Skip to content

Commit ea2551e

Browse files
committed
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.
1 parent 3ba8de1 commit ea2551e

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/wallet/wallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3099,6 +3099,7 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
30993099
if (time_first_key) walletInstance->MaybeUpdateBirthTime(*time_first_key);
31003100

31013101
if (chain && !AttachChain(walletInstance, *chain, rescan_required, error, warnings)) {
3102+
walletInstance->m_chain_notifications_handler.reset(); // Reset this pointer so that the wallet will actually be unloaded
31023103
return nullptr;
31033104
}
31043105

0 commit comments

Comments
 (0)