Skip to content

Commit 0c12f01

Browse files
hebastoachow101
andcommitted
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]>
1 parent aeee419 commit 0c12f01

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
@@ -130,6 +130,8 @@ bool LoadWallets(WalletContext& context)
130130
chain.initError(error);
131131
return false;
132132
}
133+
134+
NotifyWalletLoaded(context, pwallet);
133135
AddWallet(context, pwallet);
134136
}
135137
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

@@ -2912,8 +2916,6 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
29122916
return nullptr;
29132917
}
29142918

2915-
NotifyWalletLoaded(context, walletInstance);
2916-
29172919
{
29182920
LOCK(walletInstance->cs_wallet);
29192921
walletInstance->SetBroadcastTransactions(args.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST));

0 commit comments

Comments
 (0)