diff --git a/src/Makefile.am b/src/Makefile.am --- a/src/Makefile.am +++ b/src/Makefile.am @@ -243,7 +243,6 @@ wallet/coinselection.h \ wallet/crypter.h \ wallet/db.h \ - wallet/finaltx.h \ wallet/rpcdump.h \ wallet/fees.h \ wallet/psbtwallet.h \ @@ -354,7 +353,6 @@ wallet/crypter.cpp \ wallet/coinselection.cpp \ wallet/db.cpp \ - wallet/finaltx.cpp \ wallet/fees.cpp \ wallet/init.cpp \ wallet/psbtwallet.cpp \ diff --git a/src/interfaces/wallet.cpp b/src/interfaces/wallet.cpp --- a/src/interfaces/wallet.cpp +++ b/src/interfaces/wallet.cpp @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include @@ -99,7 +98,8 @@ static WalletTxStatus MakeWalletTxStatus(interfaces::Chain::Lock &locked_chain, const CWalletTx &wtx) { - // Temporary, for CheckFinalTx below. Removed in upcoming commit. + // Temporary, for ContextualCheckTransactionForCurrentBlock below. + // Removed in upcoming commit. LockAnnotation lock(::cs_main); WalletTxStatus result; @@ -110,7 +110,9 @@ result.depth_in_main_chain = wtx.GetDepthInMainChain(locked_chain); result.time_received = wtx.nTimeReceived; result.lock_time = wtx.tx->nLockTime; - result.is_final = CheckFinalTx(*wtx.tx); + CValidationState state; + result.is_final = ContextualCheckTransactionForCurrentBlock( + Params().GetConsensus(), *wtx.tx, state); result.is_trusted = wtx.IsTrusted(locked_chain); result.is_abandoned = wtx.isAbandoned(); result.is_coinbase = wtx.IsCoinBase(); diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -23,7 +23,6 @@ #include #include #include -#include #include #include diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -12,7 +12,6 @@ #include #include #include -#include #include diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt --- a/src/wallet/CMakeLists.txt +++ b/src/wallet/CMakeLists.txt @@ -16,7 +16,6 @@ crypter.cpp db.cpp fees.cpp - finaltx.cpp init.cpp psbtwallet.cpp rpcdump.cpp diff --git a/src/wallet/finaltx.h b/src/wallet/finaltx.h deleted file mode 100644 --- a/src/wallet/finaltx.h +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2017-2018 The Bitcoin developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_WALLET_FINALTX_H -#define BITCOIN_WALLET_FINALTX_H - -class CTransaction; - -/** - * CheckFinalTx is deprecated. In order to provide a sane migration path away - * from it, it is still provided in this header file. Or maybe we'll just - * blackhole the wallet at some point. - */ -bool CheckFinalTx(const CTransaction &tx, int flags = -1) - EXCLUSIVE_LOCKS_REQUIRED(cs_main); - -#endif // BITCOIN_WALLET_FINALTX_H diff --git a/src/wallet/finaltx.cpp b/src/wallet/finaltx.cpp deleted file mode 100644 --- a/src/wallet/finaltx.cpp +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) 2017-2019 The Bitcoin developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#include -#include -#include -#include -#include - -bool CheckFinalTx(const CTransaction &tx, int flags = -1) { - auto &config = GetConfig(); - CValidationState state; - return ContextualCheckTransactionForCurrentBlock( - config.GetChainParams().GetConsensus(), tx, state, flags); -} diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -34,7 +34,6 @@ #include #include #include -#include #include @@ -2184,11 +2183,14 @@ } bool CWalletTx::IsTrusted(interfaces::Chain::Lock &locked_chain) const { - // Temporary, for CheckFinalTx below. Removed in upcoming commit. + // Temporary, for ContextualCheckTransactionForCurrentBlock below. Removed + // in upcoming commit. LockAnnotation lock(::cs_main); // Quick answer in most cases - if (!CheckFinalTx(*tx)) { + CValidationState state; + if (!ContextualCheckTransactionForCurrentBlock(Params().GetConsensus(), *tx, + state)) { return false; } @@ -2398,16 +2400,22 @@ // trusted. Amount CWallet::GetLegacyBalance(const isminefilter &filter, int minDepth) const { - // Temporary, for CheckFinalTx below. Removed in upcoming commit. + // Temporary, for ContextualCheckTransactionForCurrentBlock below. Removed + // in upcoming commit. LockAnnotation lock(::cs_main); auto locked_chain = chain().lock(); LOCK(cs_wallet); + const Consensus::Params params = Params().GetConsensus(); + Amount balance = Amount::zero(); for (const auto &entry : mapWallet) { const CWalletTx &wtx = entry.second; const int depth = wtx.GetDepthInMainChain(*locked_chain); - if (depth < 0 || !CheckFinalTx(*wtx.tx) || + CValidationState state; + if (depth < 0 || + !ContextualCheckTransactionForCurrentBlock(params, *wtx.tx, + state) || wtx.IsImmatureCoinBase(*locked_chain)) { continue; } @@ -2462,11 +2470,15 @@ vCoins.clear(); Amount nTotal = Amount::zero(); + const Consensus::Params params = Params().GetConsensus(); + for (const auto &entry : mapWallet) { const TxId &wtxid = entry.first; const CWalletTx *pcoin = &entry.second; - if (!CheckFinalTx(*pcoin->tx)) { + CValidationState state; + if (!ContextualCheckTransactionForCurrentBlock(params, *pcoin->tx, + state)) { continue; }