@@ -484,7 +484,6 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
484
484
CCoinsView dummy;
485
485
CCoinsViewCache view (&dummy);
486
486
487
- CAmount nValueIn = 0 ;
488
487
LockPoints lp;
489
488
{
490
489
LOCK (pool.cs );
@@ -519,8 +518,6 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
519
518
// Bring the best block into scope
520
519
view.GetBestBlock ();
521
520
522
- nValueIn = view.GetValueIn (tx);
523
-
524
521
// we have all inputs cached now, so switch back to dummy, so we don't need to keep lock on mempool
525
522
view.SetBackend (dummy);
526
523
@@ -531,6 +528,12 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
531
528
// CoinsViewCache instead of create its own
532
529
if (!CheckSequenceLocks (tx, STANDARD_LOCKTIME_VERIFY_FLAGS, &lp))
533
530
return state.DoS (0 , false , REJECT_NONSTANDARD, " non-BIP68-final" );
531
+
532
+ } // end LOCK(pool.cs)
533
+
534
+ CAmount nFees = 0 ;
535
+ if (!Consensus::CheckTxInputs (tx, state, view, GetSpendHeight (view), nFees)) {
536
+ return error (" %s: Consensus::CheckTxInputs: %s, %s" , __func__, tx.GetHash ().ToString (), FormatStateMessage (state));
534
537
}
535
538
536
539
// Check for non-standard pay-to-script-hash in inputs
@@ -543,8 +546,6 @@ static bool AcceptToMemoryPoolWorker(const CChainParams& chainparams, CTxMemPool
543
546
544
547
int64_t nSigOpsCost = GetTransactionSigOpCost (tx, view, STANDARD_SCRIPT_VERIFY_FLAGS);
545
548
546
- CAmount nValueOut = tx.GetValueOut ();
547
- CAmount nFees = nValueIn-nValueOut;
548
549
// nModifiedFees includes any fee deltas from PrioritiseTransaction
549
550
CAmount nModifiedFees = nFees;
550
551
pool.ApplyDelta (hash, nModifiedFees);
@@ -1161,9 +1162,6 @@ static bool CheckInputs(const CTransaction& tx, CValidationState &state, const C
1161
1162
{
1162
1163
if (!tx.IsCoinBase ())
1163
1164
{
1164
- if (!Consensus::CheckTxInputs (tx, state, inputs, GetSpendHeight (inputs)))
1165
- return false ;
1166
-
1167
1165
if (pvChecks)
1168
1166
pvChecks->reserve (tx.vin .size ());
1169
1167
@@ -1635,9 +1633,11 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1635
1633
1636
1634
if (!tx.IsCoinBase ())
1637
1635
{
1638
- if (!view.HaveInputs (tx))
1639
- return state.DoS (100 , error (" ConnectBlock(): inputs missing/spent" ),
1640
- REJECT_INVALID, " bad-txns-inputs-missingorspent" );
1636
+ CAmount txfee = 0 ;
1637
+ if (!Consensus::CheckTxInputs (tx, state, view, pindex->nHeight , txfee)) {
1638
+ return error (" %s: Consensus::CheckTxInputs: %s, %s" , __func__, tx.GetHash ().ToString (), FormatStateMessage (state));
1639
+ }
1640
+ nFees += txfee;
1641
1641
1642
1642
// Check that transaction is BIP68 final
1643
1643
// BIP68 lock checks (as opposed to nLockTime checks) must
@@ -1665,8 +1665,6 @@ static bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockInd
1665
1665
txdata.emplace_back (tx);
1666
1666
if (!tx.IsCoinBase ())
1667
1667
{
1668
- nFees += view.GetValueIn (tx)-tx.GetValueOut ();
1669
-
1670
1668
std::vector<CScriptCheck> vChecks;
1671
1669
bool fCacheResults = fJustCheck ; /* Don't cache results if we're actually connecting blocks (still consult the cache, though) */
1672
1670
if (!CheckInputs (tx, state, view, fScriptChecks , flags, fCacheResults , txdata[i], nScriptCheckThreads ? &vChecks : NULL ))
0 commit comments