wallet: reenable sethdseed for descriptor wallets #29054

pull achow101 wants to merge 28 commits into bitcoin:master from achow101:descriptor-sethdseed changing 19 files +1174 −183
  1. achow101 commented at 8:00 pm on December 11, 2023: member

    Enable sethdseed for descriptor wallets. To be able to use createwalletdescriptor with the other address types, we need a way to change the wallet extended key, and so sethdseed has been updated and enabled for descriptor wallets. As with legacy wallets, when called without parameters, it will generate a new random master key for the wallet. It can also take a xprv and set that as the master key. It still takes a BIP 32 seed as WIF or as hex as we do for legacy wallets. The seed will be transformed into and stored as a BIP 32 extended key. The latter is to give us greater compatibility with other wallets which often produce non-WIF HD seeds.

    Split from #25907

  2. DrahtBot commented at 8:00 pm on December 11, 2023: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage

    For detailed information about the code coverage, see the test coverage report.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #bitcoin-core/gui/733 (Deniability - a tool to automatically improve coin ownership privacy by denavila)
    • #29136 (wallet: addhdkey RPC to add just keys to wallets via new void(KEY) descriptor by achow101)
    • #29130 (wallet: Add createwalletdescriptor and gethdkeys RPCs for adding new automatically generated descriptors by achow101)
    • #29124 (wallet: Automatically repair corrupted metadata with doubled derivation path by achow101)
    • #29112 (sqlite: Disallow writing from multiple SQLiteBatchs by achow101)
    • #29016 (RPC: add new listmempooltransactions by niftynei)
    • #28574 (wallet: optimize migration process, batch db transactions by furszy)
    • #28333 (wallet: Construct ScriptPubKeyMans with all data rather than loaded progressively by achow101)
    • #28142 (wallet: Allow users to create a wallet that encrypts all database records by achow101)
    • #27865 (wallet: Track no-longer-spendable TXOs separately by achow101)
    • #27792 (wallet: Deniability API (Unilateral Transaction Meta-Privacy) by denavila)
    • #27286 (wallet: Keep track of the wallet’s own transaction outputs in memory by achow101)
    • #26728 (wallet: Have the wallet store the key for automatically generated descriptors by achow101)
    • #26008 (wallet: cache IsMine scriptPubKeys to improve performance of descriptor wallets by achow101)
    • #24748 (test/BIP324: functional tests for v2 P2P encryption by stratospher)
    • #22838 (descriptors: Be able to specify change and receiving in a single descriptor string by achow101)
    • #22341 (rpc: add path to gethdkey by Sjors)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  3. achow101 renamed this:
    Descriptor sethdseed
    wallet: reenable sethdseed for descriptor wallets
    on Dec 11, 2023
  4. DrahtBot added the label Wallet on Dec 11, 2023
  5. walletdb: Read and write activehdkey record 8bb7a8b06f
  6. wallet: Load activehdkey and its private keys
    The activehdkey record will now be loaded into the wallet as its own
    member variable. Since the private keys will always be in existing
    descriptors in the wallet, the key for the active hd key is also pulled
    out of those descriptors on loading.
    2e840bcfc0
  7. wallet: Store master key used for automatically generated descriptors 2e2545c3a2
  8. wallet: Retrieve active hd pubkey 4569cb1666
  9. key: Add constructor for CExtKey that takes CExtPubKey and CKey
    We often need to construct a CExtKey given an CExtPubKey and CKey, so
    implement a constructor that does that for us.
    116a4252d6
  10. wallet: Implement GetActiveHDPrivkey 77408c0bdb
  11. wallet, rpc: Add gethdkey RPC 9b760c1049
  12. descriptor: Be able to get the pubkeys involved in a descriptor 5800b75a54
  13. wallet: Always set WALLET_FLAG_GLOBAL_HD_KEY for new wallets 4a82d27872
  14. wallet, rpc: Check WALLET_FLAG_GLOBAL_HD_KEY in gethdkey bb02b9eb94
  15. wallet: Automatically upgrade a wallet to have global hd key ce5495a4b2
  16. tests: Test for gethdkey 9ac7fe7da8
  17. test: Test automatic upgrade of descriptor wallets to have hd key 5679b4a885
  18. wallet: Set global hd key for migrated wallets 18879984d1
  19. test: Also do backwards compat test with encrypted wallets
    Best reviewed with `git show -w`
    af3667a13c
  20. walletdb: Check that unencrypted and crypted keys are mutually exclusive 1bbbb732b5
  21. test: Check that no unencrypted records persist after encrypting 291cb32237
  22. DrahtBot added the label CI failed on Dec 11, 2023
  23. achow101 marked this as a draft on Dec 12, 2023
  24. achow101 force-pushed on Dec 19, 2023
  25. achow101 force-pushed on Dec 19, 2023
  26. test: add coverage for re-opening a downgraded encrypted wallet on master
    The test creates a wallet on master, downgrades and encrypts the wallet.
    Then, it tries to open it again on master.
    db6b61e9e7
  27. wallet: Refactor function for single DescSPKM setup
    We will need access to a function that sets up a singular
    DescriptorSPKM, so refactor this out of the multiple DescriptorSPKM
    setup function.
    f4ebc290b6
  28. wallet, descspkm: Refactor wallet descriptor generation to static func 7d724083ae
  29. wallet, rpc: Add createwalletdescriptor RPC 41a7904522
  30. wallet: Test createwalletdescriptor 8123f936d1
  31. walletdb: Refactor privkey checksum calc 00f80b2311
  32. walletdb: Read, write, and load hd{c}key records 8ca5938a59
  33. wallet: Add WALLET_FLAG_HAS_HDKEY_RECORDS 7ff108bc24
  34. wallet: Write hd{c}key when HAS_HDKEY_RECORDS is set
    If WALLET_FLAG_HAS_HDKEY_RECORDS is already set, then it's okay to just
    use the hd{c}key records.
    bd491ed67c
  35. wallet: Re-enable sethdseed for descriptors wallets
    Descriptor wallets store an HD master key that is used for new
    automatically generated descriptors. sethdseed is an existing RPC that
    can be repurposed to allow the users to set that HD key whenever they
    want.
    
    Using sethdseed with a descriptor wallet sets the HAS_HDKEY_RECORDS
    flag.
    
    Also fixes the whitespace of sethdseed. Best to review this with
    --ignore-all-space
    840516148c
  36. test: Test descriptor wallet sethdseed 655c57bbe6
  37. achow101 force-pushed on Dec 19, 2023
  38. DrahtBot removed the label CI failed on Dec 20, 2023
  39. Wote74 approved
  40. ryanofsky commented at 4:39 am on December 23, 2023: contributor
    EDIT: deleted comment intended for #29136, which replaces this PR
  41. achow101 commented at 0:06 am on January 6, 2024: member
    Superseded by #29136
  42. achow101 closed this on Jan 6, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-22 06:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me