| 2053 | |
| 2054 | |
| 2055 | UniValue keypoolrefill(const UniValue& params, bool fHelp) |
| 2056 | { |
| 2057 | if (fHelp || params.size() > 1) |
| 2058 | throw runtime_error( |
| 2059 | "keypoolrefill ( newsize )\n" |
| 2060 | "\nFills the keypool." + |
| 2061 | HelpRequiringPassphrase() + "\n" |
| 2062 | "\nArguments\n" |
| 2063 | "1. newsize (numeric, optional, default=100) The new keypool size\n" |
| 2064 | "\nExamples:\n" + |
| 2065 | HelpExampleCli("keypoolrefill", "") + HelpExampleRpc("keypoolrefill", "")); |
| 2066 | |
| 2067 | LOCK2(cs_main, pwalletMain->cs_wallet); |
| 2068 | |
| 2069 | // 0 is interpreted by TopUpKeyPool() as the default keypool size given by -keypool |
| 2070 | unsigned int kpSize = 0; |
| 2071 | if (params.size() > 0) { |
| 2072 | if (params[0].get_int() < 0) |
| 2073 | throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected valid size."); |
| 2074 | kpSize = (unsigned int)params[0].get_int(); |
| 2075 | } |
| 2076 | |
| 2077 | EnsureWalletIsUnlocked(); |
| 2078 | pwalletMain->TopUpKeyPool(kpSize); |
| 2079 | |
| 2080 | if (pwalletMain->GetKeyPoolSize() < (pwalletMain->IsHDEnabled() ? kpSize * 2 : kpSize)) |
| 2081 | throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool."); |
| 2082 | |
| 2083 | return NullUniValue; |
| 2084 | } |
| 2085 | |
| 2086 | |
| 2087 | static void LockWallet(CWallet* pWallet) |
nothing calls this directly
no test coverage detected