diff --git a/src/cc/dice.cpp b/src/cc/dice.cpp index a434a40ea..fedb8a25c 100644 --- a/src/cc/dice.cpp +++ b/src/cc/dice.cpp @@ -241,21 +241,24 @@ int32_t dicefinish_utxosget(int32_t &total,struct dicefinish_utxo *utxos,int32_t total = 0; std::vector > unspentOutputs; SetCCunspents(unspentOutputs,coinaddr); - for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { - if ( myIsutxo_spentinmempool(it->first.txhash,(int32_t)it->first.index) == 0 ) + LOCK(mempool.cs); + for (std::vector >::const_iterator it=unspentOutputs.begin(); it!=unspentOutputs.end(); it++) { - if ( it->second.satoshis < threshold || it->second.satoshis > 10*threshold ) - continue; - total++; - if ( n < max ) + if ( myIsutxo_spentinmempool(it->first.txhash,(int32_t)it->first.index) == 0 ) { - if ( utxos != 0 ) + if ( it->second.satoshis < threshold || it->second.satoshis > 10*threshold ) + continue; + total++; + if ( n < max ) { - utxos[n].txid = it->first.txhash; - utxos[n].vout = (int32_t)it->first.index; + if ( utxos != 0 ) + { + utxos[n].txid = it->first.txhash; + utxos[n].vout = (int32_t)it->first.index; + } + n++; } - n++; } } } @@ -284,6 +287,7 @@ int32_t dice_betspent(char *debugstr,uint256 bettxid) } else*/ { + LOCK(mempool.cs); if ( myIsutxo_spentinmempool(bettxid,0) != 0 || myIsutxo_spentinmempool(bettxid,1) != 0 ) { fprintf(stderr,"%s bettxid.%s already spent in mempool\n",debugstr,bettxid.GetHex().c_str()); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 4b5ef8a1f..4aaaef33c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -6188,6 +6188,7 @@ UniValue dicefinish(const UniValue& params, bool fHelp) if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; + LOCK(mempool.cs); LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); if (!VALID_PLAN_NAME(name)) { @@ -6223,6 +6224,7 @@ UniValue dicestatus(const UniValue& params, bool fHelp) if ( ensure_CCrequirements() < 0 ) throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n"); const CKeyStore& keystore = *pwalletMain; + LOCK(mempool.cs); LOCK2(cs_main, pwalletMain->cs_wallet); name = (char *)params[0].get_str().c_str(); if (!VALID_PLAN_NAME(name)) {