From eff8c62cb321922dbf91a45eb74c4d86d8bdb78e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 22:04:40 -1100 Subject: [PATCH 01/20] Test --- src/cc/gateways.cpp | 4 ++-- src/komodo_utils.h | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 283ba91a1..a61fe2ba4 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -554,8 +554,8 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u return(mhash); } else return(zeroid); } - batontxid = hash; - } else break; + } //else break; + batontxid = hash; } return(zeroid); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 79c0b4671..75f68d87d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1705,7 +1705,10 @@ void komodo_args(char *argv0) BITCOIND_RPCPORT = GetArg("-rpcport", ASSETCHAINS_RPCPORT); //fprintf(stderr,"(%s) port.%u chain params initialized\n",ASSETCHAINS_SYMBOL,BITCOIND_RPCPORT); if ( strcmp("PIRATE",ASSETCHAINS_SYMBOL) == 0 && ASSETCHAINS_HALVING == 77777 ) + { ASSETCHAINS_HALVING *= 5; + fprintf(stderr,"PIRATE halving changed to %d %.1f days\n",(int32_t)ASSETCHAINS_HALVING,(double)ASSETCHAINS_HALVING/1440); + } } else BITCOIND_RPCPORT = GetArg("-rpcport", BaseParams().RPCPort()); } From 8dab0bc78c6a9ff41bf3e34661e08bcdf1a78c12 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 22:10:42 -1100 Subject: [PATCH 02/20] Test --- src/cc/oracles.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index c24ad5a8b..a0437ed0f 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -157,7 +157,8 @@ uint8_t DecodeOraclesData(const CScript &scriptPubKey,uint256 &oracletxid,uint25 { if ( e == EVAL_ORACLES && f == 'D' ) return(f); - } + else fprintf(stderr,"DecodeOraclesData evalcode.%d f.%c\n",e,f); + } else fprintf(stderr,"DecodeOraclesData not enough opereturn data\n"); return(0); } From d4f6cde55040c8e9beea6f410698c5ad92059afb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 22:18:37 -1100 Subject: [PATCH 03/20] Test --- src/cc/gateways.cpp | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index a61fe2ba4..5ec01b8fd 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -539,24 +539,32 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u { CTransaction tx; uint256 hash,mhash,hashBlock,oracletxid; int64_t val; int32_t numvouts; int64_t merkleht; CPubKey pk; std::vectordata; txid = zeroid; - char str[65]; fprintf(stderr,"reverse scan %s\n",uint256_str(str,batontxid)); + char str[65]; fprintf(stderr,"start reverse scan %s\n",uint256_str(str,batontxid)); while ( GetTransaction(batontxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { - fprintf(stderr,"reverse scan %s\n",uint256_str(str,batontxid)); if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,hash,pk,data) == 'D' && oracletxid == reforacletxid ) { + fprintf(stderr,"decoded %s\n",uint256_str(str,batontxid)); if ( oracle_format(&hash,&merkleht,0,'I',(uint8_t *)data.data(),0,(int32_t)data.size()) == sizeof(int32_t) && merkleht == height ) { + fprintf(stderr,"found merkleht.%d\n",merkleht); if ( oracle_format(&hash,&val,0,'h',(uint8_t *)data.data(),sizeof(int32_t),(int32_t)data.size()) == sizeof(hash) && oracle_format(&mhash,&val,0,'h',(uint8_t *)data.data(),(int32_t)(sizeof(int32_t)+sizeof(uint256)),(int32_t)data.size()) == sizeof(hash) && mhash != zeroid ) { txid = batontxid; + fprintf(stderr,"set txid\n"); return(mhash); - } else return(zeroid); - } - } //else break; - batontxid = hash; + } + else + { + fprintf(stderr,"missing hash\n"); + return(zeroid); + } + } else fprintf(stderr,"height.%d vs search ht.%d\n",merkleht,height); + batontxid = hash; + } else break; } + fprintf(stderr,"end of loop\n"); return(zeroid); } From 36fbbfe6fcdfa56f17e4f01a5843724ff724d8dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 22:20:51 -1100 Subject: [PATCH 04/20] Test --- src/cc/gateways.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 5ec01b8fd..04c585cd3 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -547,7 +547,7 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u fprintf(stderr,"decoded %s\n",uint256_str(str,batontxid)); if ( oracle_format(&hash,&merkleht,0,'I',(uint8_t *)data.data(),0,(int32_t)data.size()) == sizeof(int32_t) && merkleht == height ) { - fprintf(stderr,"found merkleht.%d\n",merkleht); + fprintf(stderr,"found merkleht.%d\n",(int32_t)merkleht); if ( oracle_format(&hash,&val,0,'h',(uint8_t *)data.data(),sizeof(int32_t),(int32_t)data.size()) == sizeof(hash) && oracle_format(&mhash,&val,0,'h',(uint8_t *)data.data(),(int32_t)(sizeof(int32_t)+sizeof(uint256)),(int32_t)data.size()) == sizeof(hash) && mhash != zeroid ) { @@ -560,7 +560,7 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u fprintf(stderr,"missing hash\n"); return(zeroid); } - } else fprintf(stderr,"height.%d vs search ht.%d\n",merkleht,height); + } else fprintf(stderr,"height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); batontxid = hash; } else break; } From 2ca4cd6e9a791bfd4b6bd022cb1650e55270718c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 22:25:15 -1100 Subject: [PATCH 05/20] Test --- src/cc/gateways.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 04c585cd3..2452825f3 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -542,6 +542,7 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u char str[65]; fprintf(stderr,"start reverse scan %s\n",uint256_str(str,batontxid)); while ( GetTransaction(batontxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { + fprintf(stderr,"check %s\n",uint256_str(str,batontxid)); if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,hash,pk,data) == 'D' && oracletxid == reforacletxid ) { fprintf(stderr,"decoded %s\n",uint256_str(str,batontxid)); @@ -562,6 +563,7 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u } } else fprintf(stderr,"height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); batontxid = hash; + fprintf(stderr,"new hash %s\n",uint256_str(str,batontxid)); } else break; } fprintf(stderr,"end of loop\n"); From b73666e2ffa061ecac897e43462666101d552ca2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 22:26:42 -1100 Subject: [PATCH 06/20] Test --- src/cc/gateways.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 2452825f3..ec0fb919b 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -537,13 +537,13 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,uint256 batontxid) { - CTransaction tx; uint256 hash,mhash,hashBlock,oracletxid; int64_t val; int32_t numvouts; int64_t merkleht; CPubKey pk; std::vectordata; + CTransaction tx; uint256 hash,mhash,bhash,hashBlock,oracletxid; int64_t val; int32_t numvouts; int64_t merkleht; CPubKey pk; std::vectordata; txid = zeroid; char str[65]; fprintf(stderr,"start reverse scan %s\n",uint256_str(str,batontxid)); while ( GetTransaction(batontxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { fprintf(stderr,"check %s\n",uint256_str(str,batontxid)); - if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,hash,pk,data) == 'D' && oracletxid == reforacletxid ) + if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,bhash,pk,data) == 'D' && oracletxid == reforacletxid ) { fprintf(stderr,"decoded %s\n",uint256_str(str,batontxid)); if ( oracle_format(&hash,&merkleht,0,'I',(uint8_t *)data.data(),0,(int32_t)data.size()) == sizeof(int32_t) && merkleht == height ) @@ -562,7 +562,7 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u return(zeroid); } } else fprintf(stderr,"height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); - batontxid = hash; + batontxid = bhash; fprintf(stderr,"new hash %s\n",uint256_str(str,batontxid)); } else break; } From 11b0ed84d56ee172ca7639957c61123af7a9d5ca Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 22:33:18 -1100 Subject: [PATCH 07/20] Test --- src/cc/gateways.cpp | 15 ++++++++------- src/cc/oracles.cpp | 4 ++-- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index ec0fb919b..7c70408d8 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -537,20 +537,21 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,uint256 batontxid) { - CTransaction tx; uint256 hash,mhash,bhash,hashBlock,oracletxid; int64_t val; int32_t numvouts; int64_t merkleht; CPubKey pk; std::vectordata; + CTransaction tx; uint256 hash,mhash,bhash,hashBlock,oracletxid; int32_t len,len2,numvouts; int64_t val,merkleht; CPubKey pk; std::vectordata; txid = zeroid; - char str[65]; fprintf(stderr,"start reverse scan %s\n",uint256_str(str,batontxid)); + //char str[65]; fprintf(stderr,"start reverse scan %s\n",uint256_str(str,batontxid)); while ( GetTransaction(batontxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { - fprintf(stderr,"check %s\n",uint256_str(str,batontxid)); + //fprintf(stderr,"check %s\n",uint256_str(str,batontxid)); if ( DecodeOraclesData(tx.vout[numvouts-1].scriptPubKey,oracletxid,bhash,pk,data) == 'D' && oracletxid == reforacletxid ) { - fprintf(stderr,"decoded %s\n",uint256_str(str,batontxid)); + //fprintf(stderr,"decoded %s\n",uint256_str(str,batontxid)); if ( oracle_format(&hash,&merkleht,0,'I',(uint8_t *)data.data(),0,(int32_t)data.size()) == sizeof(int32_t) && merkleht == height ) { - fprintf(stderr,"found merkleht.%d\n",(int32_t)merkleht); - if ( oracle_format(&hash,&val,0,'h',(uint8_t *)data.data(),sizeof(int32_t),(int32_t)data.size()) == sizeof(hash) && - oracle_format(&mhash,&val,0,'h',(uint8_t *)data.data(),(int32_t)(sizeof(int32_t)+sizeof(uint256)),(int32_t)data.size()) == sizeof(hash) && mhash != zeroid ) + len = oracle_format(&hash,&val,0,'h',(uint8_t *)data.data(),sizeof(int32_t),(int32_t)data.size()); + len2 = oracle_format(&mhash,&val,0,'h',(uint8_t *)data.data(),(int32_t)(sizeof(int32_t)+sizeof(uint256)),(int32_t)data.size()); + char str2[65]; fprintf(stderr,"found merkleht.%d len.%d len2.%d %s %s\n",(int32_t)merkleht,len,len2,uint256_str(str,hash),uint256_str(str2,mhash)); + if ( len == sizeof(hash) && len2 == sizeof(mhash) && mhash != zeroid ) { txid = batontxid; fprintf(stderr,"set txid\n"); diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index a0437ed0f..6af1453ce 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -157,8 +157,8 @@ uint8_t DecodeOraclesData(const CScript &scriptPubKey,uint256 &oracletxid,uint25 { if ( e == EVAL_ORACLES && f == 'D' ) return(f); - else fprintf(stderr,"DecodeOraclesData evalcode.%d f.%c\n",e,f); - } else fprintf(stderr,"DecodeOraclesData not enough opereturn data\n"); + //else fprintf(stderr,"DecodeOraclesData evalcode.%d f.%c\n",e,f); + } //else fprintf(stderr,"DecodeOraclesData not enough opereturn data\n"); return(0); } From e072837352c08975ce67eae86e5b68e6ca67b998 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 22:36:45 -1100 Subject: [PATCH 08/20] Test --- src/cc/gateways.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 7c70408d8..68f639ff3 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -539,7 +539,8 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u { CTransaction tx; uint256 hash,mhash,bhash,hashBlock,oracletxid; int32_t len,len2,numvouts; int64_t val,merkleht; CPubKey pk; std::vectordata; txid = zeroid; - //char str[65]; fprintf(stderr,"start reverse scan %s\n",uint256_str(str,batontxid)); + char str[65]; + //fprintf(stderr,"start reverse scan %s\n",uint256_str(str,batontxid)); while ( GetTransaction(batontxid,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) { //fprintf(stderr,"check %s\n",uint256_str(str,batontxid)); From b6283728906e81650d649bcc2d5fa879c83200cf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 22:38:59 -1100 Subject: [PATCH 09/20] Test --- src/cc/gateways.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 68f639ff3..7d886a5b7 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -552,7 +552,7 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u len = oracle_format(&hash,&val,0,'h',(uint8_t *)data.data(),sizeof(int32_t),(int32_t)data.size()); len2 = oracle_format(&mhash,&val,0,'h',(uint8_t *)data.data(),(int32_t)(sizeof(int32_t)+sizeof(uint256)),(int32_t)data.size()); char str2[65]; fprintf(stderr,"found merkleht.%d len.%d len2.%d %s %s\n",(int32_t)merkleht,len,len2,uint256_str(str,hash),uint256_str(str2,mhash)); - if ( len == sizeof(hash) && len2 == sizeof(mhash) && mhash != zeroid ) + if ( len == sizeof(hash)+sizeof(int32_t) && len2 == 2*sizeof(mhash)+sizeof(int32_t) && mhash != zeroid ) { txid = batontxid; fprintf(stderr,"set txid\n"); @@ -565,7 +565,7 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u } } else fprintf(stderr,"height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); batontxid = bhash; - fprintf(stderr,"new hash %s\n",uint256_str(str,batontxid)); + //fprintf(stderr,"new hash %s\n",uint256_str(str,batontxid)); } else break; } fprintf(stderr,"end of loop\n"); From 186ce5d29dcbab3df4cc522cac33b9861bcc00fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 22:44:19 -1100 Subject: [PATCH 10/20] Test --- src/cc/gateways.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 7d886a5b7..53a4d8765 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -555,15 +555,15 @@ uint256 GatewaysReverseScan(uint256 &txid,int32_t height,uint256 reforacletxid,u if ( len == sizeof(hash)+sizeof(int32_t) && len2 == 2*sizeof(mhash)+sizeof(int32_t) && mhash != zeroid ) { txid = batontxid; - fprintf(stderr,"set txid\n"); + //fprintf(stderr,"set txid\n"); return(mhash); } else { - fprintf(stderr,"missing hash\n"); + //fprintf(stderr,"missing hash\n"); return(zeroid); } - } else fprintf(stderr,"height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); + } //else fprintf(stderr,"height.%d vs search ht.%d\n",(int32_t)merkleht,(int32_t)height); batontxid = bhash; //fprintf(stderr,"new hash %s\n",uint256_str(str,batontxid)); } else break; @@ -626,7 +626,7 @@ int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout { fprintf(stderr,"verify proof for cointxid in merkleroot\n"); return(nValue); - } else fprintf(stderr,"(%s) != (%s) or txid mismatch.%d or script mismatch\n",refdepositaddr,destaddr,txid != cointxid); + } else fprintf(stderr,"(%s) != (%s) or txid %s mismatch.%d or script mismatch\n",refdepositaddr,destaddr,uint256_str(str,txid),txid != cointxid); return(0); } @@ -679,7 +679,7 @@ std::string GatewaysDeposit(uint64_t txfee,uint256 bindtxid,int32_t height,std:: txids.push_back(txid); } } - fprintf(stderr,"m.%d of n.%d\n",m,n); + fprintf(stderr,"cointxid.%s m.%d of n.%d\n",uint256_str(str,cointxid),m,n); if ( merkleroot == zeroid || m < n/2 ) { //uint256 tmp; From 1826284cb3b3d3a0202f554e3a6e645ed2526814 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 22:51:01 -1100 Subject: [PATCH 11/20] Print --- src/cc/gateways.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 53a4d8765..be61cffc4 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -624,7 +624,7 @@ int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout } if ( txid == cointxid ) { - fprintf(stderr,"verify proof for cointxid in merkleroot\n"); + fprintf(stderr,"verified proof for cointxid in merkleroot\n"); return(nValue); } else fprintf(stderr,"(%s) != (%s) or txid %s mismatch.%d or script mismatch\n",refdepositaddr,destaddr,uint256_str(str,txid),txid != cointxid); return(0); From 5c43df8b4836825a144ddaa87c0acde52785eacc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 23:14:55 -1100 Subject: [PATCH 12/20] Test --- src/cc/gateways.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index be61cffc4..345b00f7e 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -298,6 +298,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); SetCCunspents(unspentOutputs,coinaddr); + fprintf(stderr,"check %s for gateway inputs\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -316,6 +317,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP if ( E_UNMARSHAL(vopret,ss >> evalcode; ss >> funcid; ss >> assetid) != 0 ) { assetid = revuint256(assetid); + char str[65]; fprintf(stderr,"check for assetid.%s\n",uint256_str(str,assetid)); if ( evalcode == cp->evalcode && assetid == refassetid && funcid == 't' && (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { if ( total != 0 && maxinputs != 0 ) From 733b58f24921d5f67df9eff981715e3e944a5151 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 23:23:20 -1100 Subject: [PATCH 13/20] Test --- src/cc/gateways.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 345b00f7e..3ebe0e8e0 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -317,12 +317,13 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP if ( E_UNMARSHAL(vopret,ss >> evalcode; ss >> funcid; ss >> assetid) != 0 ) { assetid = revuint256(assetid); - char str[65]; fprintf(stderr,"check for assetid.%s\n",uint256_str(str,assetid)); + char str[65]; fprintf(stderr,"%d:%d (%c) check for refassetid.%s vs %s %.8f\n",evalcode,cp->evalcode,funcid,uint256_str(str,refassetid),uint256_str(str2,assetid),(double)nValue/COIN); if ( evalcode == cp->evalcode && assetid == refassetid && funcid == 't' && (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { + fprintf(stderr,"total %llu maxinputs.%d %.8f\n",(long long)total,maxinputs,(double)it->second.satoshis/COIN); if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); - nValue = it->second.satoshis; + //nValue = it->second.satoshis; totalinputs += nValue; n++; if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) From c15c1ad2ef71a4ff991fc914a9ecb3d6a5f3fb38 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 23:25:22 -1100 Subject: [PATCH 14/20] Test --- src/cc/gateways.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 3ebe0e8e0..aeeb85a8a 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -317,7 +317,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP if ( E_UNMARSHAL(vopret,ss >> evalcode; ss >> funcid; ss >> assetid) != 0 ) { assetid = revuint256(assetid); - char str[65]; fprintf(stderr,"%d:%d (%c) check for refassetid.%s vs %s %.8f\n",evalcode,cp->evalcode,funcid,uint256_str(str,refassetid),uint256_str(str2,assetid),(double)nValue/COIN); + char str[65],str2[65]; fprintf(stderr,"%d:%d (%c) check for refassetid.%s vs %s %.8f\n",evalcode,cp->evalcode,funcid,uint256_str(str,refassetid),uint256_str(str2,assetid),(double)nValue/COIN); if ( evalcode == cp->evalcode && assetid == refassetid && funcid == 't' && (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { fprintf(stderr,"total %llu maxinputs.%d %.8f\n",(long long)total,maxinputs,(double)it->second.satoshis/COIN); From c884b0f0eabdbab44580ee7fcb7e3c632c40afc7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 23:30:19 -1100 Subject: [PATCH 15/20] Test --- src/cc/gateways.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index aeeb85a8a..cecb87b1a 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -311,13 +311,14 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { Getscriptaddress(destaddr,vintx.vout[vout].scriptPubKey); + fprintf(stderr,"%s vout.%d %.8f\n",destaddr,vout,(double)vintx.vout[vout].nValue/COIN); if ( strcmp(destaddr,coinaddr) != 0 && strcmp(destaddr,cp->unspendableCCaddr) != 0 && strcmp(destaddr,cp->unspendableaddr2) != 0 ) continue; GetOpReturnData(vintx.vout[vintx.vout.size()-1].scriptPubKey, vopret); if ( E_UNMARSHAL(vopret,ss >> evalcode; ss >> funcid; ss >> assetid) != 0 ) { assetid = revuint256(assetid); - char str[65],str2[65]; fprintf(stderr,"%d:%d (%c) check for refassetid.%s vs %s %.8f\n",evalcode,cp->evalcode,funcid,uint256_str(str,refassetid),uint256_str(str2,assetid),(double)nValue/COIN); + char str[65],str2[65]; fprintf(stderr,"vout.%d %d:%d (%c) check for refassetid.%s vs %s %.8f\n",vout,evalcode,cp->evalcode,funcid,uint256_str(str,refassetid),uint256_str(str2,assetid),(double)nValue/COIN); if ( evalcode == cp->evalcode && assetid == refassetid && funcid == 't' && (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { fprintf(stderr,"total %llu maxinputs.%d %.8f\n",(long long)total,maxinputs,(double)it->second.satoshis/COIN); From 2511d10f8a55a728895d37f8bad910d846d316a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 23:33:24 -1100 Subject: [PATCH 16/20] Test --- src/cc/gateways.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index cecb87b1a..b5c0ba6bd 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -311,15 +311,15 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { Getscriptaddress(destaddr,vintx.vout[vout].scriptPubKey); - fprintf(stderr,"%s vout.%d %.8f\n",destaddr,vout,(double)vintx.vout[vout].nValue/COIN); + fprintf(stderr,"%s vout.%d %.8f %.8f\n",destaddr,vout,(double)vintx.vout[vout].nValue/COIN,(double)it->second.satoshis/COIN); if ( strcmp(destaddr,coinaddr) != 0 && strcmp(destaddr,cp->unspendableCCaddr) != 0 && strcmp(destaddr,cp->unspendableaddr2) != 0 ) continue; GetOpReturnData(vintx.vout[vintx.vout.size()-1].scriptPubKey, vopret); if ( E_UNMARSHAL(vopret,ss >> evalcode; ss >> funcid; ss >> assetid) != 0 ) { assetid = revuint256(assetid); - char str[65],str2[65]; fprintf(stderr,"vout.%d %d:%d (%c) check for refassetid.%s vs %s %.8f\n",vout,evalcode,cp->evalcode,funcid,uint256_str(str,refassetid),uint256_str(str2,assetid),(double)nValue/COIN); - if ( evalcode == cp->evalcode && assetid == refassetid && funcid == 't' && (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) + char str[65],str2[65]; fprintf(stderr,"vout.%d %d:%d (%c) check for refassetid.%s vs %s %.8f\n",vout,evalcode,cp->evalcode,funcid,uint256_str(str,refassetid),uint256_str(str2,assetid),(double)vintx.vout[vout].nValue/COIN); + if ( assetid == refassetid && funcid == 't' && (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { fprintf(stderr,"total %llu maxinputs.%d %.8f\n",(long long)total,maxinputs,(double)it->second.satoshis/COIN); if ( total != 0 && maxinputs != 0 ) From 983ff7f46d38c42acdbf11867f7931a7b61228ce Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 23 Sep 2018 23:34:34 -1100 Subject: [PATCH 17/20] Test --- src/cc/gateways.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index b5c0ba6bd..566177ea6 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -311,17 +311,17 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP if ( GetTransaction(txid,vintx,hashBlock,false) != 0 ) { Getscriptaddress(destaddr,vintx.vout[vout].scriptPubKey); - fprintf(stderr,"%s vout.%d %.8f %.8f\n",destaddr,vout,(double)vintx.vout[vout].nValue/COIN,(double)it->second.satoshis/COIN); + //fprintf(stderr,"%s vout.%d %.8f %.8f\n",destaddr,vout,(double)vintx.vout[vout].nValue/COIN,(double)it->second.satoshis/COIN); if ( strcmp(destaddr,coinaddr) != 0 && strcmp(destaddr,cp->unspendableCCaddr) != 0 && strcmp(destaddr,cp->unspendableaddr2) != 0 ) continue; GetOpReturnData(vintx.vout[vintx.vout.size()-1].scriptPubKey, vopret); if ( E_UNMARSHAL(vopret,ss >> evalcode; ss >> funcid; ss >> assetid) != 0 ) { assetid = revuint256(assetid); - char str[65],str2[65]; fprintf(stderr,"vout.%d %d:%d (%c) check for refassetid.%s vs %s %.8f\n",vout,evalcode,cp->evalcode,funcid,uint256_str(str,refassetid),uint256_str(str2,assetid),(double)vintx.vout[vout].nValue/COIN); + //char str[65],str2[65]; fprintf(stderr,"vout.%d %d:%d (%c) check for refassetid.%s vs %s %.8f\n",vout,evalcode,cp->evalcode,funcid,uint256_str(str,refassetid),uint256_str(str2,assetid),(double)vintx.vout[vout].nValue/COIN); if ( assetid == refassetid && funcid == 't' && (nValue= vintx.vout[vout].nValue) > 0 && myIsutxo_spentinmempool(txid,vout) == 0 ) { - fprintf(stderr,"total %llu maxinputs.%d %.8f\n",(long long)total,maxinputs,(double)it->second.satoshis/COIN); + //fprintf(stderr,"total %llu maxinputs.%d %.8f\n",(long long)total,maxinputs,(double)it->second.satoshis/COIN); if ( total != 0 && maxinputs != 0 ) mtx.vin.push_back(CTxIn(txid,vout,CScript())); //nValue = it->second.satoshis; From 2ce154d60efed158f51d76eb6a8787e939097d37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 24 Sep 2018 00:36:18 -1100 Subject: [PATCH 18/20] Allow sendtoaddress for PIRATE to notary --- src/wallet/rpcwallet.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5a14370c4..e02cad35f 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -398,7 +398,7 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr // Parse Zcash address CScript scriptPubKey = GetScriptForDestination(address); - + // Create and send the transaction CReserveKey reservekey(pwalletMain); CAmount nFeeRequired; @@ -430,6 +430,8 @@ static void SendMoney(const CTxDestination &address, CAmount nValue, bool fSubtr throw JSONRPCError(RPC_WALLET_ERROR, "Error: The transaction was rejected! This might happen if some of the coins in your wallet were already spent, such as if you used a copy of wallet.dat and coins were spent in the copy but not marked as spent here."); } +int32_t komodo_isnotaryvout(char *coinaddr); + UniValue sendtoaddress(const UniValue& params, bool fHelp) { if (!EnsureWalletIsAvailable(fHelp)) @@ -460,8 +462,12 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp) ); if ( ASSETCHAINS_PRIVATE != 0 && AmountFromValue(params[1]) > 0 ) - throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid " + strprintf("%s",komodo_chainname()) + " address"); - + { + if ( komodo_isnotaryvout((char *)params[0].get_str().c_ctr()) == 0 ) + { + throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid " + strprintf("%s",komodo_chainname()) + " address"); + } + } LOCK2(cs_main, pwalletMain->cs_wallet); CBitcoinAddress address(params[0].get_str()); From 10a5fd2cd0d813443fae9452cf1f616bb3f9e797 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 24 Sep 2018 00:37:09 -1100 Subject: [PATCH 19/20] Test --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e02cad35f..cf86a0ba5 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -463,7 +463,7 @@ UniValue sendtoaddress(const UniValue& params, bool fHelp) if ( ASSETCHAINS_PRIVATE != 0 && AmountFromValue(params[1]) > 0 ) { - if ( komodo_isnotaryvout((char *)params[0].get_str().c_ctr()) == 0 ) + if ( komodo_isnotaryvout((char *)params[0].get_str().c_str()) == 0 ) { throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid " + strprintf("%s",komodo_chainname()) + " address"); } From 6b72038d2d7eb22798c2d587f9a06bb8425d978f Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 24 Sep 2018 03:45:08 -1100 Subject: [PATCH 20/20] add claimpubkey check --- src/cc/gateways.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 566177ea6..a0b3a7210 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -634,12 +634,12 @@ int64_t GatewaysVerify(char *refdepositaddr,uint256 oracletxid,int32_t claimvout return(0); } -int64_t GatewaysDepositval(CTransaction tx) +int64_t GatewaysDepositval(CTransaction tx,CPubKey mypk) { int32_t numvouts,height; int64_t amount; std::string coin,deposithex; std::vector publishers; std::vectortxids; uint256 bindtxid,cointxid; std::vector proof; CPubKey claimpubkey; if ( (numvouts= tx.vout.size()) > 0 ) { - if ( DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey,coin,bindtxid,publishers,txids,height,cointxid,deposithex,proof,claimpubkey,amount) == 'D' ) + if ( DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey,coin,bindtxid,publishers,txids,height,cointxid,deposithex,proof,claimpubkey,amount) == 'D' && claimpubkey == mypk ) { // coin, bindtxid, publishers fprintf(stderr,"need to validate deposittxid more\n"); @@ -735,7 +735,7 @@ std::string GatewaysClaim(uint64_t txfee,uint256 bindtxid,std::string refcoin,ui fprintf(stderr,"cant find deposittxid %s\n",uint256_str(str,bindtxid)); return(""); } - if ( (depositamount= GatewaysDepositval(tx)) != amount ) + if ( (depositamount= GatewaysDepositval(tx,mypk)) != amount ) { fprintf(stderr,"invalid Gateways deposittxid %s %.8f != %.8f\n",uint256_str(str,deposittxid),(double)depositamount/COIN,(double)amount/COIN); return("");