Skip to content

Commit fe1eccd

Browse files
committed
Merge bitcoin/bitcoin#29243: wallet: Reset chain notifications handler if AttachChain fails
ea2551e wallet: Reset chain notifications handler if AttachChain fails (Ava Chow) Pull request description: 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. This behavior can also be verified by looking at the debug.log file. When the wallet is released, the line "Releasing wallet" should appear in the debug.log file. However the failing test does not contain that line, indicating that the problem is that the `CWallet` object is not being destroyed. After this PR, that log line now appears, and the test also passes. Fixes #29234 ACKs for top commit: jamesob: ACK bitcoin/bitcoin@ea2551e murchandamus: ACK ea2551e TheCharlatan: ACK ea2551e furszy: Code review ACK ea2551e BrandonOdiwuor: Code Review ACK ea2551e Tree-SHA512: 73d676068c699303d9bcf70c9288ecb05f5f2e400ff3b7201367658d39d2fab63def97ab5ce4a742a6f2ca5e325f598fdbb6ce8f157a0423c07abc9a19bd5c81
2 parents 3ba8de1 + ea2551e commit fe1eccd

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)