HomePhabricator

Use boost::asio::deadline_timer for walletpassphrase timeout
92f2c1fe0fe2Unpublished

Unpublished Commit ยท Learn More

Repository Importing: This repository is still importing.

Description

Use boost::asio::deadline_timer for walletpassphrase timeout

New method in bitcoinrpc: RunLater, that uses a map of deadline
timers to run a function later.

Behavior of walletpassphrase is changed; before, calling
walletpassphrase again before the lock timeout passed
would result in: Error: Wallet is already unlocked.

You would have to call lockwallet before walletpassphrase.

Now: the last walletpassphrase with correct password
wins, and overrides any previous timeout.

Fixes issue# 1961 which was caused by spawning too many threads.

Test plan:

Start with encrypted wallet, password 'foo'

NOTE: python -c 'import time; print("%d"%time.time())' ... will tell you current unix timestamp.

Try:

walletpassphrase foo 600
getinfo
EXPECT: unlocked_until is about 10 minutes in the future

walletpassphrase foo 1
sleep 2
sendtoaddress mun74Bvba3B1PF2YkrF4NsgcJwHXXh12LF 11
EXPECT: Error: Please enter the wallet passphrase with walletpassphrase first.

walletpassphrase foo 600
walletpassphrase foo 0
getinfo
EXPECT: wallet is locked (unlocked_until is 0)

walletpassphrase foo 10
walletpassphrase foo 600
getinfo
EXPECT: wallet is unlocked until 10 minutes in future

walletpassphrase foo 60
walletpassphrase bar 600
EXPECT: Error, incorrect passphrase
getinfo
EXPECT: wallet still scheduled to lock 60 seconds from first (successful) walletpassphrase

Details

Provenance
Gavin Andresen <gavinandresen@gmail.com>Authored on May 7 2013, 14:47
schancelPushed on Jan 5 2018, 21:58
schancelPushed on Jan 5 2018, 21:39
schancelPushed on Jan 5 2018, 21:17
Parents
rSTAGING9d053d170be7: Merge pull request #2621 from celeduc/master
Branches
Unknown
Tags
Unknown

Event Timeline

Gavin Andresen <gavinandresen@gmail.com> committed rSTAGING92f2c1fe0fe2: Use boost::asio::deadline_timer for walletpassphrase timeout (authored by Gavin Andresen <gavinandresen@gmail.com>).May 7 2013, 15:47