HomePhabricator

Clamp walletpassphrase timeout to 2^(30) seconds and check its bounds

Description

Clamp walletpassphrase timeout to 2^(30) seconds and check its bounds

Summary:

Clamps the timeout of walletpassphrase to 2^(30) seconds, which is
~34 years. Any number greater than that will be forced to be
2^(30). This avoids the sign flipping problem with large values which
can result in a negative time used.

Also perform bounds checks to ensure that the timeout is positive
to avoid immediate relocking of the wallet.

Backport of core PR12101 and PR12905 (fix for OSX)
https://github.com/bitcoin/bitcoin/pull/12101/files
https://github.com/bitcoin/bitcoin/pull/12905/files

Due to the fix from D2633 enabling mocktime, the test will fail using
time.time() as a reference. The mocktime is used instead to get rid of
the issue.

Test Plan:

./test/functional/test_runner.py wallet_encryption

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D3434

Details

Provenance
Andrew Chow <achow101-github@achow101.com>Authored on Jan 6 2018, 07:07
FabienCommitted on Jul 1 2019, 06:26
FabienPushed on Jul 1 2019, 06:26
Reviewer
Restricted Project
Differential Revision
D3434: Clamp walletpassphrase timeout to 2^(30) seconds and check its bounds
Parents
rABCf9869acaa5bc: test: Fix dangling wallet pointer in vpwallets
Branches
Unknown
Tags
Unknown