mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-02 09:46:52 -05:00
Merge bitcoin/bitcoin#24711: wallet: Postpone wallet loading notification for encrypted wallets
0c12f0116c
wallet: Postpone NotifyWalletLoaded() for encrypted wallets (Hennadii Stepanov)aeee419c6a
wallet, refactor: Add wallet::NotifyWalletLoaded() function (Hennadii Stepanov) Pull request description: Fixes bitcoin-core/gui#571. `CWallet::Create()` notifies about wallet loading too early, that results the notification goes before `DescriptorScriptPubKeyMan`s were created and added to an encrypted wallet. And `interfaces::Wallet::taprootEnabled()` inecf692b466/src/qt/receivecoinsdialog.cpp (L100-L102)
erroneously returns `false` for just created encrypted descriptor wallets. ACKs for top commit: Sjors: utACK0c12f0116c
achow101: ACK0c12f0116c
Tree-SHA512: 2694bacd12748cd5f6c95d9d3bf8bcf4502ee67fecd8d057f33236b72069c61401b08f49deb013fc71c3f1e51ae16bdfd827ddcbc2a083d7044589be7a78982e
This commit is contained in:
commit
b7d78e6244
4 changed files with 16 additions and 7 deletions
|
@ -130,6 +130,8 @@ bool LoadWallets(WalletContext& context)
|
|||
chain.initError(error);
|
||||
return false;
|
||||
}
|
||||
|
||||
NotifyWalletLoaded(context, pwallet);
|
||||
AddWallet(context, pwallet);
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -167,6 +167,14 @@ std::unique_ptr<interfaces::Handler> HandleLoadWallet(WalletContext& context, Lo
|
|||
return interfaces::MakeHandler([&context, it] { LOCK(context.wallets_mutex); context.wallet_load_fns.erase(it); });
|
||||
}
|
||||
|
||||
void NotifyWalletLoaded(WalletContext& context, const std::shared_ptr<CWallet>& wallet)
|
||||
{
|
||||
LOCK(context.wallets_mutex);
|
||||
for (auto& load_wallet : context.wallet_load_fns) {
|
||||
load_wallet(interfaces::MakeWallet(context, wallet));
|
||||
}
|
||||
}
|
||||
|
||||
static Mutex g_loading_wallet_mutex;
|
||||
static Mutex g_wallet_release_mutex;
|
||||
static std::condition_variable g_wallet_release_cv;
|
||||
|
@ -232,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();
|
||||
|
||||
|
@ -348,6 +358,8 @@ std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string&
|
|||
wallet->Lock();
|
||||
}
|
||||
}
|
||||
|
||||
NotifyWalletLoaded(context, wallet);
|
||||
AddWallet(context, wallet);
|
||||
wallet->postInitProcess();
|
||||
|
||||
|
@ -2904,13 +2916,6 @@ std::shared_ptr<CWallet> CWallet::Create(WalletContext& context, const std::stri
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
{
|
||||
LOCK(context.wallets_mutex);
|
||||
for (auto& load_wallet : context.wallet_load_fns) {
|
||||
load_wallet(interfaces::MakeWallet(context, walletInstance));
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
LOCK(walletInstance->cs_wallet);
|
||||
walletInstance->SetBroadcastTransactions(args.GetBoolArg("-walletbroadcast", DEFAULT_WALLETBROADCAST));
|
||||
|
|
|
@ -67,6 +67,7 @@ std::shared_ptr<CWallet> LoadWallet(WalletContext& context, const std::string& n
|
|||
std::shared_ptr<CWallet> CreateWallet(WalletContext& context, const std::string& name, std::optional<bool> load_on_start, DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||
std::shared_ptr<CWallet> RestoreWallet(WalletContext& context, const fs::path& backup_file, const std::string& wallet_name, std::optional<bool> load_on_start, DatabaseStatus& status, bilingual_str& error, std::vector<bilingual_str>& warnings);
|
||||
std::unique_ptr<interfaces::Handler> HandleLoadWallet(WalletContext& context, LoadWalletFn load_wallet);
|
||||
void NotifyWalletLoaded(WalletContext& context, const std::shared_ptr<CWallet>& wallet);
|
||||
std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error);
|
||||
|
||||
//! -paytxfee default
|
||||
|
|
Loading…
Add table
Reference in a new issue