diff --git a/doc/release-notes-28454.md b/doc/release-notes-28454.md new file mode 100644 index 0000000000000..6780218714c1b --- /dev/null +++ b/doc/release-notes-28454.md @@ -0,0 +1,5 @@ +RPC Wallet +---------- + +- The `walletpassphrase` call will now uses the value of 100,000,000 seconds (~3 years) + if the user passes a `timeout` value of `-1`. (#28454) diff --git a/src/wallet/rpc/encrypt.cpp b/src/wallet/rpc/encrypt.cpp index 0226d15698bab..0d472b7e8eded 100644 --- a/src/wallet/rpc/encrypt.cpp +++ b/src/wallet/rpc/encrypt.cpp @@ -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 if -1 specified."}, }, RPCResult{RPCResult::Type::NONE, "", ""}, RPCExamples{ @@ -54,12 +54,13 @@ RPCHelpMan walletpassphrase() // Get the timeout nSleepTime = request.params[1].getInt(); // Timeout cannot be negative, otherwise it will relock immediately - if (nSleepTime < 0) { + if (nSleepTime < 0 && nSleepTime != -1) { 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) { + + if (nSleepTime > MAX_SLEEP_TIME || nSleepTime == -1) { nSleepTime = MAX_SLEEP_TIME; } diff --git a/test/functional/test_framework/wallet_util.py b/test/functional/test_framework/wallet_util.py index 44811918bf946..9c16371148723 100755 --- a/test/functional/test_framework/wallet_util.py +++ b/test/functional/test_framework/wallet_util.py @@ -128,9 +128,7 @@ class WalletUnlock(): A context manager for unlocking a wallet with a passphrase and automatically locking it afterward. """ - MAXIMUM_TIMEOUT = 999000 - - def __init__(self, wallet, passphrase, timeout=MAXIMUM_TIMEOUT): + def __init__(self, wallet, passphrase, timeout=-1): self.wallet = wallet self.passphrase = passphrase self.timeout = timeout