Skip to content

Conversation

achow101
Copy link
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

@DrahtBot
Copy link
Contributor

DrahtBot commented Dec 11, 2023

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.

@achow101 achow101 changed the title Descriptor sethdseed wallet: reenable sethdseed for descriptor wallets Dec 11, 2023
achow101 and others added 17 commits December 11, 2023 17:01
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.
We often need to construct a CExtKey given an CExtPubKey and CKey, so
implement a constructor that does that for us.
furszy and others added 11 commits December 19, 2023 18:27
…ster

The test creates a wallet on master, downgrades and encrypts the wallet.
Then, it tries to open it again on master.
We will need access to a function that sets up a singular
DescriptorSPKM, so refactor this out of the multiple DescriptorSPKM
setup function.
If WALLET_FLAG_HAS_HDKEY_RECORDS is already set, then it's okay to just
use the hd{c}key records.
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
@ryanofsky
Copy link
Contributor

ryanofsky commented Dec 23, 2023

EDIT: deleted comment intended for #29136, which replaces this PR

@achow101
Copy link
Member Author

achow101 commented Jan 6, 2024

Superseded by #29136

@achow101 achow101 closed this Jan 6, 2024
@bitcoin bitcoin locked and limited conversation to collaborators Jan 5, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants