From 482cd0eed6226f2321aed1d795e44713b2744576 Mon Sep 17 00:00:00 2001 From: Mihailo Milenkovic Date: Wed, 28 Aug 2019 19:01:24 +0200 Subject: [PATCH 1/2] Fix --- src/cc/CCtokens.cpp | 8 ++++---- src/cc/dice.cpp | 17 ++++++++--------- src/cc/dilithium.c | 8 ++++---- src/cc/gamescc.cpp | 24 ++++++++++-------------- src/cc/importgateway.cpp | 16 ++++++++-------- src/cc/lotto.cpp | 8 ++++---- src/cc/oracles.cpp | 6 +++--- src/cc/rewards.cpp | 16 ++++++++-------- src/cc/rogue_rpc.cpp | 6 +++--- src/komodo_nSPV_fullnode.h | 8 ++++++-- 10 files changed, 58 insertions(+), 59 deletions(-) diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index 9627e4547..6ec5db600 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -1026,7 +1026,7 @@ UniValue TokenInfo(uint256 tokenid) UniValue TokenList() { UniValue result(UniValue::VARR); - std::vector > addressIndex; + std::vector txids; std::vector > addressIndexCCMarker; struct CCcontract_info *cp, C; uint256 txid, hashBlock; @@ -1043,9 +1043,9 @@ UniValue TokenList() } }; - SetCCtxids(addressIndex, cp->normaladdr,false); // find by old normal addr marker - for (std::vector >::const_iterator it = addressIndex.begin(); it != addressIndex.end(); it++) { - addTokenId(it->first.txhash); + SetCCtxids(txids, cp->normaladdr,false,cp->evalcode,zeroid,'c'); // find by old normal addr marker + for (std::vector::const_iterator it = txids.begin(); it != txids.end(); it++) { + addTokenId(*it); } SetCCunspents(addressIndexCCMarker, cp->unspendableCCaddr,true); // find by burnable validated cc addr marker diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index 4d1453084..48d1049f9 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -1224,9 +1224,9 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontract_info *cp,uint64_t refsbits,CPubKey dicepk,int64_t &minbet,int64_t &maxbet,int64_t &maxodds,int64_t &timeoutblocks) { char CCaddr[64]; uint64_t sbits=0; uint256 txid,hashBlock; CTransaction tx; - std::vector > txids; + std::vector txids; GetCCaddress(cp,CCaddr,dicepk); - SetCCtxids(txids,cp->normaladdr,false); + SetCCtxids(txids,cp->normaladdr,false,cp->evalcode,zeroid,'F'); if ( fundingtxid != zeroid ) // avoid scan unless creating new funding plan { //fprintf(stderr,"check fundingtxid\n"); @@ -1240,10 +1240,9 @@ bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontrac } else fprintf(stderr,"couldnt get funding tx\n"); return(false); } - for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) + for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) { - //int height = it->first.blockHeight; - txid = it->first.txhash; + txid = *it; if ( fundingtxid != zeroid && txid != fundingtxid ) continue; if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && ConstrainVout(tx.vout[0],1,CCaddr,0) != 0 ) @@ -1320,12 +1319,12 @@ UniValue DiceInfo(uint256 diceid) UniValue DiceList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits; int64_t minbet,maxbet,maxodds,timeoutblocks; char str[65]; + UniValue result(UniValue::VARR); std::vector txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits; int64_t minbet,maxbet,maxodds,timeoutblocks; char str[65]; cp = CCinit(&C,EVAL_DICE); - SetCCtxids(addressIndex,cp->normaladdr,false); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + SetCCtxids(txids,cp->normaladdr,false,cp->evalcode,zeroid,'F'); + for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) { - txid = it->first.txhash; + txid = *it; if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( vintx.vout.size() > 0 && DecodeDiceFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,minbet,maxbet,maxodds,timeoutblocks) != 0 ) diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index d0f7aa16d..afeef33d9 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3580,16 +3580,16 @@ int32_t dilithium_registrationpub33(char *pkaddr,CPubKey &pub33,uint256 txid) void dilithium_handleinit(struct CCcontract_info *cp) { static int32_t didinit; - std::vector > txids; struct dilithium_handle *hashstr; CPubKey dilithiumpk,pub33; uint256 txid,hashBlock; CTransaction txi; int32_t numvouts; std::vector bigpub; std::string handle; char CCaddr[64]; + std::vector txids; struct dilithium_handle *hashstr; CPubKey dilithiumpk,pub33; uint256 txid,hashBlock; CTransaction txi; int32_t numvouts; std::vector bigpub; std::string handle; char CCaddr[64]; if ( didinit != 0 ) return; pthread_mutex_init(&DILITHIUM_MUTEX,NULL); dilithiumpk = GetUnspendable(cp,0); GetCCaddress(cp,CCaddr,dilithiumpk); - SetCCtxids(txids,CCaddr,true); - for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) + SetCCtxids(txids,CCaddr,true,cp->evalcode,zeroid,'R'); + for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) { - txid = it->first.txhash; + txid = *it; if ( myGetTransaction(txid,txi,hashBlock) != 0 && (numvouts= txi.vout.size()) > 1 ) { if ( dilithium_registeropretdecode(handle,pub33,bigpub,txi.vout[numvouts-1].scriptPubKey) == 'R' ) diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 425ae473d..a476ef92b 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1664,29 +1664,25 @@ UniValue games_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue games_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey gamespk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; - std::vector > addressIndex; + std::vector txids; gamespk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); GetCCaddress1of2(cp,coinaddr,gamespk,mypk); - SetCCtxids(addressIndex,coinaddr,true); + SetCCtxids(txids,coinaddr,true,cp->evalcode,zeroid,'R'); games_univalue(result,"games",-1,-1); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) { - txid = it->first.txhash; - vout = (int32_t)it->first.index; + txid = *it; //char str[65]; fprintf(stderr,"%s check %s/v%d %.8f\n",coinaddr,uint256_str(str,txid),vout,(double)it->second.satoshis/COIN); - if ( vout == 0 ) + if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) { - if ( myGetTransaction(txid,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 1 ) + if ( games_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) { - if ( games_registeropretdecode(gametxid,tokenid,playertxid,tx.vout[numvouts-1].scriptPubKey) == 'R' ) + if ( games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) { - if ( games_isvalidgame(cp,gameheight,gametx,buyin,maxplayers,gametxid,0) == 0 ) - { - if ( CCgettxout(txid,vout,1,0) < 0 ) - b.push_back(gametxid.GetHex()); - else a.push_back(gametxid.GetHex()); - } + if ( CCgettxout(txid,vout,1,0) < 0 ) + b.push_back(gametxid.GetHex()); + else a.push_back(gametxid.GetHex()); } } } diff --git a/src/cc/importgateway.cpp b/src/cc/importgateway.cpp index 1f16c7fd4..16b54d2b6 100644 --- a/src/cc/importgateway.cpp +++ b/src/cc/importgateway.cpp @@ -260,13 +260,13 @@ int32_t ImportGatewayBindExists(struct CCcontract_info *cp,CPubKey importgateway { char markeraddr[64],burnaddr[64]; std::string coin; int32_t numvouts; int64_t totalsupply; uint256 tokenid,oracletxid,hashBlock; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; CTransaction tx; - std::vector > addressIndex; + std::vector txids; _GetCCaddress(markeraddr,EVAL_IMPORTGATEWAY,importgatewaypk); - SetCCtxids(addressIndex,markeraddr,true); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + SetCCtxids(txids,markeraddr,true,cp->evalcode,zeroid,'B'); + for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) { - if ( myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' ) + if ( myGetTransaction(*it,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' ) { if ( DecodeImportGatewayBindOpRet(burnaddr,tx.vout[numvouts-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B' ) { @@ -1172,14 +1172,14 @@ UniValue ImportGatewayProcessedWithdraws(uint256 bindtxid,std::string refcoin) UniValue ImportGatewayList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; + UniValue result(UniValue::VARR); std::vector txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid; CTransaction vintx; std::string coin; char str[65],burnaddr[64]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; cp = CCinit(&C,EVAL_IMPORTGATEWAY); - SetCCtxids(addressIndex,cp->unspendableCCaddr,true); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + SetCCtxids(txids,cp->unspendableCCaddr,true,cp->evalcode,zeroid,'B'); + for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) { - txid = it->first.txhash; + txid = *it; if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( vintx.vout.size() > 0 && DecodeImportGatewayBindOpRet(burnaddr,vintx.vout[vintx.vout.size()-1].scriptPubKey,coin,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) != 0 ) diff --git a/src/cc/lotto.cpp b/src/cc/lotto.cpp index e8466bd88..db4414445 100644 --- a/src/cc/lotto.cpp +++ b/src/cc/lotto.cpp @@ -264,12 +264,12 @@ UniValue LottoInfo(uint256 lottoid) UniValue LottoList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,hentropy; CTransaction vintx; uint64_t sbits; int32_t ticketsize,odds,firstheight,period; char str[65]; + UniValue result(UniValue::VARR); std::vector txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock,hentropy; CTransaction vintx; uint64_t sbits; int32_t ticketsize,odds,firstheight,period; char str[65]; cp = CCinit(&C,EVAL_LOTTO); - SetCCtxids(addressIndex,cp->normaladdr,true); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + SetCCtxids(txids,cp->normaladdr,true,cp->evalcode,zeroid,'F'); + for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) { - txid = it->first.txhash; + txid = *it; if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( vintx.vout.size() > 0 && DecodeLottoFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,ticketsize,odds,firstheight,period,hentropy) == 'F' ) diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index a5a3b0f14..2ea135687 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -794,7 +794,7 @@ int64_t LifetimeOraclesFunds(struct CCcontract_info *cp,uint256 oracletxid,CPubK char coinaddr[64]; CPubKey pk; int64_t total=0,num; uint256 txid,hashBlock,subtxid; CTransaction subtx; std::vector txids; GetCCaddress(cp,coinaddr,publisher); - SetCCtxids(txids,coinaddr,true,EVAL_ORACLES,oracletxid,'S'); + SetCCtxids(txids,coinaddr,true,cp->evalcode,oracletxid,'S'); //fprintf(stderr,"scan lifetime of %s\n",coinaddr); for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) { @@ -1122,7 +1122,7 @@ UniValue OracleDataSamples(uint256 reforacletxid,char* batonaddr,int32_t num) break; } } - SetCCtxids(txids,batonaddr,true,EVAL_ORACLES,zeroid,'D'); + SetCCtxids(txids,batonaddr,true,EVAL_ORACLES,reforacletxid,'D'); if (txids.size()>0) { for (std::vector::const_iterator it=txids.end()-1; it!=txids.begin(); it--) @@ -1224,7 +1224,7 @@ UniValue OraclesList() { UniValue result(UniValue::VARR); std::vector txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction createtx; std::string name,description,format; char str[65]; cp = CCinit(&C,EVAL_ORACLES); - SetCCtxids(txids,cp->normaladdr,false,EVAL_ORACLES,zeroid,'C'); + SetCCtxids(txids,cp->normaladdr,false,cp->evalcode,zeroid,'C'); for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) { txid = *it; diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index 2d6399737..ae1bdabcb 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -432,13 +432,13 @@ int64_t RewardsPlanFunds(uint64_t &lockedfunds,uint64_t refsbits,struct CCcontra bool RewardsPlanExists(struct CCcontract_info *cp,uint64_t refsbits,CPubKey rewardspk,uint64_t &APR,uint64_t &minseconds,uint64_t &maxseconds,uint64_t &mindeposit) { char CCaddr[64]; uint64_t sbits; uint256 txid,hashBlock; CTransaction tx; - std::vector > txids; + std::vector txids; GetCCaddress(cp,CCaddr,rewardspk); - SetCCtxids(txids,CCaddr,true); - for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) + SetCCtxids(txids,CCaddr,true,cp->evalcode,zeroid,'F'); + for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) { //int height = it->first.blockHeight; - txid = it->first.txhash; + txid = *it; if ( myGetTransaction(txid,tx,hashBlock) != 0 && tx.vout.size() > 0 && ConstrainVout(tx.vout[0],1,CCaddr,0) != 0 ) { //char str[65]; fprintf(stderr,"rewards plan %s\n",uint256_str(str,txid)); @@ -492,12 +492,12 @@ UniValue RewardsInfo(uint256 rewardsid) UniValue RewardsList() { - UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; char str[65]; + UniValue result(UniValue::VARR); std::vector txids; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction vintx; uint64_t sbits,APR,minseconds,maxseconds,mindeposit; char str[65]; cp = CCinit(&C,EVAL_REWARDS); - SetCCtxids(addressIndex,cp->normaladdr,false); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + SetCCtxids(txids,cp->normaladdr,false,cp->evalcode,zeroid,'F'); + for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) { - txid = it->first.txhash; + txid = *it; if ( myGetTransaction(txid,vintx,hashBlock) != 0 ) { if ( vintx.vout.size() > 0 && DecodeRewardsFundingOpRet(vintx.vout[vintx.vout.size()-1].scriptPubKey,sbits,APR,minseconds,maxseconds,mindeposit) != 0 ) diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index a6168a206..04d0d9e1f 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -1452,15 +1452,15 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) { UniValue result(UniValue::VOBJ),a(UniValue::VARR),b(UniValue::VARR); uint256 txid,hashBlock,gametxid,tokenid,playertxid; int32_t vout,maxplayers,gameheight,numvouts; CPubKey roguepk,mypk; char coinaddr[64]; CTransaction tx,gametx; int64_t buyin; - std::vector > addressIndex; + std::vector txids; //std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); //SetCCunspents(unspentOutputs,coinaddr); - SetCCtxids(addressIndex,coinaddr,true); + SetCCtxids(txids,coinaddr,true,cp->evalcode,zeroid,'R'); rogue_univalue(result,"games",-1,-1); - for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) + for (std::vector::const_iterator it=txids.begin(); it!=txids.end(); it++) //for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/komodo_nSPV_fullnode.h b/src/komodo_nSPV_fullnode.h index 20cdb8dd4..b53b77594 100644 --- a/src/komodo_nSPV_fullnode.h +++ b/src/komodo_nSPV_fullnode.h @@ -286,10 +286,14 @@ int32_t NSPV_mempoolfuncs(bits256 *satoshisp,int32_t *vindexp,std::vector> e; ss >> f; ss >> tmp_txid;); if (e!=eval || (txid!=zeroid && txid!=tmp_txid) || (func!=0 && f!=func)) continue; - break; + break; + case EVAL_TOKENS:EVAL_DICE:EVAL_DILITHIUM:EVAL_FAUCET:EVAL_LOTO:EVAL_PAYMENTS:EVAL_REWARDS: + E_UNMARSHAL(vopret,ss >> e; ss >> f;); + if (e!=eval || (func!=0 && f!=func)) continue; + break; default: break; } From bcf242808bca9656d91e2be7131053e3a5626997 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 7 Sep 2019 20:10:05 -1100 Subject: [PATCH 2/2] Fix adaptive pow else --- src/rpc/mining.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 741f02f7b..6f5254cc3 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -884,8 +884,8 @@ UniValue getblocktemplate(const UniValue& params, bool fHelp) result.push_back(Pair("origtarget", hashTarget.GetHex())); } /*else if ( ASSETCHAINS_ADAPTIVEPOW > 0 ) - result.push_back(Pair("target",komodo_adaptivepow_target((int32_t)(pindexPrev->GetHeight()+1),hashTarget,pblock->nTime).GetHex())); - else*/ + result.push_back(Pair("target",komodo_adaptivepow_target((int32_t)(pindexPrev->GetHeight()+1),hashTarget,pblock->nTime).GetHex()));*/ + else result.push_back(Pair("target", hashTarget.GetHex())); result.push_back(Pair("mintime", (int64_t)pindexPrev->GetMedianTimePast()+1)); result.push_back(Pair("mutable", aMutable));