bitcoin/src/wallet
laanwj 267917f563
Merge bitcoin/bitcoin#23304: wallet: Derive inactive HD chains in additional places
c4d76c6faa tests: Tests for inactive HD chains (Andrew Chow)
8077862c5e wallet: Refactor TopUp to be able to top up inactive chains too (Andrew Chow)
70134eb34f wallet: Properly set hd chain counters when loading (Andrew Chow)
961b9e4e40 wallet: Parse hdKeypath if key_origin is not available (Andrew Chow)
0652ee73ec Add size check on meta.key_origin.path (Rob Fielding)

Pull request description:

  Currently inactive HD chains are only derived from at the time a key in that chain is found to have been used. However, at that time, the wallet may not be able to derive keys (e.g. it is locked). Currently we would just move on and not derive any new keys, however this could result in missing funds.

  This PR resolves this problem by adding memory only variables to `CHDChain` which track the highest known index. `TopUp` is modified to always try to top up the inactive HD chains, and this process will use the new variables to determine how much to top up. In this way, after an encrypted wallet is unlocked, the inactive HD chains will be topped up and hopefully funds will not be missed.

  Note that because these variables are not persisted to disk (because `CHDChain`s for inactive HD chains are not written to disk), if an encrypted wallet is not unlocked in the same session as a key from an inactive chain is found to be used, then it will not be topped up later unless more keys are found.

  Additionally, wallets which do not have upgraded key metadata will not derive any keys from inactive HD chains. This is resolved by using the derivation path string in `CKeyMetadata.hdKeypath` to determine what indexes to derive.

ACKs for top commit:
  laanwj:
    Code review ACK c4d76c6faa

Tree-SHA512: b2b572ad7f1b1b2847edece09f7583543d63997e18ae32764e5a27ad608dd64b9bdb2d84ea27137894e986a8e82f047a3dba9c8015b74f5f179961911f0c4095
2022-03-02 09:35:07 +01:00
..
rpc Replace "can not" with "cannot" in docs, user messages, and tests 2022-02-21 19:07:29 +01:00
test doc: Fix typos 2022-02-17 03:42:08 +09:00
bdb.cpp refactor: replace boost::filesystem with std::filesystem 2022-02-03 18:35:52 +08:00
bdb.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
coincontrol.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
coincontrol.h wallet: add input weights to CCoinControl 2022-01-24 11:23:31 -05:00
coinselection.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
coinselection.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
context.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
context.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
crypter.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
crypter.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
db.cpp refactor: replace boost::filesystem with std::filesystem 2022-02-03 18:35:52 +08:00
db.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
dump.cpp refactor: replace boost::filesystem with std::filesystem 2022-02-03 18:35:52 +08:00
dump.h refactor: replace boost::filesystem with std::filesystem 2022-02-03 18:35:52 +08:00
external_signer_scriptpubkeyman.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
external_signer_scriptpubkeyman.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
feebumper.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
feebumper.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
fees.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
fees.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
init.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
interfaces.cpp interfaces: Remove unused is_final 2022-01-14 11:28:45 +01:00
ismine.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
load.cpp Use ArgsManager::GetPathArg() for "-walletdir" option 2022-02-09 19:31:23 +02:00
load.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
receive.cpp wallet: Avoid dropping confirmed coins 2022-01-25 10:15:12 +01:00
receive.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
salvage.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
salvage.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
scriptpubkeyman.cpp Merge bitcoin/bitcoin#23304: wallet: Derive inactive HD chains in additional places 2022-03-02 09:35:07 +01:00
scriptpubkeyman.h Merge bitcoin/bitcoin#23304: wallet: Derive inactive HD chains in additional places 2022-03-02 09:35:07 +01:00
spend.cpp User-facing content fixups from transifex translator feedback 2022-02-17 12:59:30 +01:00
spend.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
sqlite.cpp Merge bitcoin/bitcoin#23438: refactor: Use spans of std::byte in serialize 2022-01-27 19:19:12 +01:00
sqlite.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
transaction.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
transaction.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
wallet.cpp Merge bitcoin/bitcoin#24401: wallet: Add external-signer-support specific error message 2022-02-23 17:19:49 -05:00
wallet.h wallet: Allow user specified input size to override 2022-01-24 11:23:31 -05:00
walletdb.cpp Merge bitcoin/bitcoin#23304: wallet: Derive inactive HD chains in additional places 2022-03-02 09:35:07 +01:00
walletdb.h Merge bitcoin/bitcoin#23304: wallet: Derive inactive HD chains in additional places 2022-03-02 09:35:07 +01:00
wallettool.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
wallettool.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
walletutil.cpp Use ArgsManager::GetPathArg() for "-walletdir" option 2022-02-09 19:31:23 +02:00
walletutil.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00