Skip to content

Default wallet passphrase timeout #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/release-notes-28454.md
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 4 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 if -1 specified."},
},
RPCResult{RPCResult::Type::NONE, "", ""},
RPCExamples{
Expand Down Expand Up @@ -54,12 +54,13 @@ RPCHelpMan walletpassphrase()
// Get the timeout
nSleepTime = request.params[1].getInt<int64_t>();
// 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;
}

Expand Down
4 changes: 1 addition & 3 deletions test/functional/test_framework/wallet_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down