mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-25 10:43:19 -03:00
Add upgradewallet RPC
This commit is contained in:
parent
1e48796c99
commit
92263cce5b
2 changed files with 41 additions and 0 deletions
|
@ -153,6 +153,7 @@ static const CRPCConvertParam vRPCConvertParams[] =
|
|||
{ "logging", 0, "include" },
|
||||
{ "logging", 1, "exclude" },
|
||||
{ "disconnectnode", 1, "nodeid" },
|
||||
{ "upgradewallet", 0, "version" },
|
||||
// Echo with conversion (For testing only)
|
||||
{ "echojson", 0, "arg0" },
|
||||
{ "echojson", 1, "arg1" },
|
||||
|
|
|
@ -4245,6 +4245,45 @@ UniValue walletcreatefundedpsbt(const JSONRPCRequest& request)
|
|||
return result;
|
||||
}
|
||||
|
||||
static UniValue upgradewallet(const JSONRPCRequest& request)
|
||||
{
|
||||
std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request);
|
||||
CWallet* const pwallet = wallet.get();
|
||||
|
||||
if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) {
|
||||
return NullUniValue;
|
||||
}
|
||||
|
||||
RPCHelpMan{"upgradewallet",
|
||||
"\nUpgrade the wallet. Upgrades to the latest version if no version number is specified\n"
|
||||
"New keys may be generated and a new wallet backup will need to be made.",
|
||||
{
|
||||
{"version", RPCArg::Type::NUM, /* default */ strprintf("%d", FEATURE_LATEST), "The version number to upgrade to. Default is the latest wallet version"}
|
||||
},
|
||||
RPCResults{},
|
||||
RPCExamples{
|
||||
HelpExampleCli("upgradewallet", "169900")
|
||||
+ HelpExampleRpc("upgradewallet", "169900")
|
||||
}
|
||||
}.Check(request);
|
||||
|
||||
RPCTypeCheck(request.params, {UniValue::VNUM}, true);
|
||||
|
||||
EnsureWalletIsUnlocked(pwallet);
|
||||
|
||||
int version = 0;
|
||||
if (!request.params[0].isNull()) {
|
||||
version = request.params[0].get_int();
|
||||
}
|
||||
|
||||
std::string error;
|
||||
std::vector<std::string> warnings;
|
||||
if (!pwallet->UpgradeWallet(version, error, warnings)) {
|
||||
throw JSONRPCError(RPC_WALLET_ERROR, error);
|
||||
}
|
||||
return error;
|
||||
}
|
||||
|
||||
UniValue abortrescan(const JSONRPCRequest& request); // in rpcdump.cpp
|
||||
UniValue dumpprivkey(const JSONRPCRequest& request); // in rpcdump.cpp
|
||||
UniValue importprivkey(const JSONRPCRequest& request);
|
||||
|
@ -4313,6 +4352,7 @@ static const CRPCCommand commands[] =
|
|||
{ "wallet", "signmessage", &signmessage, {"address","message"} },
|
||||
{ "wallet", "signrawtransactionwithwallet", &signrawtransactionwithwallet, {"hexstring","prevtxs","sighashtype"} },
|
||||
{ "wallet", "unloadwallet", &unloadwallet, {"wallet_name"} },
|
||||
{ "wallet", "upgradewallet", &upgradewallet, {"version"} },
|
||||
{ "wallet", "walletcreatefundedpsbt", &walletcreatefundedpsbt, {"inputs","outputs","locktime","options","bip32derivs"} },
|
||||
{ "wallet", "walletlock", &walletlock, {} },
|
||||
{ "wallet", "walletpassphrase", &walletpassphrase, {"passphrase","timeout"} },
|
||||
|
|
Loading…
Add table
Reference in a new issue