aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.cpp
diff options
context:
space:
mode:
authorAva Chow <github@achow101.com>2024-01-12 20:07:57 -0500
committerAva Chow <github@achow101.com>2024-01-12 20:09:08 -0500
commitea2551e55d260854a5cca8aa95034970d4adca1c (patch)
treefec71f534577862327ac2bef1b0dc6d93607e2a8 /src/wallet/wallet.cpp
parent3ba8de1b704d590fa4e1975620bd21d830d11666 (diff)
downloadbitcoin-ea2551e55d260854a5cca8aa95034970d4adca1c.tar.xz
wallet: Reset chain notifications handler if AttachChain fails
AttachChain will create the chain notifications handler which contains a reference to the wallet's shared_ptr. If AttachChain fails, the wallet needs to be unloaded, and this is expected to happen with its custom deleter ReleaseWallet. However, if the chain notifications handler is still set, then the shared_ptr is still referenced by something, so the wallet is never actually released.
Diffstat (limited to 'src/wallet/wallet.cpp')
-rw-r--r--src/wallet/wallet.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index bf8cfcb082..e03f5532fc 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -3099,6 +3099,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
if (time_first_key) walletInstance->MaybeUpdateBirthTime(*time_first_key);
if (chain && !AttachChain(walletInstance, *chain, rescan_required, error, warnings)) {
+ walletInstance->m_chain_notifications_handler.reset(); // Reset this pointer so that the wallet will actually be unloaded
return nullptr;
}