Skip to content

Commit f41d589

Browse files
author
Antoine Riard
committed
Document better -keypool as a look-ahead safety mechanism
If after a backup, an address is issued beyond the initial keypool range and none of the addresses in this range is seen onchain, if a wallet is restored from backup, even in case of rescan, funds may be loss due to the look-ahead buffer not being incremented and so restored wallet not detecting onchain out-of-range address as derived from its seed. This scenario is theoretically unavoidable due to the requirement of the keypool to have a max size. However, given the default keypool size, this is unlikely. Document better keypool size implications to avoid user setting a too low value.
1 parent 3d67527 commit f41d589

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/wallet/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void WalletInit::AddWalletOptions() const
4646

4747
gArgs.AddArg("-fallbackfee=<amt>", strprintf("A fee rate (in %s/kB) that will be used when fee estimation has insufficient data. 0 to entirely disable the fallbackfee feature. (default: %s)",
4848
CURRENCY_UNIT, FormatMoney(DEFAULT_FALLBACK_FEE)), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
49-
gArgs.AddArg("-keypool=<n>", strprintf("Set key pool size to <n> (default: %u)", DEFAULT_KEYPOOL_SIZE), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
49+
gArgs.AddArg("-keypool=<n>", strprintf("Set key pool size to <n> (default: %u). Warning: Smaller sizes may increase the risk of losing funds when restoring from an old backup, if none of the addresses in the original keypool have been used.", DEFAULT_KEYPOOL_SIZE), ArgsManager::ALLOW_ANY, OptionsCategory::WALLET);
5050
gArgs.AddArg("-maxtxfee=<amt>", strprintf("Maximum total fees (in %s) to use in a single wallet transaction; setting this too low may abort large transactions (default: %s)",
5151
CURRENCY_UNIT, FormatMoney(DEFAULT_TRANSACTION_MAXFEE)), ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
5252
gArgs.AddArg("-mintxfee=<amt>", strprintf("Fees (in %s/kB) smaller than this are considered zero fee for transaction creation (default: %s)",

src/wallet/scriptpubkeyman.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ std::vector<CKeyID> GetAffectedKeys(const CScript& spk, const SigningProvider& p
7272
* keys (by default 1000) ahead of the last used key and scans for the
7373
* addresses of those keys. This avoids the risk of not seeing transactions
7474
* involving the wallet's addresses, or of re-using the same address.
75+
* In the unlikely case where none of the addresses in the `gap limit` are
76+
* used on-chain, the look-ahead will not be incremented to keep
77+
* a constant size and addresses beyond this range will not be detected by an
78+
* old backup. For this reason, it is not recommended to decrease keypool size
79+
* lower than default value.
7580
*
7681
* The HD-split wallet feature added a second keypool (commit: 02592f4c). There
7782
* is an external keypool (for addresses to hand out) and an internal keypool

0 commit comments

Comments
 (0)