mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-13 07:28:59 +01:00
Add loadwallet and createwallet RPC load_on_startup options
This maintains a persistent list of wallets stored in settings that will automatically be loaded on startup. Being able to load a wallet automatically on startup will be more useful in the GUI when the option to create wallets is added in #15006, but it's reasonable to expose this feature by RPC as well.
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <node/context.h>
|
||||
#include <node/ui_interface.h>
|
||||
#include <outputtype.h>
|
||||
#include <univalue.h>
|
||||
#include <util/check.h>
|
||||
#include <util/moneystr.h>
|
||||
#include <util/system.h>
|
||||
@@ -118,6 +119,14 @@ void WalletInit::Construct(NodeContext& node) const
|
||||
LogPrintf("Wallet disabled!\n");
|
||||
return;
|
||||
}
|
||||
args.SoftSetArg("-wallet", "");
|
||||
// If there's no -wallet setting with a list of wallets to load, set it to
|
||||
// load the default "" wallet.
|
||||
if (!args.IsArgSet("wallet")) {
|
||||
args.LockSettings([&](util::Settings& settings) {
|
||||
util::SettingsValue wallets(util::SettingsValue::VARR);
|
||||
wallets.push_back(""); // Default wallet name is ""
|
||||
settings.rw_settings["wallet"] = wallets;
|
||||
});
|
||||
}
|
||||
node.chain_clients.emplace_back(interfaces::MakeWalletClient(*node.chain, args, args.GetArgs("-wallet")));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user