From 98ad066a7eb7909001e2020a314b3607cc3e2d0f Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Tue, 25 Jan 2022 16:13:02 -0500 Subject: [PATCH] Merge bitcoin/bitcoin#24067: wallet: Actually treat (un)confirmed txs as (un)confirmed fac816544317cee6553d60cb0f5f24f6f9ec98de Remove unused checkFinalTx (MarcoFalke) fa272eab44553df9b0bed3ca20caf2a7bd193680 wallet: Avoid dropping confirmed coins (MarcoFalke) 888841ea8d38fc059ca06ef67af7f31f8d8418a4 interfaces: Remove unused is_final (MarcoFalke) dddd05e7a3389fcbd90bb4acdfe1f59945d9f381 qt: Treat unconfirmed txs as unconfirmed (MarcoFalke) Pull request description: The wallet has several issues: ## Unconfirmed txs in the GUI The GUI clumsily attempts to guess if unconfirmed txs are locked until a future time. This is currently based on the locktime only, not nSequence, thus wrong. Fix this by removing the clumsy code and treat all unconfirmed txs as unconfirmed. The GUI already prints whether a tx is in the mempool, in which case the user knows that the tx wasn't locked until a future time. If the tx is not in the mempool, it might be better to report the exact reject reason from the mempool instead of using incorrect heuristics. ## Confirmed txs in the wallet The wallet drops coins that it incorrectly assumes to be locked until a future time, even if they are already confirmed in the chain. This is because the wallet is using the wrong time (adjusted network time) instead of MTP, due to the `-1` default argument of `CheckFinalTx`. The issues are fixed in separate commits and there is even a test. ACKs for top commit: achow101: ACK fac816544317cee6553d60cb0f5f24f6f9ec98de prayank23: reACK https://github.com/bitcoin/bitcoin/pull/24067/commits/fac816544317cee6553d60cb0f5f24f6f9ec98de glozow: code review ACK fac8165443, I understand now how this fixes both issues. Tree-SHA512: 210afb855f4c6d903fee49eba6b1a9735d699cf0168b669eabb38178e53b3a522258b7cc669f52489c6cd3e38bf358afde12eef3ba2e2f2ffaeb06b8f652ccd0 --- src/interfaces/chain.h | 3 -- src/interfaces/wallet.h | 1 - src/node/interfaces.cpp | 5 --- src/qt/transactiondesc.cpp | 9 ------ src/qt/transactionrecord.cpp | 15 +-------- src/qt/transactionrecord.h | 2 -- src/qt/transactiontablemodel.cpp | 9 ------ src/wallet/interfaces.cpp | 1 - test/functional/test_runner.py | 1 + test/functional/wallet_timelock.py | 50 ++++++++++++++++++++++++++++++ 10 files changed, 52 insertions(+), 44 deletions(-) create mode 100755 test/functional/wallet_timelock.py diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index ea5fe712abf0d2..a9b42bcaa4c581 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -133,9 +133,6 @@ class Chain //! or one of its ancestors. virtual std::optional findLocatorFork(const CBlockLocator& locator) = 0; - //! Check if transaction will be final given chain height current time. - virtual bool checkFinalTx(const CTransaction& tx) = 0; - //! Check if transaction is locked by InstantSendManager virtual bool isInstantSendLockedTx(const uint256& hash) = 0; diff --git a/src/interfaces/wallet.h b/src/interfaces/wallet.h index 06ff08caf83f7c..a5112918d7512d 100644 --- a/src/interfaces/wallet.h +++ b/src/interfaces/wallet.h @@ -424,7 +424,6 @@ struct WalletTxStatus int depth_in_main_chain; unsigned int time_received; uint32_t lock_time; - bool is_final; bool is_trusted; bool is_abandoned; bool is_coinbase; diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index d680ab84889524..7856dc99461d0a 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -764,11 +764,6 @@ class ChainImpl : public Chain } return std::nullopt; } - bool checkFinalTx(const CTransaction& tx) override - { - LOCK(cs_main); - return CheckFinalTx(m_node.chainman->ActiveChain().Tip(), tx); - } bool isInstantSendLockedTx(const uint256& hash) override { if (m_node.llmq_ctx == nullptr || m_node.llmq_ctx->isman == nullptr) return false; diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index 2f90ca679faee1..61af346a4f2d5d 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -18,7 +18,6 @@ #include #include #include -#include