myIsutxo_spentinmempool
This commit is contained in:
@@ -53,7 +53,8 @@ static const uint256 zeroid;
|
||||
bool myGetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock);
|
||||
int32_t is_hexstr(char *str,int32_t n);
|
||||
bool myAddtomempool(CTransaction &tx);
|
||||
uint64_t myGettxout(uint256 hash,int32_t n);
|
||||
//uint64_t myGettxout(uint256 hash,int32_t n);
|
||||
bool myIsutxo_spentinmempool(uint256 txid,int32_t vout);
|
||||
|
||||
// CCcustom
|
||||
CPubKey GetUnspendable(struct CCcontract_info *cp,uint8_t *unspendablepriv);
|
||||
|
||||
@@ -220,7 +220,7 @@ uint64_t AddNormalinputs(CMutableTransaction &mtx,CPubKey mypk,uint64_t total,in
|
||||
break;
|
||||
if ( j != mtx.vin.size() )
|
||||
continue;
|
||||
if ( myGettxout(txid,vout) == out.tx->vout[out.i].nValue )
|
||||
if ( myIsutxo_spentinmempool(txid,vout) == 0 )
|
||||
{
|
||||
mtx.vin.push_back(CTxIn(txid,vout,CScript()));
|
||||
nValue = out.tx->vout[out.i].nValue;
|
||||
|
||||
@@ -119,13 +119,6 @@ void *dicefinish(void *_ptr)
|
||||
if ( duplicate == 0 )
|
||||
{
|
||||
CTransaction tx,bettx; uint256 txid,hashBlock; char str[65]; int32_t result;
|
||||
for (i=0; i<10; i++)
|
||||
{
|
||||
if ( myGettxout(ptr->bettxid,0) != 0 ) // need to wait for mempool to be updated
|
||||
break;
|
||||
fprintf(stderr,".");
|
||||
sleep(3);
|
||||
}
|
||||
res = DiceWinLoseTimeout(&result,0,name,ptr->fundingtxid,ptr->bettxid,ptr->iswin);
|
||||
if ( result != 0 && res.empty() == 0 && res.size() > 64 && is_hexstr((char *)res.c_str(),0) > 64 )
|
||||
{
|
||||
@@ -582,7 +575,7 @@ uint64_t AddDiceInputs(struct CCcontract_info *cp,CMutableTransaction &mtx,CPubK
|
||||
break;
|
||||
if ( j != mtx.vin.size() )
|
||||
continue;
|
||||
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myGettxout(txid,vout) != 0 )
|
||||
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout.size() > 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 )
|
||||
{
|
||||
if ( (funcid= DecodeDiceOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid,hash,proof)) != 0 )
|
||||
{
|
||||
@@ -616,7 +609,7 @@ uint64_t DicePlanFunds(uint64_t &entropyval,uint256 &entropytxid,uint64_t refsbi
|
||||
{
|
||||
txid = it->first.txhash;
|
||||
vout = (int32_t)it->first.index;
|
||||
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myGettxout(txid,vout) > 0 )
|
||||
if ( GetTransaction(txid,tx,hashBlock,false) != 0 && tx.vout[vout].scriptPubKey.IsPayToCryptoCondition() != 0 && myIsutxo_spentinmempool(txid,vout) == 0 )
|
||||
{
|
||||
//char str[65],str2[65];
|
||||
if ( (funcid= DecodeDiceOpRet(txid,tx.vout[tx.vout.size()-1].scriptPubKey,sbits,fundingtxid,hash,proof)) != 0 )
|
||||
@@ -871,7 +864,7 @@ std::string DiceBet(uint64_t txfee,char *planstr,uint256 fundingtxid,int64_t bet
|
||||
}
|
||||
if ( (funding= DicePlanFunds(entropyval,entropytxid,sbits,cp,dicepk,fundingtxid)) >= 2*bet*odds+txfee && entropyval != 0 )
|
||||
{
|
||||
if ( myGettxout(entropytxid,0) == 0 )
|
||||
if ( myIsutxo_spentinmempool(entropytxid,0) != 0 )
|
||||
{
|
||||
fprintf(stderr,"entropy txid is spent\n");
|
||||
return(0);
|
||||
@@ -923,7 +916,7 @@ std::string DiceWinLoseTimeout(int32_t *resultp,uint64_t txfee,char *planstr,uin
|
||||
{
|
||||
if ( iswin == winlosetimeout )
|
||||
{
|
||||
if ( myGettxout(bettxid,0) == 0 || myGettxout(bettxid,1) == 0 )
|
||||
if ( myIsutxo_spentinmempool(bettxid,0) != 0 || myIsutxo_spentinmempool(bettxid,1) != 0 )
|
||||
{
|
||||
fprintf(stderr,"bettxid already spent\n");
|
||||
return(0);
|
||||
|
||||
@@ -1603,7 +1603,7 @@ bool GetAddressUnspent(uint160 addressHash, int type,
|
||||
return true;
|
||||
}
|
||||
|
||||
uint64_t myGettxout(uint256 hash,int32_t n)
|
||||
/*uint64_t myGettxout(uint256 hash,int32_t n)
|
||||
{
|
||||
CCoins coins;
|
||||
LOCK2(cs_main,mempool.cs);
|
||||
@@ -1613,7 +1613,7 @@ uint64_t myGettxout(uint256 hash,int32_t n)
|
||||
if ( n < 0 || (unsigned int)n >= coins.vout.size() || coins.vout[n].IsNull() )
|
||||
return(0);
|
||||
else return(coins.vout[n].nValue);
|
||||
}
|
||||
}*/
|
||||
|
||||
bool myAddtomempool(CTransaction &tx)
|
||||
{
|
||||
|
||||
@@ -346,6 +346,26 @@ UniValue getdifficulty(const UniValue& params, bool fHelp)
|
||||
return GetNetworkDifficulty();
|
||||
}
|
||||
|
||||
bool myIsutxo_spentinmempool(uint256 txid,int32_t vout)
|
||||
{
|
||||
char *uint256_str(char *str,uint256);
|
||||
char str[65];
|
||||
LOCK(mempool.cs);
|
||||
BOOST_FOREACH(const CTxMemPoolEntry &e,mempool.mapTx)
|
||||
{
|
||||
const CTransaction &tx = e.GetTx();
|
||||
const uint256 &hash = tx.GetHash();
|
||||
BOOST_FOREACH(const CTxIn &txin,tx.vin)
|
||||
{
|
||||
fprintf(stderr,"%s/v%d ",uint256_str(str,txin.prevout.hash),txin.prevout.n);
|
||||
if ( txin.prevout.n == vout && txin.prevout.hash == txid )
|
||||
return(true);
|
||||
}
|
||||
fprintf(stderr,"are vins for %s\n",uint256_str(str,hash));
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
UniValue mempoolToJSON(bool fVerbose = false)
|
||||
{
|
||||
if (fVerbose)
|
||||
|
||||
Reference in New Issue
Block a user