diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2022-03-29 22:28:42 +0200 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2022-03-31 19:04:04 +0200 |
commit | 1448c99380bbb83f2cf0410470e75049d0e0c627 (patch) | |
tree | 63b6a1a23d42891be8405b7d5a8aac0c8bde8e4b /src | |
parent | 4f3ba8517a7e8c8f823617149d12e72cb32c8d0d (diff) | |
download | bitcoin-1448c99380bbb83f2cf0410470e75049d0e0c627.tar.xz |
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 <achow101-github@achow101.com>
Github-Pull: bitcoin/bitcoin#24711
Rebased-From: 0c12f0116ca802f55f5ab43e6c4842ac403b9889
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/load.cpp | 2 | ||||
-rw-r--r-- | src/wallet/test/wallet_tests.cpp | 1 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 6 |
3 files changed, 7 insertions, 2 deletions
diff --git a/src/wallet/load.cpp b/src/wallet/load.cpp index 633d8c5450..b62d8b57af 100644 --- a/src/wallet/load.cpp +++ b/src/wallet/load.cpp @@ -127,6 +127,8 @@ bool LoadWallets(WalletContext& context) chain.initError(error); return false; } + + NotifyWalletLoaded(context, pwallet); AddWallet(context, pwallet); } return true; diff --git a/src/wallet/test/wallet_tests.cpp b/src/wallet/test/wallet_tests.cpp index 7693c9c0e8..c7227927e2 100644 --- a/src/wallet/test/wallet_tests.cpp +++ b/src/wallet/test/wallet_tests.cpp @@ -54,6 +54,7 @@ static const std::shared_ptr<CWallet> TestLoadWallet(WalletContext& context) std::vector<bilingual_str> warnings; auto database = MakeWalletDatabase("", options, status, error); auto wallet = CWallet::Create(context, "", std::move(database), options.create_flags, error, warnings); + NotifyWalletLoaded(context, wallet); if (context.chain) { wallet->postInitProcess(); } diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 2826217932..55ef103bbe 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -240,6 +240,8 @@ std::shared_ptr<CWallet> LoadWalletInternal(WalletContext& context, const std::s status = DatabaseStatus::FAILED_LOAD; return nullptr; } + + NotifyWalletLoaded(context, wallet); AddWallet(context, wallet); wallet->postInitProcess(); @@ -356,6 +358,8 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string& wallet->Lock(); } } + + NotifyWalletLoaded(context, wallet); AddWallet(context, wallet); wallet->postInitProcess(); @@ -2906,8 +2910,6 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri return nullptr; } - NotifyWalletLoaded(context, walletInstance); - { LOCK(walletInstance->cs_wallet); walletInstance->SetBroadcastTransactions(args.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST)); |