| 2503 | |
| 2504 | |
| 2505 | static UniValue keypoolrefill(const JSONRPCRequest& request) |
| 2506 | { |
| 2507 | std::shared_ptr<CWallet> const wallet = GetWalletForJSONRPCRequest(request); |
| 2508 | CWallet* const pwallet = wallet.get(); |
| 2509 | |
| 2510 | if (!EnsureWalletIsAvailable(pwallet, request.fHelp)) { |
| 2511 | return NullUniValue; |
| 2512 | } |
| 2513 | |
| 2514 | if (request.fHelp || request.params.size() > 1) |
| 2515 | throw std::runtime_error( |
| 2516 | "keypoolrefill ( newsize )\n" |
| 2517 | "\nFills the keypool." |
| 2518 | + HelpRequiringPassphrase(pwallet) + "\n" |
| 2519 | "\nArguments\n" |
| 2520 | "1. newsize (numeric, optional, default=100) The new keypool size\n" |
| 2521 | "\nExamples:\n" |
| 2522 | + HelpExampleCli("keypoolrefill", "") |
| 2523 | + HelpExampleRpc("keypoolrefill", "") |
| 2524 | ); |
| 2525 | |
| 2526 | if (pwallet->IsWalletFlagSet(WALLET_FLAG_DISABLE_PRIVATE_KEYS)) { |
| 2527 | throw JSONRPCError(RPC_WALLET_ERROR, "Error: Private keys are disabled for this wallet"); |
| 2528 | } |
| 2529 | |
| 2530 | LOCK2(cs_main, pwallet->cs_wallet); |
| 2531 | |
| 2532 | // 0 is interpreted by TopUpKeyPool() as the default keypool size given by -keypool |
| 2533 | unsigned int kpSize = 0; |
| 2534 | if (!request.params[0].isNull()) { |
| 2535 | if (request.params[0].get_int() < 0) |
| 2536 | throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected valid size."); |
| 2537 | kpSize = (unsigned int)request.params[0].get_int(); |
| 2538 | } |
| 2539 | |
| 2540 | EnsureWalletIsUnlocked(pwallet); |
| 2541 | pwallet->TopUpKeyPool(kpSize); |
| 2542 | |
| 2543 | if (pwallet->GetKeyPoolSize() < kpSize) { |
| 2544 | throw JSONRPCError(RPC_WALLET_ERROR, "Error refreshing keypool."); |
| 2545 | } |
| 2546 | |
| 2547 | return NullUniValue; |
| 2548 | } |
| 2549 | |
| 2550 | |
| 2551 | static UniValue walletpassphrase(const JSONRPCRequest& request) |
nothing calls this directly
no test coverage detected