Skip to content

Commit

Permalink
wallet: allowing walletpassphrase timeout to be set to MAX_SLEEP_TIME
Browse files Browse the repository at this point in the history
In this change we allow the timeout for walletpassphrase to be
set to MAX_SLEEP_TIME,
if set as 0 then we then use the MAX_SLEEP_TIME amount

context from PR 28403
  • Loading branch information
kevkevinpal committed Sep 12, 2023
1 parent 8f7b9eb commit e776d58
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/wallet/rpc/encrypt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RPCHelpMan walletpassphrase()
"time that overrides the old one.\n",
{
{"passphrase", RPCArg::Type::STR, RPCArg::Optional::NO, "The wallet passphrase"},
{"timeout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The time to keep the decryption key in seconds; capped at 100000000 (~3 years)."},
{"timeout", RPCArg::Type::NUM, RPCArg::Optional::NO, "The time to keep the decryption key in seconds; capped at 100000000 (~3 years), will use cap 0 specified"},
},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{
Expand Down Expand Up @@ -57,11 +57,13 @@ RPCHelpMan walletpassphrase()
if (nSleepTime < 0) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "Timeout cannot be negative.");
}
// Clamp timeout

constexpr int64_t MAX_SLEEP_TIME = 100000000; // larger values trigger a macos/libevent bug?
if (nSleepTime > MAX_SLEEP_TIME) {
// Clamp timeout
if (nSleepTime > MAX_SLEEP_TIME || nSleepTime == 0) {
nSleepTime = MAX_SLEEP_TIME;
}


if (strWalletPass.empty()) {
throw JSONRPCError(RPC_INVALID_PARAMETER, "passphrase cannot be empty");
Expand Down

0 comments on commit e776d58

Please sign in to comment.