@ -484,7 +484,6 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
CCoinsView dummy ;
CCoinsView dummy ;
CCoinsViewCache view ( & dummy ) ;
CCoinsViewCache view ( & dummy ) ;
CAmount nValueIn = 0 ;
LockPoints lp ;
LockPoints lp ;
{
{
LOCK ( pool . cs ) ;
LOCK ( pool . cs ) ;
@ -519,8 +518,6 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
// Bring the best block into scope
// Bring the best block into scope
view . GetBestBlock ( ) ;
view . GetBestBlock ( ) ;
nValueIn = view . GetValueIn ( tx ) ;
// we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool
// we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool
view . SetBackend ( dummy ) ;
view . SetBackend ( dummy ) ;
@ -531,6 +528,12 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
// CoinsViewCache instead of create its own
// CoinsViewCache instead of create its own
if ( ! CheckSequenceLocks ( tx , STANDARD_LOCKTIME_VERIFY_FLAGS , & lp ) )
if ( ! CheckSequenceLocks ( tx , STANDARD_LOCKTIME_VERIFY_FLAGS , & lp ) )
return state . DoS ( 0 , false , REJECT_NONSTANDARD , " non-BIP68-final " ) ;
return state . DoS ( 0 , false , REJECT_NONSTANDARD , " non-BIP68-final " ) ;
} // end LOCK(pool.cs)
CAmount nFees = 0 ;
if ( ! Consensus : : CheckTxInputs ( tx , state , view , GetSpendHeight ( view ) , nFees ) ) {
return error ( " %s: Consensus::CheckTxInputs: %s, %s " , __func__ , tx . GetHash ( ) . ToString ( ) , FormatStateMessage ( state ) ) ;
}
}
// Check for non-standard pay-to-script-hash in inputs
// Check for non-standard pay-to-script-hash in inputs
@ -543,8 +546,6 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
int64_t nSigOpsCost = GetTransactionSigOpCost ( tx , view , STANDARD_SCRIPT_VERIFY_FLAGS ) ;
int64_t nSigOpsCost = GetTransactionSigOpCost ( tx , view , STANDARD_SCRIPT_VERIFY_FLAGS ) ;
CAmount nValueOut = tx . GetValueOut ( ) ;
CAmount nFees = nValueIn - nValueOut ;
// nModifiedFees includes any fee deltas from PrioritiseTransaction
// nModifiedFees includes any fee deltas from PrioritiseTransaction
CAmount nModifiedFees = nFees ;
CAmount nModifiedFees = nFees ;
pool . ApplyDelta ( hash , nModifiedFees ) ;
pool . ApplyDelta ( hash , nModifiedFees ) ;
@ -1161,9 +1162,6 @@ static bool CheckInputs(const CTransaction& tx, CValidationState &state, const C
{
{
if ( ! tx . IsCoinBase ( ) )
if ( ! tx . IsCoinBase ( ) )
{
{
if ( ! Consensus : : CheckTxInputs ( tx , state , inputs , GetSpendHeight ( inputs ) ) )
return false ;
if ( pvChecks )
if ( pvChecks )
pvChecks - > reserve ( tx . vin . size ( ) ) ;
pvChecks - > reserve ( tx . vin . size ( ) ) ;
@ -1635,9 +1633,11 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
if ( ! tx . IsCoinBase ( ) )
if ( ! tx . IsCoinBase ( ) )
{
{
if ( ! view . HaveInputs ( tx ) )
CAmount txfee = 0 ;
return state . DoS ( 100 , error ( " ConnectBlock(): inputs missing/spent " ) ,
if ( ! Consensus : : CheckTxInputs ( tx , state , view , pindex - > nHeight , txfee ) ) {
REJECT_INVALID , " bad-txns-inputs-missingorspent " ) ;
return error ( " %s: Consensus::CheckTxInputs: %s, %s " , __func__ , tx . GetHash ( ) . ToString ( ) , FormatStateMessage ( state ) ) ;
}
nFees + = txfee ;
// Check that transaction is BIP68 final
// Check that transaction is BIP68 final
// BIP68 lock checks (as opposed to nLockTime checks) must
// BIP68 lock checks (as opposed to nLockTime checks) must
@ -1665,8 +1665,6 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
txdata . emplace_back ( tx ) ;
txdata . emplace_back ( tx ) ;
if ( ! tx . IsCoinBase ( ) )
if ( ! tx . IsCoinBase ( ) )
{
{
nFees + = view . GetValueIn ( tx ) - tx . GetValueOut ( ) ;
std : : vector < CScriptCheck > vChecks ;
std : : vector < CScriptCheck > vChecks ;
bool fCacheResults = fJustCheck ; /* Don't cache results if we're actually connecting blocks (still consult the cache, though) */
bool fCacheResults = fJustCheck ; /* Don't cache results if we're actually connecting blocks (still consult the cache, though) */
if ( ! CheckInputs ( tx , state , view , fScriptChecks , flags , fCacheResults , txdata [ i ] , nScriptCheckThreads ? & vChecks : NULL ) )
if ( ! CheckInputs ( tx , state , view , fScriptChecks , flags , fCacheResults , txdata [ i ] , nScriptCheckThreads ? & vChecks : NULL ) )