mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-18 22:35:39 +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:
@@ -372,6 +372,27 @@ public:
|
||||
RPCRunLater(name, std::move(fn), seconds);
|
||||
}
|
||||
int rpcSerializationFlags() override { return RPCSerializationFlags(); }
|
||||
util::SettingsValue getRwSetting(const std::string& name) override
|
||||
{
|
||||
util::SettingsValue result;
|
||||
gArgs.LockSettings([&](const util::Settings& settings) {
|
||||
if (const util::SettingsValue* value = util::FindKey(settings.rw_settings, name)) {
|
||||
result = *value;
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
bool updateRwSetting(const std::string& name, const util::SettingsValue& value) override
|
||||
{
|
||||
gArgs.LockSettings([&](util::Settings& settings) {
|
||||
if (value.isNull()) {
|
||||
settings.rw_settings.erase(name);
|
||||
} else {
|
||||
settings.rw_settings[name] = value;
|
||||
}
|
||||
});
|
||||
return gArgs.WriteSettingsFile();
|
||||
}
|
||||
void requestMempoolTransactions(Notifications& notifications) override
|
||||
{
|
||||
LOCK2(::cs_main, ::mempool.cs);
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <optional.h> // For Optional and nullopt
|
||||
#include <primitives/transaction.h> // For CTransactionRef
|
||||
#include <util/settings.h> // For util::SettingsValue
|
||||
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
@@ -269,6 +270,12 @@ public:
|
||||
//! Current RPC serialization flags.
|
||||
virtual int rpcSerializationFlags() = 0;
|
||||
|
||||
//! Return <datadir>/settings.json setting value.
|
||||
virtual util::SettingsValue getRwSetting(const std::string& name) = 0;
|
||||
|
||||
//! Write a setting to <datadir>/settings.json.
|
||||
virtual bool updateRwSetting(const std::string& name, const util::SettingsValue& value) = 0;
|
||||
|
||||
//! Synchronously send transactionAddedToMempool notifications about all
|
||||
//! current mempool transactions to the specified handler and return after
|
||||
//! the last one is sent. These notifications aren't coordinated with async
|
||||
|
||||
Reference in New Issue
Block a user