diff --git a/src/interfaces/chain.cpp b/src/interfaces/chain.cpp index a2f521e7b..5b4654e03 100644 --- a/src/interfaces/chain.cpp +++ b/src/interfaces/chain.cpp @@ -347,17 +347,16 @@ public: { return MakeUnique(*this, notifications); } - bool waitForNotificationsIfTipIsNotSame(const uint256& tip) override + void waitForNotificationsIfTipIsNotSame(const uint256& tip) override { if (!tip.IsNull()) { LOCK(::cs_main); auto chainTip = ::ChainActive().Tip(); - if (tip == chainTip->GetBlockHash()) return true; + if (tip == chainTip->GetBlockHash()) return; CBlockIndex* block = LookupBlockIndex(tip); - if (block && block->GetAncestor(::ChainActive().Height()) == chainTip) return true; + if (block && block->GetAncestor(::ChainActive().Height()) == chainTip) return; } SyncWithValidationInterfaceQueue(); - return false; } std::unique_ptr handleRpc(const CRPCCommand& command) override { diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h index 5433ba324..87553a855 100644 --- a/src/interfaces/chain.h +++ b/src/interfaces/chain.h @@ -230,7 +230,7 @@ public: //! Wait for pending notifications to be processed unless block hash points to the current //! chain tip, or to a possible descendant of the current chain tip that isn't currently //! connected. - virtual bool waitForNotificationsIfTipIsNotSame(const uint256& tip) = 0; + virtual void waitForNotificationsIfTipIsNotSame(const uint256& tip) = 0; //! Register handler for RPC. Command is not copied, so reference //! needs to remain valid until Handler is disconnected. diff --git a/src/wallet/ismine.h b/src/wallet/ismine.h index 642a87792..2b40109c5 100644 --- a/src/wallet/ismine.h +++ b/src/wallet/ismine.h @@ -25,7 +25,7 @@ enum isminetype : unsigned int ISMINE_USED = 1 << 4, ISMINE_STAKE = ISMINE_CLAIM | ISMINE_SUPPORT, ISMINE_ALL = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE, - ISMINE_ALL_USED = ISMINE_ALL | ISMINE_USED | ISMINE_STAKE, + ISMINE_ALL_USED = ISMINE_ALL | ISMINE_USED, ISMINE_ENUM_ELEMENTS, }; /** used for bitflags of isminetype */ diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b8a7cc150..affce2a92 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2228,7 +2228,8 @@ static UniValue listsinceblock(const JSONRPCRequest& request) for (const auto& pairWtx : pwallet->mapWallet) { CWalletTx tx = pairWtx.second; - if (depth == -1 || abs(tx.GetDepthInMainChain(*locked_chain)) < depth) { + auto dmc = tx.GetDepthInMainChain(*locked_chain); + if (depth == -1 || (dmc >= 0 && dmc < depth)) { ListTransactions(*locked_chain, pwallet, tx, 0, true, transactions, filter, nullptr /* filter_label */); } } diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index b554dfaab..f36bda6f5 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -283,7 +283,7 @@ static int64_t AddTx(CWallet& wallet, uint32_t lockTime, int64_t mockTime, int64 LOCK(wallet.cs_wallet); // If transaction is already in map, to avoid inconsistencies, unconfirmation // is needed before confirm again with different block. - std::map::iterator it = wallet.mapWallet.find(wtx.GetHash()); + auto it = wallet.mapWallet.find(wtx.GetHash()); if (it != wallet.mapWallet.end()) { wtx.setUnconfirmed(); wallet.AddToWallet(wtx); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 072bb7e1b..5b4a8ead8 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1498,13 +1498,8 @@ void CWallet::BlockUntilSyncedToCurrentChain() { // ::ChainActive().Tip(), otherwise put a callback in the validation interface queue and wait // for the queue to drain enough to execute it (indicating we are caught up // at least with the time we entered this function). - auto lastProcessedBlock = [this]() -> uint256 { - return WITH_LOCK(cs_wallet, return m_last_block_processed); - }; - bool tipIsSame = false; - uint256 last_block_hash; - while (!tipIsSame && !(last_block_hash = lastProcessedBlock()).IsNull()) - tipIsSame = chain().waitForNotificationsIfTipIsNotSame(last_block_hash); + uint256 last_block_hash = WITH_LOCK(cs_wallet, return m_last_block_processed); + chain().waitForNotificationsIfTipIsNotSame(last_block_hash); } @@ -2444,7 +2439,7 @@ void CWallet::ResendWalletTransactions() LOCK(cs_wallet); // Relay transactions - for (std::pair& item : mapWallet) { + for (auto& item : mapWallet) { CWalletTx& wtx = item.second; // Attempt to rebroadcast all txes more than 5 minutes older than // the last block. SubmitMemoryPoolAndRelay() will not rebroadcast