From 4c8293dc76f0ab5a4da09545928ee0536113a0b1 Mon Sep 17 00:00:00 2001 From: miketout Date: Thu, 25 Oct 2018 23:25:31 -0700 Subject: [PATCH] Fixed issue #145, should fix stake synching with wallets --- src/cc/CCinclude.h | 2 +- src/main.cpp | 42 ++++++++++++++++++++++++++-------------- src/rpc/server.cpp | 2 +- src/wallet/rpcwallet.cpp | 5 +++-- 4 files changed, 32 insertions(+), 19 deletions(-) diff --git a/src/cc/CCinclude.h b/src/cc/CCinclude.h index fa4ea7960..a1e433fdd 100644 --- a/src/cc/CCinclude.h +++ b/src/cc/CCinclude.h @@ -101,7 +101,7 @@ bool GetAddressUnspent(uint160 addressHash, int type,std::vectorGetHeight()+1,chainActive.LastTip()->GetMedianTimePast() + 777,0) < 0 ) { @@ -1579,6 +1571,14 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return state.DoS(0, false, REJECT_NONSTANDARD, "non-final"); } + // if this is a valid stake transaction, don't put it in the mempool + CStakeParams p; + if (ValidateStakeTransaction(tx, p, false)) + { + return state.DoS(0, error("AcceptToMemoryPool: attempt to add staking transaction to the mempool"), + REJECT_INVALID, "staking"); + } + // is it already in the memory pool? uint256 hash = tx.GetHash(); if (pool.exists(hash)) @@ -1891,9 +1891,12 @@ bool GetAddressUnspent(uint160 addressHash, int type, else return(coins.vout[n].nValue); }*/ -bool myAddtomempool(CTransaction &tx) +bool myAddtomempool(CTransaction &tx, CValidationState *pstate) { - CValidationState state; CTransaction Ltx; bool fMissingInputs,fOverrideFees = false; + CValidationState state; + if (!pstate) + pstate = &state; + CTransaction Ltx; bool fMissingInputs,fOverrideFees = false; if ( mempool.lookup(tx.GetHash(),Ltx) == 0 ) return(AcceptToMemoryPool(mempool, state, tx, false, &fMissingInputs, !fOverrideFees)); else return(true); @@ -4541,18 +4544,27 @@ bool CheckBlock(int32_t *futureblockp,int32_t height,CBlockIndex *pindex,const C // Check transactions if ( ASSETCHAINS_CC != 0 ) // CC contracts might refer to transactions in the current block, from a CC spend within the same block and out of order { - CValidationState stateDummy; int32_t i,j,rejects=0,lastrejects=0; + int32_t i,j,rejects=0,lastrejects=0; //fprintf(stderr,"put block's tx into mempool\n"); while ( 1 ) { for (i=0; i 0) + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + if (params.size() > 0) throw runtime_error("getbalance64\n"); total = total2 = 0; memset(nValues,0,sizeof(nValues));