diff --git a/src/test/undo_tests.cpp b/src/test/undo_tests.cpp --- a/src/test/undo_tests.cpp +++ b/src/test/undo_tests.cpp @@ -19,7 +19,7 @@ CBlockUndo &blockundo, const CChainParams &chainparams, uint32_t nHeight) { auto &coinbaseTx = *block.vtx[0]; - UpdateCoins(view, coinbaseTx, nHeight); + AddCoins(view, coinbaseTx, nHeight); for (size_t i = 1; i < block.vtx.size(); i++) { auto &tx = *block.vtx[1]; diff --git a/src/txmempool.cpp b/src/txmempool.cpp --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -8,6 +8,7 @@ #include #include // for GetConsensus. #include +#include #include #include #include @@ -870,7 +871,10 @@ Consensus::CheckTxInputs(tx, dummy_state, mempoolDuplicate, spendheight, txfee); assert(fCheckResult); - UpdateCoins(mempoolDuplicate, tx, std::numeric_limits::max()); + for (const auto &input : tx.vin) { + mempoolDuplicate.SpendCoin(input.prevout); + } + AddCoins(mempoolDuplicate, tx, std::numeric_limits::max()); } for (auto it = mapNextTx.cbegin(); it != mapNextTx.cend(); it++) { diff --git a/src/validation.h b/src/validation.h --- a/src/validation.h +++ b/src/validation.h @@ -465,7 +465,6 @@ /** * Apply the effects of this transaction on the UTXO set represented by view. */ -void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, int nHeight); void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, CTxUndo &txundo, int nHeight); diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1145,19 +1145,6 @@ AddCoins(view, tx, nHeight); } -void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, int nHeight) { - // Mark inputs spent. - if (!tx.IsCoinBase()) { - for (const CTxIn &txin : tx.vin) { - bool is_spent = view.SpendCoin(txin.prevout); - assert(is_spent); - } - } - - // Add outputs. - AddCoins(view, tx, nHeight); -} - bool CScriptCheck::operator()() { const CScript &scriptSig = ptxTo->vin[nIn].scriptSig; if (!VerifyScript(scriptSig, m_tx_out.scriptPubKey, nFlags,