From f914c7a1a47657b75f2d54b7a1f5a299772f1cae Mon Sep 17 00:00:00 2001 From: Philip Kaufmann Date: Mon, 28 Oct 2013 11:58:39 +0100 Subject: [PATCH] rpcwallet: use EnsureWalletIsUnlocked() where possible - replaces a pwalletMain->IsLocked() check - in keypoolrefill init kpSize to 0 as we have the logic to determine max kpSize in pwalletMain->TopUpKeyPool() anyway --- src/rpcwallet.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/rpcwallet.cpp b/src/rpcwallet.cpp index bb87afec5..82fa9d88c 100644 --- a/src/rpcwallet.cpp +++ b/src/rpcwallet.cpp @@ -334,8 +334,7 @@ Value sendtoaddress(const Array& params, bool fHelp) if (params.size() > 3 && params[3].type() != null_type && !params[3].get_str().empty()) wtx.mapValue["to"] = params[3].get_str(); - if (pwalletMain->IsLocked()) - throw JSONRPCError(RPC_WALLET_UNLOCK_NEEDED, "Error: Please enter the wallet passphrase with walletpassphrase first."); + EnsureWalletIsUnlocked(); string strError = pwalletMain->SendMoneyToDestination(address.Get(), nAmount, wtx); if (strError != "") @@ -1657,15 +1656,15 @@ Value keypoolrefill(const Array& params, bool fHelp) + HelpExampleRpc("keypoolrefill", "") ); - unsigned int kpSize = max(GetArg("-keypool", 100), (int64_t) 0); + // 0 is interpreted by TopUpKeyPool() as the default keypool size given by -keypool + unsigned int kpSize = 0; if (params.size() > 0) { if (params[0].get_int() < 0) - throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected valid size"); - kpSize = (unsigned int) params[0].get_int(); + throw JSONRPCError(RPC_INVALID_PARAMETER, "Invalid parameter, expected valid size."); + kpSize = (unsigned int)params[0].get_int(); } EnsureWalletIsUnlocked(); - pwalletMain->TopUpKeyPool(kpSize); if (pwalletMain->GetKeyPoolSize() < kpSize)