elements/src/wallet
Samuel Dobson ccd85b57af
Merge #17681: wallet: Keep inactive seeds after sethdseed and derive keys from them as needed
1ed52fbb4d Remove IBD check in sethdseed (Andrew Chow)
b1810a145a Test that keys from inactive seeds are generated (Andrew Chow)
c93082ece4 Generate new keys for inactive seeds after marking used (Andrew Chow)
45f2f6a0e8 Determine inactive HD seeds from key metadata and track them in LegacyScriptPubKeyMan (Andrew Chow)
b59b4504ab have GenerateNewKey and DeriveNewChildKey take a CHDChain as an argument (Andrew Chow)

Pull request description:

  Largely implements the suggestion from https://github.com/bitcoin/bitcoin/pull/17484#issuecomment-560845316.

  After `sethdseed` is called, the CHDChain for the old seed is kept in the wallet. It is kept on the file as a new `inactivehdseed` record and in memory in a map `m_inactive_hd_seeds`. In `LegacyScriptPubKeyMan::MarkUnusedAddresses` we check each used key's metadata for whether it was derived from an inactive seed. If it is, we then check to see how many keys after that key were derived from the inactive seed. If that number does not match the keypool parameter, we derive more keys from the inactive seed until it does match. This way we won't miss transactions belonging to keys outside of the range of the keypool initially.

  The indexes and internal-ness of a key is gotten by checking it's key origin data.

  Because of this change, we no longer need to wait for IBD to finish before `sethdseed` can work so that check is also removed.

  A test case for this is added as well which fails on master.

ACKs for top commit:
  ryanofsky:
    Code review ACK 1ed52fbb4d. Changes since last review: various commit message, code comment, log message, error checking improvements, and fix for topping up inactive seeds if wallet isn't reloaded after calling sethdseed and test for this
  ariard:
    Code Review ACK 1ed52fb
  jonatack:
    ACK 1ed52fbb4d thanks for addressing the previous review feedback; would be happy to see the new review questions answered and feedback addressed and re-ack.

Tree-SHA512: e658ae0e1dab94be55d2b62cdda506c94815e73a6881533fd30d41cc77477f82fee2095144957a3a1df0c129e256bdd7b7abe3737d515f393610446cae4edf1c
2020-05-22 13:48:26 +12:00
..
test refactor: Pass NodeContext to RPC and REST methods through util::Ref 2020-05-13 16:20:13 -04:00
coincontrol.cpp scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
coincontrol.h refactor: Nuke coincontrol circular dependency 2019-11-23 08:30:03 +02:00
coinselection.cpp bnb: exit selection when best_waste is 0 2020-03-04 16:35:15 -05:00
coinselection.h amount: Move CAmount CENT to unit test header 2018-09-17 14:34:56 -04:00
crypter.cpp Fix occurences of c_str() used with size() to data() 2019-10-28 13:41:45 +01:00
crypter.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
db.cpp refactor: Add BerkeleyDatabaseVersion() function 2020-05-11 20:42:55 +03:00
db.h build: Enable -Wsuggest-override 2020-05-12 18:03:39 +03:00
feebumper.cpp wallet: Remove trailing whitespace from potential translation strings 2020-05-01 07:41:32 -04:00
feebumper.h wallet: Avoid translating RPC errors when creating txs 2020-05-01 07:39:06 -04:00
fees.cpp Remove unused includes 2019-10-15 22:56:43 +00:00
fees.h Remove uses of fee globals in wallet code 2019-02-22 15:43:02 -04:00
init.cpp Make InitError bilingual 2020-05-05 04:46:04 +03:00
ismine.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
load.cpp gui: Do not translate InitWarning messages in debug.log 2020-05-10 18:01:28 +03:00
load.h wallet: Fix documentation around WalletParameterInteraction 2019-09-03 14:10:25 -04:00
rpcdump.cpp Remove CWalletTx merging logic from AddToWallet 2020-05-01 05:59:09 -05:00
rpcwallet.cpp Merge #17681: wallet: Keep inactive seeds after sethdseed and derive keys from them as needed 2020-05-22 13:48:26 +12:00
rpcwallet.h scripted-diff: Bump copyright headers 2020-04-16 13:33:09 -04:00
scriptpubkeyman.cpp Merge #17681: wallet: Keep inactive seeds after sethdseed and derive keys from them as needed 2020-05-22 13:48:26 +12:00
scriptpubkeyman.h Merge #17681: wallet: Keep inactive seeds after sethdseed and derive keys from them as needed 2020-05-22 13:48:26 +12:00
wallet.cpp [wallet] remove nLastResend logic 2020-05-17 17:52:11 -07:00
wallet.h [wallet] remove nLastResend logic 2020-05-17 17:52:11 -07:00
walletdb.cpp Merge #17681: wallet: Keep inactive seeds after sethdseed and derive keys from them as needed 2020-05-22 13:48:26 +12:00
walletdb.h Merge #17681: wallet: Keep inactive seeds after sethdseed and derive keys from them as needed 2020-05-22 13:48:26 +12:00
wallettool.cpp wallet: Report full error message in wallettool 2020-05-01 07:39:35 -04:00
wallettool.h scripted-diff: Bump copyright of files changed in 2019 2019-12-30 10:42:20 +13:00
walletutil.cpp Correctly check for default wallet 2020-04-23 13:59:48 -04:00
walletutil.h wallet: Make sure no WalletDescriptor members are uninitialized after construction 2020-04-27 14:20:26 +00:00