Skip to content

Commit 22cc797

Browse files
committed
Add newkeypool RPC to flush the keypool
1 parent 16ccb3a commit 22cc797

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

src/wallet/rpcwallet.cpp

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1892,6 +1892,33 @@ static RPCHelpMan keypoolrefill()
18921892
}
18931893

18941894

1895+
static RPCHelpMan newkeypool()
1896+
{
1897+
return RPCHelpMan{"newkeypool",
1898+
"\nEntirely clears and refills the keypool."+
1899+
HELP_REQUIRING_PASSPHRASE,
1900+
{},
1901+
RPCResult{RPCResult::Type::NONE, "", ""},
1902+
RPCExamples{
1903+
HelpExampleCli("newkeypool", "")
1904+
+ HelpExampleRpc("newkeypool", "")
1905+
},
1906+
[&](const RPCHelpMan& self, const JSONRPCRequest& request) -> UniValue
1907+
{
1908+
std::shared_ptr<CWallet> const pwallet = GetWalletForJSONRPCRequest(request);
1909+
if (!pwallet) return NullUniValue;
1910+
1911+
LOCK(pwallet->cs_wallet);
1912+
1913+
LegacyScriptPubKeyMan& spk_man = EnsureLegacyScriptPubKeyMan(*pwallet, true);
1914+
spk_man.NewKeyPool();
1915+
1916+
return NullUniValue;
1917+
},
1918+
};
1919+
}
1920+
1921+
18951922
static RPCHelpMan walletpassphrase()
18961923
{
18971924
return RPCHelpMan{"walletpassphrase",
@@ -4773,6 +4800,7 @@ static const CRPCCommand commands[] =
47734800
{ "wallet", &listwallets, },
47744801
{ "wallet", &loadwallet, },
47754802
{ "wallet", &lockunspent, },
4803+
{ "wallet", &newkeypool, },
47764804
{ "wallet", &removeprunedfunds, },
47774805
{ "wallet", &rescanblockchain, },
47784806
{ "wallet", &send, },

0 commit comments

Comments
 (0)