diff --git a/src/cc/CCassetstx.cpp b/src/cc/CCassetstx.cpp index dfe04fcb2..0929591ff 100644 --- a/src/cc/CCassetstx.cpp +++ b/src/cc/CCassetstx.cpp @@ -16,55 +16,6 @@ #include "CCassets.h" #include "CCtokens.h" -/* use AddTokenCCInputs instead -int64_t AddAssetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,uint256 assetid,int64_t total,int32_t maxinputs) -{ - char coinaddr[64],destaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t j,vout,n = 0; - std::vector > unspentOutputs; - GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); - - threshold = total/(maxinputs!=0?maxinputs:64); // TODO: is maxinputs really not over 64, what if i want to calc total balance? - - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) - { - txid = it->first.txhash; - vout = (int32_t)it->first.index; - - if (it->second.satoshis < threshold) - continue; - - for (j=0; junspendableCCaddr) != 0 && strcmp(destaddr,cp->unspendableaddr2) != 0 ) - continue; - fprintf(stderr,"AddAssetInputs() check destaddress=%s vout amount=%.8f\n",destaddr,(double)vintx.vout[vout].nValue/COIN); - if( (nValue = IsAssetvout(cp, price, origpubkey, vintx, vout, assetid)) > 0 && myIsutxo_spentinmempool(ignoretxid,ignorevin,txid,vout) == 0 ) - { - if ( total != 0 && maxinputs != 0 ) - mtx.vin.push_back(CTxIn(txid,vout,CScript())); - nValue = it->second.satoshis; - totalinputs += nValue; - //std::cerr << "AddAssetInputs() adding input nValue=" << nValue << std::endl; - n++; - if ( (total > 0 && totalinputs >= total) || (maxinputs > 0 && n >= maxinputs) ) - break; - } - } - } - - //std::cerr << "AddAssetInputs() found totalinputs=" << totalinputs << std::endl; - return(totalinputs); -} -*/ UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode) { @@ -165,7 +116,7 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode) char assetsUnspendableAddr[64]; GetCCaddress(cpAssets, assetsUnspendableAddr, GetUnspendable(cpAssets, NULL)); - SetCCunspents(unspentOutputsCoins, assetsUnspendableAddr); + SetCCunspents(unspentOutputsCoins, assetsUnspendableAddr,true); char assetsTokensUnspendableAddr[64]; std::vector vopretNonfungible; @@ -175,7 +126,7 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode) cpAssets->additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; } GetTokensCCaddress(cpAssets, assetsTokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); - SetCCunspents(unspentOutputsTokens, assetsTokensUnspendableAddr); + SetCCunspents(unspentOutputsTokens, assetsTokensUnspendableAddr,true); // tokenbids: for (std::vector >::const_iterator itCoins = unspentOutputsCoins.begin(); @@ -195,7 +146,7 @@ UniValue AssetOrders(uint256 refassetid, CPubKey pk, uint8_t additionalEvalCode) // try also dual eval tokenasks (and we do not need bids): cpAssets->additionalTokensEvalcode2 = additionalEvalCode; GetTokensCCaddress(cpAssets, assetsDualEvalTokensUnspendableAddr, GetUnspendable(cpAssets, NULL)); - SetCCunspents(unspentOutputsDualEvalTokens, assetsDualEvalTokensUnspendableAddr); + SetCCunspents(unspentOutputsDualEvalTokens, assetsDualEvalTokensUnspendableAddr,true); for (std::vector >::const_iterator itDualEvalTokens = unspentOutputsDualEvalTokens.begin(); itDualEvalTokens != unspentOutputsDualEvalTokens.end(); diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index d1fda0154..08d466411 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -179,7 +179,7 @@ int32_t decode_hex(uint8_t *bytes,int32_t n,char *hex); int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); int32_t iguana_rwbignum(int32_t rwflag,uint8_t *serialized,int32_t len,uint8_t *endianedp); CScript GetScriptForMultisig(int nRequired, const std::vector& keys); -int64_t CCaddress_balance(char *coinaddr); +int64_t CCaddress_balance(char *coinaddr,int32_t CCflag); CPubKey CCtxidaddr(char *txidaddr,uint256 txid); CPubKey CCCustomtxidaddr(char *txidaddr,uint256 txid,uint8_t taddr,uint8_t prefix,uint8_t prefix2); bool GetCCParams(Eval* eval, const CTransaction &tx, uint32_t nIn, @@ -278,11 +278,11 @@ CPubKey check_signing_pubkey(CScript scriptSig); bool SignTx(CMutableTransaction &mtx,int32_t vini,int64_t utxovalue,const CScript scriptPubKey); extern std::vector NULL_pubkeys; std::string FinalizeCCTx(uint64_t skipmask,struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey mypk,uint64_t txfee,CScript opret,std::vector pubkeys = NULL_pubkeys); -void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr); -void SetCCtxids(std::vector > &addressIndex,char *coinaddr); +void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr,bool CCflag = true); +void SetCCtxids(std::vector > &addressIndex,char *coinaddr,bool CCflag = true); int64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,int64_t total,int32_t maxinputs); int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinputs); -int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout); +int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag); // curve25519 and sha256 bits256 curve25519_shared(bits256 privkey,bits256 otherpub); diff --git a/src/cc/CCtokens.cpp b/src/cc/CCtokens.cpp index a81a69b1f..a6ecf7123 100644 --- a/src/cc/CCtokens.cpp +++ b/src/cc/CCtokens.cpp @@ -580,7 +580,7 @@ int64_t AddTokenCCInputs(struct CCcontract_info *cp, CMutableTransaction &mtx, C cp->additionalTokensEvalcode2 = vopretNonfungible.begin()[0]; GetTokensCCaddress(cp, tokenaddr, pk); - SetCCunspents(unspentOutputs, tokenaddr); + SetCCunspents(unspentOutputs, tokenaddr,true); if (unspentOutputs.empty()) { LOGSTREAM((char *)"cctokens", CCLOG_INFO, stream << "AddTokenCCInputs() no utxos for token dual/three eval addr=" << tokenaddr << " evalcode=" << (int)cp->evalcode << " additionalTokensEvalcode2=" << (int)cp->additionalTokensEvalcode2 << std::endl); @@ -942,12 +942,12 @@ UniValue TokenList() } }; - SetCCtxids(addressIndex, cp->normaladdr); // find by old normal addr marker + 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); } - SetCCunspents(addressIndexCCMarker, cp->unspendableCCaddr); // find by burnable validated cc addr marker + SetCCunspents(addressIndexCCMarker, cp->unspendableCCaddr,true); // find by burnable validated cc addr marker for (std::vector >::const_iterator it = addressIndexCCMarker.begin(); it != addressIndexCCMarker.end(); it++) { addTokenId(it->first.txhash); } diff --git a/src/cc/CCtx.cpp b/src/cc/CCtx.cpp index 2713dd9ed..5e8a05895 100644 --- a/src/cc/CCtx.cpp +++ b/src/cc/CCtx.cpp @@ -306,7 +306,7 @@ std::string FinalizeCCTx(uint64_t CCmask,struct CCcontract_info *cp,CMutableTran else return("0"); } -void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr) +void SetCCunspents(std::vector > &unspentOutputs,char *coinaddr,bool ccflag) { int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector > addresses; n = (int32_t)strlen(coinaddr); @@ -325,7 +325,7 @@ void SetCCunspents(std::vector > &addressIndex,char *coinaddr) +void SetCCtxids(std::vector > &addressIndex,char *coinaddr,bool ccflag) { int32_t type=0,i,n; char *ptr; std::string addrstr; uint160 hashBytes; std::vector > addresses; n = (int32_t)strlen(coinaddr); @@ -344,10 +344,10 @@ void SetCCtxids(std::vector > &addressIndex } } -int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout) +int64_t CCutxovalue(char *coinaddr,uint256 utxotxid,int32_t utxovout,int32_t CCflag) { uint256 txid; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,CCflag!=0?true:false); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -403,10 +403,10 @@ int32_t CCgetspenttxid(uint256 &spenttxid,int32_t &vini,int32_t &height,uint256 return(0); } -int64_t CCaddress_balance(char *coinaddr) +int64_t CCaddress_balance(char *coinaddr,int32_t CCflag) { int64_t sum = 0; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,CCflag!=0?true:false); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { sum += it->second.satoshis; @@ -434,7 +434,7 @@ int64_t CCtoken_balance(char *coinaddr,uint256 reftokenid) std::vector > unspentOutputs; uint8_t evalCode; - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -613,7 +613,7 @@ int64_t AddNormalinputs2(CMutableTransaction &mtx,int64_t total,int32_t maxinput else threshold = total; sum = 0; Getscriptaddress(coinaddr,CScript() << Mypubkey() << OP_CHECKSIG); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,false); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/CCutils.cpp b/src/cc/CCutils.cpp index 9a68c2456..55c93d7b3 100644 --- a/src/cc/CCutils.cpp +++ b/src/cc/CCutils.cpp @@ -600,7 +600,7 @@ int32_t CCCointxidExists(char const *logcategory,uint256 cointxid) char txidaddr[64]; std::string coin; int32_t numvouts; uint256 hashBlock; std::vector > addressIndex; CCtxidaddr(txidaddr,cointxid); - SetCCtxids(addressIndex,txidaddr); + SetCCtxids(addressIndex,txidaddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { return(-1); diff --git a/src/cc/auction.cpp b/src/cc/auction.cpp index 0858facfa..7521256c7 100644 --- a/src/cc/auction.cpp +++ b/src/cc/auction.cpp @@ -124,7 +124,7 @@ int64_t AddAuctionInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/cclib.cpp b/src/cc/cclib.cpp index 8552cfa1b..ee52dadcf 100644 --- a/src/cc/cclib.cpp +++ b/src/cc/cclib.cpp @@ -482,7 +482,7 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C else if ( (hash[0] & 0xff) != 0 || (hash[31] & 0xff) != 0 ) return eval->Invalid("invalid faucetget txid"); Getscriptaddress(destaddr,tx.vout[i].scriptPubKey); - SetCCtxids(txids,destaddr); + SetCCtxids(txids,destaddr,tx.vout[i].scriptPubKey.IsPayToCryptoCondition()); for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) { //int height = it->first.blockHeight; @@ -501,12 +501,12 @@ bool CClib_validate(struct CCcontract_info *cp,int32_t height,Eval *eval,const C } } -int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,char *cmpaddr) +int64_t AddCClibInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey pk,int64_t total,int32_t maxinputs,char *cmpaddr,int32_t CCflag) { char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0,txfee = 10000; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,CCflag!=0?true:false); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs != 0 ) @@ -542,7 +542,7 @@ int64_t AddCClibtxfee(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe char coinaddr[64]; int64_t nValue,txfee = 10000; uint256 txid,hashBlock; CTransaction vintx; int32_t vout; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -596,7 +596,7 @@ std::string CClib_rawtxgen(struct CCcontract_info *cp,uint8_t funcid,cJSON *para return(""); cclibpk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); - if ( (inputs= AddCClibInputs(cp,mtx,cclibpk,nValue+txfee,60,cp->unspendableCCaddr)) > 0 ) + if ( (inputs= AddCClibInputs(cp,mtx,cclibpk,nValue+txfee,60,cp->unspendableCCaddr,1)) > 0 ) { if ( inputs > nValue ) CCchange = (inputs - nValue - txfee); diff --git a/src/cc/channels.cpp b/src/cc/channels.cpp index 2887c18e1..254f7e3a5 100644 --- a/src/cc/channels.cpp +++ b/src/cc/channels.cpp @@ -411,7 +411,7 @@ int64_t AddChannelsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx, C { if (tokenid!=zeroid) GetTokensCCaddress1of2(cp,coinaddr,srcpub,destpub); else GetCCaddress1of2(cp,coinaddr,srcpub,destpub); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); } else { @@ -797,7 +797,7 @@ UniValue ChannelsList() cp = CCinit(&C,EVAL_CHANNELS); mypk = pubkey2pk(Mypubkey()); GetCCaddress(cp,myCCaddr,mypk); - SetCCtxids(txids,myCCaddr); + SetCCtxids(txids,myCCaddr,true); result.push_back(Pair("result","success")); result.push_back(Pair("name","Channels List")); for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) @@ -848,7 +848,7 @@ UniValue ChannelsInfo(uint256 channeltxid) result.push_back(Pair("Denomination (satoshi)",i64tostr(param2))); result.push_back(Pair("Amount (satoshi)",i64tostr(param1*param2))); } - SetCCtxids(addressIndex,CCaddr); + SetCCtxids(addressIndex,CCaddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { if (GetTransaction(it->first.txhash,tx,hashBlock,false) != 0 && (numvouts= tx.vout.size()) > 0 ) diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index ca1ad7b53..76d68e090 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -264,7 +264,7 @@ int32_t dicefinish_utxosget(int32_t &total,struct dicefinish_utxo *utxos,int32_t int32_t n = 0; int64_t threshold = 2 * 10000; total = 0; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,false); { LOCK(mempool.cs); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) @@ -1051,7 +1051,7 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK char coinaddr[64],str[65]; uint64_t threshold,sbits,nValue,totalinputs = 0; uint256 txid,hash,proof,hashBlock,fundingtxid; CTransaction tx; int32_t j,vout,n = 0; uint8_t funcid; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) @@ -1108,7 +1108,7 @@ int64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbit fundingPubKey = tx.vout[1].scriptPubKey; } else return(0); GetCCaddress(cp,coinaddr,dicepk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); entropyval = 0; int loops = 0; int numtxs = unspentOutputs.size()/2; @@ -1225,7 +1225,7 @@ bool DicePlanExists(CScript &fundingPubKey,uint256 &fundingtxid,struct CCcontrac char CCaddr[64]; uint64_t sbits=0; uint256 txid,hashBlock; CTransaction tx; std::vector > txids; GetCCaddress(cp,CCaddr,dicepk); - SetCCtxids(txids,cp->normaladdr); + SetCCtxids(txids,cp->normaladdr,false); if ( fundingtxid != zeroid ) // avoid scan unless creating new funding plan { //fprintf(stderr,"check fundingtxid\n"); @@ -1321,7 +1321,7 @@ 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]; cp = CCinit(&C,EVAL_DICE); - SetCCtxids(addressIndex,cp->normaladdr); + SetCCtxids(addressIndex,cp->normaladdr,false); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; @@ -1774,7 +1774,7 @@ double DiceStatus(uint64_t txfee,char *planstr,uint256 fundingtxid,uint256 bettx return(0.); } std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/dilithium.c b/src/cc/dilithium.c index 5044edf94..5dfa1deda 100644 --- a/src/cc/dilithium.c +++ b/src/cc/dilithium.c @@ -3341,7 +3341,7 @@ int64_t dilithium_inputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPu char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 checktxid,txid,hashBlock; std::vector origpubkey,tmpsig; CTransaction vintx; int32_t vout,numvouts,n = 0; std::vector voutpubtxids; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) @@ -3538,7 +3538,7 @@ void dilithium_handleinit(struct CCcontract_info *cp) pthread_mutex_init(&DILITHIUM_MUTEX,NULL); dilithiumpk = GetUnspendable(cp,0); GetCCaddress(cp,CCaddr,dilithiumpk); - SetCCtxids(txids,CCaddr); + SetCCtxids(txids,CCaddr,true); for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/faucet.cpp b/src/cc/faucet.cpp index 81a2c2933..cf12fae69 100644 --- a/src/cc/faucet.cpp +++ b/src/cc/faucet.cpp @@ -118,7 +118,7 @@ bool FaucetValidate(struct CCcontract_info *cp,Eval* eval,const CTransaction &tx else if ( (hash[0] & 0xff) != 0 || (hash[31] & 0xff) != 0 ) return eval->Invalid("invalid faucetget txid"); Getscriptaddress(destaddr,tx.vout[i].scriptPubKey); - SetCCtxids(txids,destaddr); + SetCCtxids(txids,destaddr,tx.vout[i].scriptPubKey.IsPayToCryptoCondition()); for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) { //int height = it->first.blockHeight; @@ -145,7 +145,7 @@ int64_t AddFaucetInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPub char coinaddr[64]; int64_t threshold,nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) diff --git a/src/cc/fsm.cpp b/src/cc/fsm.cpp index 0bcc61a1b..e44f85e47 100644 --- a/src/cc/fsm.cpp +++ b/src/cc/fsm.cpp @@ -126,7 +126,7 @@ int64_t AddFSMInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKey char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/gamescc.cpp b/src/cc/gamescc.cpp index 17b0d371b..997013b0c 100644 --- a/src/cc/gamescc.cpp +++ b/src/cc/gamescc.cpp @@ -1130,7 +1130,7 @@ UniValue games_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) gamespk = GetUnspendable(cp,0); games_univalue(result,"newgame",maxplayers,buyin); required = (3*txfee + maxplayers*(GAMES_REGISTRATIONSIZE+txfee)); - if ( (inputsum= AddCClibInputs(cp,mtx,gamespk,required,16,cp->unspendableCCaddr)) >= required ) + if ( (inputsum= AddCClibInputs(cp,mtx,gamespk,required,16,cp->unspendableCCaddr,1)) >= required ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,gamespk)); for (i=0; i > unspentOutputs; gamespk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,gamespk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); nextheight = komodo_nextheight(); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -1583,7 +1583,7 @@ UniValue games_finish(uint64_t txfee,struct CCcontract_info *cp,cJSON *params,ch } if ( cashout > 0 ) { - if ( (inputsum= AddCClibInputs(cp,mtx,gamespk,cashout,60,cp->unspendableCCaddr)) > cashout ) + if ( (inputsum= AddCClibInputs(cp,mtx,gamespk,cashout,60,cp->unspendableCCaddr,1)) > cashout ) CCchange = (inputsum - cashout); else fprintf(stderr,"couldnt find enough utxos\n"); } @@ -1638,7 +1638,7 @@ UniValue games_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) gamespk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); GetTokensCCaddress(cp,coinaddr,mypk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); games_univalue(result,"players",-1,-1); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -1665,7 +1665,7 @@ UniValue games_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) gamespk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); GetCCaddress1of2(cp,coinaddr,gamespk,mypk); - SetCCtxids(addressIndex,coinaddr); + SetCCtxids(addressIndex,coinaddr,true); games_univalue(result,"games",-1,-1); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { diff --git a/src/cc/gateways.cpp b/src/cc/gateways.cpp index 1039e9176..e15735d70 100644 --- a/src/cc/gateways.cpp +++ b/src/cc/gateways.cpp @@ -484,7 +484,7 @@ int32_t GatewaysBindExists(struct CCcontract_info *cp,CPubKey gatewayspk,uint256 std::vector > addressIndex; _GetCCaddress(markeraddr,EVAL_GATEWAYS,gatewayspk); - SetCCtxids(addressIndex,markeraddr); + SetCCtxids(addressIndex,markeraddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { if ( myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeGatewaysOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' ) @@ -831,7 +831,7 @@ int64_t AddGatewaysInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP if ((numvouts=bindtx.vout.size())!=0 && DecodeGatewaysBindOpRet(depositaddr,bindtx.vout[numvouts-1].scriptPubKey,tokenid,refcoin,totalsupply,oracletxid,M,N,pubkeys,taddr,prefix,prefix2,wiftype) == 'B') { GetTokensCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) @@ -905,7 +905,7 @@ std::string GatewaysBind(uint64_t txfee,std::string coin,uint256 tokenid,int64_t for (i=0; i >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1500,7 +1500,7 @@ UniValue GatewaysPendingDeposits(uint256 bindtxid,std::string refcoin) result.push_back(Pair("error",strprintf("invalid bindtxid %s coin.%s",uint256_str(str,bindtxid),coin.c_str()))); return(result); } - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1563,7 +1563,7 @@ UniValue GatewaysPendingWithdraws(uint256 bindtxid,std::string refcoin) queueflag = 1; break; } - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1651,7 +1651,7 @@ UniValue GatewaysProcessedWithdraws(uint256 bindtxid,std::string refcoin) queueflag = 1; break; } - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1688,7 +1688,7 @@ UniValue GatewaysList() { UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock,oracletxid,tokenid; CTransaction vintx; std::string coin; int64_t totalsupply; char str[65],depositaddr[64]; uint8_t M,N,taddr,prefix,prefix2,wiftype; std::vector pubkeys; cp = CCinit(&C,EVAL_GATEWAYS); - SetCCtxids(addressIndex,cp->unspendableCCaddr); + SetCCtxids(addressIndex,cp->unspendableCCaddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/heir.cpp b/src/cc/heir.cpp index 9cb0f03bd..e047d1ab1 100644 --- a/src/cc/heir.cpp +++ b/src/cc/heir.cpp @@ -399,7 +399,7 @@ uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &toke //char markeraddr[64]; //CCtxidaddr(markeraddr, fundingtxid); - //SetCCunspents(unspentOutputs, markeraddr); + //SetCCunspents(unspentOutputs, markeraddr,true); hasHeirSpendingBegun = 0; funcId = 0; @@ -429,7 +429,7 @@ uint256 _FindLatestFundingTx(uint256 fundingtxid, uint8_t& funcId, uint256 &toke char coinaddr[64]; GetCCaddress1of2(cp, coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' - SetCCunspents(unspentOutputs, coinaddr); // get vector with tx's with unspent vouts of 1of2pubkey address: + SetCCunspents(unspentOutputs, coinaddr,true); // get vector with tx's with unspent vouts of 1of2pubkey address: //std::cerr << "FindLatestFundingTx() using 1of2address=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; int32_t maxBlockHeight = 0; // max block height @@ -514,11 +514,11 @@ template int64_t Add1of2AddressInputs(struct CCcontract_info* cp, char coinaddr[64]; Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); // get address of cryptocondition '1 of 2 pubkeys' - SetCCunspents(unspentOutputs, coinaddr); + SetCCunspents(unspentOutputs, coinaddr,true); // char markeraddr[64]; // CCtxidaddr(markeraddr, fundingtxid); - // SetCCunspents(unspentOutputs, markeraddr); + // SetCCunspents(unspentOutputs, markeraddr,true); std::cerr << "Add1of2AddressInputs() using 1of2addr=" << coinaddr << " unspentOutputs.size()=" << unspentOutputs.size() << std::endl; @@ -569,7 +569,7 @@ template int64_t LifetimeHeirContractFunds(struct CCcontract_info Helper::GetCoinsOrTokensCCaddress1of2(coinaddr, ownerPubkey, heirPubkey); // get the address of cryptocondition '1 of 2 pubkeys' std::vector> addressIndexes; - SetCCtxids(addressIndexes, coinaddr); + SetCCtxids(addressIndexes, coinaddr,true); //fprintf(stderr,"LifetimeHeirContractFunds() scan lifetime of %s\n",coinaddr); int64_t total = 0; @@ -1053,7 +1053,7 @@ UniValue HeirInfo(uint256 fundingtxid) //char markeraddr[64]; //CCtxidaddr(markeraddr, fundingtxid); - //SetCCunspents(unspentOutputs, markeraddr); + //SetCCunspents(unspentOutputs, markeraddr,true); // get initial funding tx and set it as initial lasttx: if (myGetTransaction(fundingtxid, fundingtx, hashBlock) && fundingtx.vout.size()) { @@ -1218,7 +1218,7 @@ void _HeirList(struct CCcontract_info *cp, UniValue &result) char markeraddr[64]; GetCCaddress(cp, markeraddr, GetUnspendable(cp, NULL)); - SetCCunspents(unspentOutputs, markeraddr); + SetCCunspents(unspentOutputs, markeraddr,true); //std::cerr << "HeirList() finding heir marker from unspendable addr=" << markeraddr << " unspentOutputs.size()=" << unspentOutputs.size() << '\n'; diff --git a/src/cc/import.cpp b/src/cc/import.cpp index 14f359398..b847e07d2 100644 --- a/src/cc/import.cpp +++ b/src/cc/import.cpp @@ -129,7 +129,7 @@ bool ImportCoinGatewaysVerify(CTransaction oracletx, int32_t claimvout, std::str // return(""); // } // CCtxidaddr(markeraddr,oracletxid); -// SetCCunspents(unspentOutputs,markeraddr); +// SetCCunspents(unspentOutputs,markeraddr,true); // for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) // { // txid = it->first.txhash; @@ -478,7 +478,7 @@ int32_t CheckGATEWAYimport(CTransaction importTx,CTransaction burnTx,std::string // return(-1); // } // CCtxidaddr(markeraddr,oracletxid); - // SetCCunspents(unspentOutputs,markeraddr); + // SetCCunspents(unspentOutputs,markeraddr,true); // for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) // { // txid = it->first.txhash; diff --git a/src/cc/importgateway.cpp b/src/cc/importgateway.cpp index 4e943b472..f7bd9b669 100644 --- a/src/cc/importgateway.cpp +++ b/src/cc/importgateway.cpp @@ -261,7 +261,7 @@ int32_t ImportGatewayBindExists(struct CCcontract_info *cp,CPubKey importgateway std::vector > addressIndex; _GetCCaddress(markeraddr,EVAL_IMPORTGATEWAY,importgatewaypk); - SetCCtxids(addressIndex,markeraddr); + SetCCtxids(addressIndex,markeraddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { if ( myGetTransaction(it->first.txhash,tx,hashBlock) != 0 && (numvouts= tx.vout.size()) > 0 && DecodeImportGatewayOpRet(tx.vout[numvouts-1].scriptPubKey)=='B' ) @@ -505,7 +505,7 @@ std::string ImportGatewayBind(uint64_t txfee,std::string coin,uint256 oracletxid for (i=0; i >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -992,7 +992,7 @@ UniValue ImportGatewayPendingDeposits(uint256 bindtxid,std::string refcoin) LOGSTREAM("importgateway",CCLOG_INFO, stream << CCerror << std::endl); return(""); } - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1054,7 +1054,7 @@ UniValue ImportGatewayPendingWithdraws(uint256 bindtxid,std::string refcoin) queueflag = 1; break; } - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1142,7 +1142,7 @@ UniValue ImportGatewayProcessedWithdraws(uint256 bindtxid,std::string refcoin) queueflag = 1; break; } - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1181,7 +1181,7 @@ UniValue ImportGatewayList() 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); + SetCCtxids(addressIndex,cp->unspendableCCaddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/lotto.cpp b/src/cc/lotto.cpp index e9c263ff1..f873b3881 100644 --- a/src/cc/lotto.cpp +++ b/src/cc/lotto.cpp @@ -166,7 +166,7 @@ int64_t AddLottoInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -209,7 +209,7 @@ int64_t LottoPlanFunds(uint64_t refsbits,struct CCcontract_info *cp,CPubKey pk,u std::vector > unspentOutputs; lockedfunds = 0; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -266,7 +266,7 @@ 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]; cp = CCinit(&C,EVAL_LOTTO); - SetCCtxids(addressIndex,cp->normaladdr); + SetCCtxids(addressIndex,cp->normaladdr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/marmara.cpp b/src/cc/marmara.cpp index 60afbc7fd..f0d55eaf4 100644 --- a/src/cc/marmara.cpp +++ b/src/cc/marmara.cpp @@ -352,7 +352,7 @@ int64_t AddMarmaraCoinbases(struct CCcontract_info *cp,CMutableTransaction &mtx, std::vector > unspentOutputs; Marmarapk = GetUnspendable(cp,0); GetCCaddress1of2(cp,coinaddr,Marmarapk,poolpk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); unlocks = MarmaraUnlockht(firstheight); //fprintf(stderr,"check coinaddr.(%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) @@ -387,7 +387,7 @@ int64_t AddMarmarainputs(CMutableTransaction &mtx,std::vector &pubkeys, { uint64_t threshold,nValue,totalinputs = 0; uint256 txid,hashBlock; CTransaction tx; int32_t numvouts,ht,unlockht,vout,i,n = 0; uint8_t funcid; CPubKey pk; std::vector vals; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) @@ -441,7 +441,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG); - if ( (val= CCaddress_balance(coinaddr)) < amount ) + if ( (val= CCaddress_balance(coinaddr,0)) < amount ) val -= txfee; else val = amount; if ( val > txfee ) @@ -457,7 +457,7 @@ UniValue MarmaraLock(uint64_t txfee,int64_t amount,int32_t height) remains = (amount + txfee) - inputsum; std::vector > unspentOutputs; GetCCaddress1of2(cp,coinaddr,Marmarapk,mypk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); threshold = remains / (MARMARA_VINS+1); uint8_t mypriv[32]; Myprivkey(mypriv); @@ -666,7 +666,7 @@ int32_t MarmaraGetCreditloops(int64_t &totalamount,std::vector &issuanc std::vector > unspentOutputs; Marmarapk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,Marmarapk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); // do all txid, conditional on spent/unspent //fprintf(stderr,"check coinaddr.(%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) @@ -1059,16 +1059,16 @@ UniValue MarmaraInfo(CPubKey refpk,int32_t firstheight,int32_t lastheight,int64_ result.push_back(Pair("result","success")); Getscriptaddress(coinaddr,CScript() << ParseHex(HexStr(Mypubkey())) << OP_CHECKSIG); result.push_back(Pair("myaddress",coinaddr)); - result.push_back(Pair("normal",ValueFromAmount(CCaddress_balance(coinaddr)))); + result.push_back(Pair("normal",ValueFromAmount(CCaddress_balance(coinaddr,0)))); GetCCaddress1of2(cp,coinaddr,Marmarapk,Mypubkey()); result.push_back(Pair("myCCactivated",coinaddr)); - result.push_back(Pair("activated",ValueFromAmount(CCaddress_balance(coinaddr)))); + result.push_back(Pair("activated",ValueFromAmount(CCaddress_balance(coinaddr,1)))); result.push_back(Pair("activated16",ValueFromAmount(AddMarmarainputs(mtx,pubkeys,coinaddr,0,MARMARA_VINS)))); GetCCaddress(cp,coinaddr,Mypubkey()); result.push_back(Pair("myCCaddress",coinaddr)); - result.push_back(Pair("CCutxos",ValueFromAmount(CCaddress_balance(coinaddr)))); + result.push_back(Pair("CCutxos",ValueFromAmount(CCaddress_balance(coinaddr,1)))); if ( refpk.size() == 33 ) result.push_back(Pair("issuer",HexStr(refpk))); diff --git a/src/cc/oracles.cpp b/src/cc/oracles.cpp index dc371ef16..1b13a00b7 100644 --- a/src/cc/oracles.cpp +++ b/src/cc/oracles.cpp @@ -197,7 +197,7 @@ int64_t OracleCurrentDatafee(uint256 reforacletxid,char *markeraddr,CPubKey publ { uint256 txid,oracletxid,hashBlock; int64_t datafee=0,dfee; int32_t dheight=0,vout,height,numvouts; CTransaction tx; CPubKey pk; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,markeraddr); + SetCCunspents(unspentOutputs,markeraddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -260,7 +260,7 @@ uint256 OracleBatonUtxo(uint64_t txfee,struct CCcontract_info *cp,uint256 refora { uint256 txid,oracletxid,hashBlock,btxid,batontxid = zeroid; int64_t dfee; int32_t dheight=0,vout,height,numvouts; CTransaction tx; CPubKey pk; uint8_t *ptr; std::vector vopret,data; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,batonaddr); + SetCCunspents(unspentOutputs,batonaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -306,7 +306,7 @@ uint256 OraclesBatontxid(uint256 reforacletxid,CPubKey refpk) batontxid = zeroid; cp = CCinit(&C,EVAL_ORACLES); CCtxidaddr(markeraddr,reforacletxid); - SetCCunspents(unspentOutputs,markeraddr); + SetCCunspents(unspentOutputs,markeraddr,true); //char str[67]; fprintf(stderr,"markeraddr.(%s) %s\n",markeraddr,pubkey33_str(str,(uint8_t *)&refpk)); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -525,14 +525,14 @@ int32_t oracleprice_add(std::vector &publishers,CPubKey } else return(0); } -int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char *format) +/*int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char *format) { std::vector > unspentOutputs; CTransaction regtx; uint256 hash,txid,oracletxid,batontxid; CPubKey pk; int32_t i,ht,maxheight=0; int64_t datafee,price; char batonaddr[64]; std::vector data; struct CCcontract_info *cp,C; std::vector publishers; std::vector prices; if ( format[0] != 'L' ) return(0); cp = CCinit(&C,EVAL_ORACLES); - SetCCunspents(unspentOutputs,markeraddr); + SetCCunspents(unspentOutputs,markeraddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -562,7 +562,7 @@ int64_t OraclePrice(int32_t height,uint256 reforacletxid,char *markeraddr,char * return(OracleCorrelatedPrice(height,prices)); } return(0); -} +}*/ int64_t IsOraclesvout(struct CCcontract_info *cp,const CTransaction& tx,int32_t v) { @@ -708,7 +708,7 @@ int64_t AddOracleInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,uint char coinaddr[64],funcid; int64_t nValue,price,totalinputs = 0; uint256 tmporacletxid,tmpbatontxid,txid,hashBlock; std::vector origpubkey,data; CTransaction vintx; int32_t numvouts,vout,n = 0; std::vector > unspentOutputs; CPubKey tmppk; int64_t tmpnum; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); //fprintf(stderr,"addoracleinputs from (%s)\n",coinaddr); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -746,7 +746,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 > addressIndex; GetCCaddress(cp,coinaddr,publisher); - SetCCtxids(addressIndex,coinaddr); + SetCCtxids(addressIndex,coinaddr,true); //fprintf(stderr,"scan lifetime of %s\n",coinaddr); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { @@ -992,7 +992,7 @@ UniValue OracleInfo(uint256 origtxid) result.push_back(Pair("description",description)); result.push_back(Pair("format",format)); result.push_back(Pair("marker",markeraddr)); - SetCCunspents(unspentOutputs,markeraddr); + SetCCunspents(unspentOutputs,markeraddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -1028,7 +1028,7 @@ UniValue OraclesList() { UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; uint256 txid,hashBlock; CTransaction createtx; std::string name,description,format; char str[65]; cp = CCinit(&C,EVAL_ORACLES); - SetCCtxids(addressIndex,cp->normaladdr); + SetCCtxids(addressIndex,cp->normaladdr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/payments.cpp b/src/cc/payments.cpp index ae83e2661..d83cd0bec 100644 --- a/src/cc/payments.cpp +++ b/src/cc/payments.cpp @@ -317,7 +317,7 @@ int64_t AddPaymentsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CP if ( iter == 0 ) GetCCaddress(cp,coinaddr,Paymentspk); else GetCCaddress1of2(cp,coinaddr,Paymentspk,txidpk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -864,10 +864,10 @@ UniValue PaymentsInfo(struct CCcontract_info *cp,char *jsonstr) result.push_back(Pair("txidoprets",a)); txidpk = CCtxidaddr(txidaddr,createtxid); GetCCaddress1of2(cp,fundsaddr,Paymentspk,txidpk); - funds = CCaddress_balance(fundsaddr); + funds = CCaddress_balance(fundsaddr,1); result.push_back(Pair(fundsaddr,ValueFromAmount(funds))); GetCCaddress(cp,fundsopretaddr,Paymentspk); - fundsopret = CCaddress_balance(fundsopretaddr); + fundsopret = CCaddress_balance(fundsopretaddr,1); result.push_back(Pair(fundsopretaddr,ValueFromAmount(fundsopret))); result.push_back(Pair("totalfunds",ValueFromAmount(funds+fundsopret))); result.push_back(Pair("result","success")); @@ -896,7 +896,7 @@ UniValue PaymentsList(struct CCcontract_info *cp,char *jsonstr) UniValue result(UniValue::VOBJ),a(UniValue::VARR); char markeraddr[64],str[65]; CPubKey Paymentspk; CTransaction tx; int32_t lockedblocks,minrelease; std::vector txidoprets; int64_t totalallocations; Paymentspk = GetUnspendable(cp,0); GetCCaddress1of2(cp,markeraddr,Paymentspk,Paymentspk); - SetCCtxids(addressIndex,markeraddr); + SetCCtxids(addressIndex,markeraddr,true); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/pegs.cpp b/src/cc/pegs.cpp index 38933ebdc..21cee8ca1 100644 --- a/src/cc/pegs.cpp +++ b/src/cc/pegs.cpp @@ -181,7 +181,7 @@ int64_t AddPegsInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubKe char coinaddr[64]; int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/prices.cpp b/src/cc/prices.cpp index 19194d16f..5d164d97e 100644 --- a/src/cc/prices.cpp +++ b/src/cc/prices.cpp @@ -230,7 +230,7 @@ int64_t AddPricesInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,char { int64_t nValue,price,totalinputs = 0; uint256 txid,hashBlock; std::vector origpubkey; CTransaction vintx; int32_t vout,n = 0; std::vector > unspentOutputs; - SetCCunspents(unspentOutputs,destaddr); + SetCCunspents(unspentOutputs,destaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -711,7 +711,7 @@ UniValue PricesList() UniValue result(UniValue::VARR); std::vector > addressIndex; struct CCcontract_info *cp,C; int64_t amount,firstprice; int32_t height; int16_t leverage; uint256 txid,hashBlock,tokenid; CPubKey pk,pricespk; std::vector vec; CTransaction vintx; char str[65]; cp = CCinit(&C,EVAL_PRICES); pricespk = GetUnspendable(cp,0); - SetCCtxids(addressIndex,cp->normaladdr); + SetCCtxids(addressIndex,cp->normaladdr,false); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; diff --git a/src/cc/rewards.cpp b/src/cc/rewards.cpp index bc9464fb8..5ca2b038a 100644 --- a/src/cc/rewards.cpp +++ b/src/cc/rewards.cpp @@ -338,7 +338,7 @@ int64_t AddRewardsInputs(CScript &scriptPubKey,uint64_t maxseconds,struct CCcont char coinaddr[64],str[65]; uint64_t threshold,sbits,nValue,totalinputs = 0; uint256 txid,hashBlock,fundingtxid; CTransaction tx; int32_t numblocks,j,vout,n = 0; uint8_t funcid; std::vector > unspentOutputs; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); if ( maxinputs > CC_MAXVINS ) maxinputs = CC_MAXVINS; if ( maxinputs > 0 ) @@ -403,7 +403,7 @@ int64_t RewardsPlanFunds(uint64_t &lockedfunds,uint64_t refsbits,struct CCcontra std::vector > unspentOutputs; lockedfunds = 0; GetCCaddress(cp,coinaddr,pk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -433,7 +433,7 @@ bool RewardsPlanExists(struct CCcontract_info *cp,uint64_t refsbits,CPubKey rewa char CCaddr[64]; uint64_t sbits; uint256 txid,hashBlock; CTransaction tx; std::vector > txids; GetCCaddress(cp,CCaddr,rewardspk); - SetCCtxids(txids,CCaddr); + SetCCtxids(txids,CCaddr,true); for (std::vector >::const_iterator it=txids.begin(); it!=txids.end(); it++) { //int height = it->first.blockHeight; @@ -493,7 +493,7 @@ 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]; cp = CCinit(&C,EVAL_REWARDS); - SetCCtxids(addressIndex,cp->normaladdr); + SetCCtxids(addressIndex,cp->normaladdr,false); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) { txid = it->first.txhash; @@ -650,7 +650,7 @@ std::string RewardsUnlock(uint64_t txfee,char *planstr,uint256 fundingtxid,uint2 else { GetCCaddress(cp,coinaddr,rewardspk); - if ( (amount= CCutxovalue(coinaddr,locktxid,0)) == 0 ) + if ( (amount= CCutxovalue(coinaddr,locktxid,0,1)) == 0 ) { fprintf(stderr,"%s locktxid/v0 is spent\n",coinaddr); CCerror = "locktxid/v0 is spent"; diff --git a/src/cc/rogue_rpc.cpp b/src/cc/rogue_rpc.cpp index c5350a68d..b0ed60ab2 100644 --- a/src/cc/rogue_rpc.cpp +++ b/src/cc/rogue_rpc.cpp @@ -806,7 +806,7 @@ UniValue rogue_newgame(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) roguepk = GetUnspendable(cp,0); rogue_univalue(result,"newgame",maxplayers,buyin); required = (3*txfee + maxplayers*(ROGUE_REGISTRATIONSIZE+txfee)); - if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,required,16,cp->unspendableCCaddr)) >= required ) + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,required,16,cp->unspendableCCaddr,1)) >= required ) { mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,roguepk)); // for highlander TCBOO creation for (i=0; i 0 ) { - if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,60,cp->unspendableCCaddr)) > cashout ) + if ( (inputsum= AddCClibInputs(cp,mtx,roguepk,cashout,60,cp->unspendableCCaddr,1)) > cashout ) CCchange = (inputsum - cashout); else fprintf(stderr,"couldnt find enough utxos\n"); } @@ -1397,7 +1397,7 @@ UniValue rogue_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) std::vector > unspentOutputs; roguepk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,roguepk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); nextheight = komodo_nextheight(); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -1427,7 +1427,7 @@ UniValue rogue_players(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) roguepk = GetUnspendable(cp,0); mypk = pubkey2pk(Mypubkey()); GetTokensCCaddress(cp,coinaddr,mypk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); rogue_univalue(result,"players",-1,-1); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { @@ -1456,7 +1456,7 @@ UniValue rogue_games(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) mypk = pubkey2pk(Mypubkey()); GetCCaddress1of2(cp,coinaddr,roguepk,mypk); //SetCCunspents(unspentOutputs,coinaddr); - SetCCtxids(addressIndex,coinaddr); + SetCCtxids(addressIndex,coinaddr,true); rogue_univalue(result,"games",-1,-1); for (std::vector >::const_iterator it=addressIndex.begin(); it!=addressIndex.end(); it++) //for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) diff --git a/src/cc/sudoku.cpp b/src/cc/sudoku.cpp index a9efdd950..61ea6c545 100644 --- a/src/cc/sudoku.cpp +++ b/src/cc/sudoku.cpp @@ -2679,7 +2679,7 @@ UniValue sudoku_generate(uint64_t txfee,struct CCcontract_info *cp,cJSON *params sudokupk = GetUnspendable(cp,0); result.push_back(Pair("srand",(int)srandi)); result.push_back(Pair("amount",ValueFromAmount(amount))); - if ( (inputsum= AddCClibInputs(cp,mtx,sudokupk,amount+2*txfee,16,cp->unspendableCCaddr)) >= amount+2*txfee ) + if ( (inputsum= AddCClibInputs(cp,mtx,sudokupk,amount+2*txfee,16,cp->unspendableCCaddr,1)) >= amount+2*txfee ) { //printf("inputsum %.8f\n",(double)inputsum/COIN); mtx.vout.push_back(MakeCC1vout(cp->evalcode,txfee,sudokupk)); @@ -2772,7 +2772,7 @@ UniValue sudoku_pending(uint64_t txfee,struct CCcontract_info *cp,cJSON *params) std::vector > unspentOutputs; sudokupk = GetUnspendable(cp,0); GetCCaddress(cp,coinaddr,sudokupk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; @@ -2844,7 +2844,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params pk = buf2pk(pub33); GetCCaddress(cp,CCaddr,pk); result.push_back(Pair("sudokuaddr",CCaddr)); - balance = CCaddress_balance(CCaddr); + balance = CCaddress_balance(CCaddr,1); result.push_back(Pair("amount",ValueFromAmount(balance))); if ( sudoku_captcha(1,timestamps,komodo_nextheight()) < 0 ) { @@ -2892,7 +2892,7 @@ UniValue sudoku_solution(uint64_t txfee,struct CCcontract_info *cp,cJSON *params if ( good != 0 ) { mtx.vin.push_back(CTxIn(txid,0,CScript())); - if ( (inputsum= AddCClibInputs(cp,mtx,pk,balance,16,CCaddr)) >= balance ) + if ( (inputsum= AddCClibInputs(cp,mtx,pk,balance,16,CCaddr,1)) >= balance ) { mtx.vout.push_back(CTxOut(balance,CScript() << ParseHex(HexStr(mypk)) << OP_CHECKSIG)); CCaddr2set(cp,cp->evalcode,pk,priv32,CCaddr); diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index aa21896aa..0ae61356f 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -2472,7 +2472,7 @@ int32_t komodo_staked(CMutableTransaction &txNew,uint32_t nBits,uint32_t *blockt mypk = pubkey2pk(Mypubkey()); Marmarapk = GetUnspendable(cp,0); GetCCaddress1of2(cp,coinaddr,Marmarapk,mypk); - SetCCunspents(unspentOutputs,coinaddr); + SetCCunspents(unspentOutputs,coinaddr,true); for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { txid = it->first.txhash; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6bd03ccfb..7661296b9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1555,6 +1555,7 @@ extern std::vector Mineropret; // opreturn data set by the data gatheri #define KOMODO_LOCALPRICE_CACHESIZE 13 #define KOMODO_MAXPRICES 2048 #define PRICES_SMOOTHWIDTH 1 +#define PRICES_MAXDATAPOINTS 3 #define issue_curl(cmdstr) bitcoind_RPC(0,(char *)"CBCOINBASE",cmdstr,0,0,0) @@ -1747,6 +1748,7 @@ CScript komodo_mineropret(int32_t nHeight) void komodo_queuelocalprice(int32_t dir,int32_t height,uint32_t timestamp,uint256 blockhash,int32_t ind,uint32_t pricebits) { + fprintf(stderr,"ExtremePrice dir.%d ht.%d ind.%d cmpbits.%u\n",dir,height,ind,pricebits); ExtremePrice.dir = dir; ExtremePrice.height = height; ExtremePrice.blockhash = blockhash; @@ -2226,6 +2228,7 @@ void komodo_cbopretupdate(int32_t forceflag) memcpy(Mineropret.data(),PriceCache[0],size); if ( ExtremePrice.dir != 0 && ExtremePrice.ind > 0 && ExtremePrice.ind < size/sizeof(uint32_t) && now < ExtremePrice.timestamp+3600 ) { + fprintf(stderr,"cmp dir.%d PriceCache[0][ExtremePrice.ind] %u >= %u ExtremePrice.pricebits\n",ExtremePrice.dir,PriceCache[0][ExtremePrice.ind],ExtremePrice.pricebits); if ( (ExtremePrice.dir > 0 && PriceCache[0][ExtremePrice.ind] >= ExtremePrice.pricebits) || (ExtremePrice.dir < 0 && PriceCache[0][ExtremePrice.ind] <= ExtremePrice.pricebits) ) { fprintf(stderr,"future price is close enough to allow approving previously rejected block ind.%d %u vs %u\n",ExtremePrice.ind,PriceCache[0][ExtremePrice.ind],ExtremePrice.pricebits); @@ -2609,7 +2612,7 @@ void komodo_pricesinit() PRICES[i].fp = fopen(pricefname.string().c_str(), createflag != 0 ? "wb+" : "rb+"); if ( createflag != 0 ) { - fseek(PRICES[i].fp,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(int64_t) * 3,SEEK_SET); + fseek(PRICES[i].fp,(2*PRICES_DAYWINDOW+PRICES_SMOOTHWIDTH) * sizeof(int64_t) * PRICES_MAXDATAPOINTS,SEEK_SET); fputc(0,PRICES[i].fp); fflush(PRICES[i].fp); } @@ -2631,7 +2634,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) { numprices = (int32_t)(komodo_cbopretsize(ASSETCHAINS_CBOPRET) / sizeof(uint32_t)); ptr32 = (uint32_t *)calloc(sizeof(uint32_t),numprices * width); - ptr64 = (int64_t *)calloc(sizeof(int64_t),PRICES_DAYWINDOW*3); + ptr64 = (int64_t *)calloc(sizeof(int64_t),PRICES_DAYWINDOW*PRICES_MAXDATAPOINTS); tmpbuf = (int64_t *)calloc(sizeof(int64_t),2*PRICES_DAYWINDOW); fprintf(stderr,"prices update: numprices.%d %p %p\n",numprices,ptr32,ptr64); } @@ -2658,7 +2661,7 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) rngval = (rngval*11109 + 13849); if ( (correlated= komodo_pricecorrelated(rngval,ind,&ptr32[offset],-numprices,0,PRICES_SMOOTHWIDTH)) > 0 ) { - fseek(PRICES[ind].fp,height * sizeof(int64_t) * 3,SEEK_SET); + fseek(PRICES[ind].fp,height * sizeof(int64_t) * PRICES_MAXDATAPOINTS,SEEK_SET); buf[0] = rawprices[ind]; buf[1] = rawprices[0]; // timestamp memcpy(&buf[2],&correlated,sizeof(correlated)); @@ -2666,20 +2669,15 @@ void komodo_pricesupdate(int32_t height,CBlock *pblock) fprintf(stderr,"error fwrite buf for ht.%d ind.%d\n",height,ind); else if ( height > PRICES_DAYWINDOW*2 ) { - fseek(PRICES[ind].fp,(height-PRICES_DAYWINDOW+1) * 3 * sizeof(int64_t),SEEK_SET); - if ( fread(ptr64,sizeof(int64_t),PRICES_DAYWINDOW*3-1,PRICES[ind].fp) == PRICES_DAYWINDOW*3-1 ) + fseek(PRICES[ind].fp,(height-PRICES_DAYWINDOW+1) * PRICES_MAXDATAPOINTS * sizeof(int64_t),SEEK_SET); + if ( fread(ptr64,sizeof(int64_t),(PRICES_DAYWINDOW-1)*PRICES_MAXDATAPOINTS+2,PRICES[ind].fp) == (PRICES_DAYWINDOW-1)*PRICES_MAXDATAPOINTS+2 ) { - if ( (smoothed= komodo_priceave(tmpbuf,&ptr64[PRICES_DAYWINDOW*3-2],-3)) > 0 ) + if ( (smoothed= komodo_priceave(tmpbuf,&ptr64[(PRICES_DAYWINDOW-1)*PRICES_MAXDATAPOINTS+1],-PRICES_MAXDATAPOINTS)) > 0 ) { - fseek(PRICES[ind].fp,(height * 3 + 2) * sizeof(int64_t),SEEK_SET); + fseek(PRICES[ind].fp,(height * PRICES_MAXDATAPOINTS + 2) * sizeof(int64_t),SEEK_SET); if ( fwrite(&smoothed,1,sizeof(smoothed),PRICES[ind].fp) != sizeof(smoothed) ) fprintf(stderr,"error fwrite smoothed for ht.%d ind.%d\n",height,ind); - else - { - if ( ind == 36 ) - fprintf(stderr,"(%.8f %.8f) ",(double)ptr64[PRICES_DAYWINDOW*3-2]/COIN,(double)smoothed/COIN); - fflush(PRICES[ind].fp); - } + else fflush(PRICES[ind].fp); } else fprintf(stderr,"error price_smoothed ht.%d ind.%d\n",height,ind); } else fprintf(stderr,"error fread ptr64 for ht.%d ind.%d\n",height,ind); } diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 043d7282e..1900df432 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1811,6 +1811,7 @@ void komodo_args(char *argv0) ASSETCHAINS_CODAPORT = GetArg("-ac_coda",0); ASSETCHAINS_MARMARA = GetArg("-ac_marmara",0); ASSETCHAINS_CBOPRET = GetArg("-ac_cbopret",0); + //fprintf(stderr,"ASSETCHAINS_CBOPRET.%llx\n",(long long)ASSETCHAINS_CBOPRET); if ( ASSETCHAINS_CBOPRET != 0 ) { SplitStr(GetArg("-ac_prices",""), ASSETCHAINS_PRICES); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 8ee2896ba..a21de63f4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5369,11 +5369,11 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vectorunspendableCCaddr)); sprintf(str,"%sCCBalance",name); - result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->unspendableCCaddr)))); + result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->unspendableCCaddr,1)))); sprintf(str,"%sNormalAddress",name); result.push_back(Pair(str,cp->normaladdr)); sprintf(str,"%sNormalBalance",name); - result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->normaladdr)))); + result.push_back(Pair(str,ValueFromAmount(CCaddress_balance(cp->normaladdr,0)))); if (strcmp(name,"Gateways")==0) result.push_back(Pair("GatewaysPubkey","03ea9c062b9652d8eff34879b504eda0717895d27597aaeb60347d65eed96ccb40")); if ((strcmp(name,"Channels")==0 || strcmp(name,"Heir")==0) && pubkey.size() == 33) { @@ -5402,7 +5402,7 @@ UniValue CCaddress(struct CCcontract_info *cp,char *name,std::vector