Skip to content

Commit 1448c99

Browse files
hebastoMarcoFalke
authored and
MarcoFalke
committed
wallet: Postpone NotifyWalletLoaded() for encrypted wallets
Too early NotifyWalletLoaded() call in CWallet::Create() results the notification goes before DescriptorScriptPubKeyMans were created and added to an encrypted wallet. Co-authored-by: Andrew Chow <[email protected]> Github-Pull: bitcoin/bitcoin#24711 Rebased-From: 0c12f01
1 parent 4f3ba85 commit 1448c99

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/wallet/load.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@ bool LoadWallets(WalletContext& context)
127127
chain.initError(error);
128128
return false;
129129
}
130+
131+
NotifyWalletLoaded(context, pwallet);
130132
AddWallet(context, pwallet);
131133
}
132134
return true;

src/wallet/test/wallet_tests.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ static const std::shared_ptr<CWallet> TestLoadWallet(WalletContext& context)
5454
std::vector<bilingual_str> warnings;
5555
auto database = MakeWalletDatabase("", options, status, error);
5656
auto wallet = CWallet::Create(context, "", std::move(database), options.create_flags, error, warnings);
57+
NotifyWalletLoaded(context, wallet);
5758
if (context.chain) {
5859
wallet->postInitProcess();
5960
}

src/wallet/wallet.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ std::shared_ptr<CWallet> LoadWalletInternal(WalletContext& context, const std::s
240240
status = DatabaseStatus::FAILED_LOAD;
241241
return nullptr;
242242
}
243+
244+
NotifyWalletLoaded(context, wallet);
243245
AddWallet(context, wallet);
244246
wallet->postInitProcess();
245247

@@ -356,6 +358,8 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
356358
wallet->Lock();
357359
}
358360
}
361+
362+
NotifyWalletLoaded(context, wallet);
359363
AddWallet(context, wallet);
360364
wallet->postInitProcess();
361365

@@ -2906,8 +2910,6 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
29062910
return nullptr;
29072911
}
29082912

2909-
NotifyWalletLoaded(context, walletInstance);
2910-
29112913
{
29122914
LOCK(walletInstance->cs_wallet);
29132915
walletInstance->SetBroadcastTransactions(args.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST));

0 commit comments

Comments
 (0)