diff options
author | Ava Chow <github@achow101.com> | 2024-01-12 20:07:57 -0500 |
---|---|---|
committer | Ava Chow <github@achow101.com> | 2024-01-12 20:09:08 -0500 |
commit | ea2551e55d260854a5cca8aa95034970d4adca1c (patch) | |
tree | fec71f534577862327ac2bef1b0dc6d93607e2a8 /src/wallet | |
parent | 3ba8de1b704d590fa4e1975620bd21d830d11666 (diff) | |
download | bitcoin-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')
-rw-r--r-- | src/wallet/wallet.cpp | 1 |
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; } |