Skip to content

Conversation

@Sjors
Copy link
Member

@Sjors Sjors commented Feb 26, 2019

Introduces a non-backwards compatible wallet type which contains a set of output descriptors.

A new RPC method importdescriptor works like importmulti but for one descriptor at a time and with fewer options.

Each wallet descriptor has a purpose: current receive, current change, archive (receive & change)

The current receive and change purposes can have one descriptor with address type bech32 and one with address type base58. It builds on top of #15590 for that.

getnewaddress finds correct receive descriptor based on address type, which must be either bech32 or legacy (base58).

Usage:

bitcoin-cli createwallet true true true
bitcoin-cli importdescriptor "wpkh([00000000/84h/1h/0h]tpub.../1/*)#...."
bitcoin-cli importdescriptor "wpkh([00000000/84h/1h/0h]tpub.../1/*)#..." '{"internal": true}, "timestamp": "now"}' 
bitcoin-cli getnewaddress "SegWit"
bitcoin-cli importdescriptor "sh(wpkh([00000000/49h/1h/0h]tpub.../1/*))#...."
bitcoin-cli getnewaddress "Pre SegWit" legacy
bitcoin-cli dumpwallet "dump" # only way to see the descriptors at the moment

This initial version will have several limitations (ignoring the TODO list below). It paves the way towards usage with hardware wallets in #14912.

  • only available through createwallet followed by importdescriptor
  • no upgrade path yet
  • no private keys allowed
  • doesn't serialise descriptor cache

TODO:

  • fix methods that deal with labels
  • fix signmessage
  • fix getrawchangeaddress
  • improve getwalletinfo
  • decide on descriptor serialization (currently stores a string)

For followup PR:

  • (re)scan wallet transactions matching descriptor
  • transaction creation (e.g. get change address from change descriptor)
  • private key support
  • multisig support

@DrahtBot
Copy link
Contributor

DrahtBot commented Feb 26, 2019

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #15463 (rpc: Speedup getaddressesbylabel by promag)
  • #15452 (Replace CScriptID and CKeyID in CTxDestination with dedicated types by instagibbs)
  • #15129 (rpc: Added ability to remove watch only addresses by benthecarman)
  • #15112 (build: Optionally enable -Wzero-as-null-pointer-constant by Empact)
  • #15006 (Add option to create an encrypted wallet by achow101)
  • #13756 (wallet: "avoid_reuse" wallet flag for improved privacy by kallewoof)
  • #12419 (Force distinct destinations in CWallet::CreateTransaction by promag)

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.

@Sjors Sjors force-pushed the 2019/02/descriptor-wallet branch 3 times, most recently from 6457e69 to df79475 Compare February 28, 2019 13:11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: ;; at end of line :-)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be const?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Just return LoadDescriptor(nID, std::move(desc));?

@sipa
Copy link
Member

sipa commented Feb 28, 2019

@practicalswift There is absolutely no point in giving coding nits on a PR that is just at a proof of concept stage like this.

@practicalswift
Copy link
Contributor

practicalswift commented Feb 28, 2019

@sipa Oh, personally I'm very happy as a PR author when reviewers take time to point out areas of improvement (large or small) or small mistakes in my code also in the WIP stage. In the event that I find a particular nit irrelevant or premature I would simply hit "Resolve conversation" and be done with it.

What do you think @Sjors?

@practicalswift
Copy link
Contributor

practicalswift commented Feb 28, 2019

Perhaps "Draft pull requests" could be used to opt out of any code feedback:

When you create a pull request, you can choose to create a pull request that is ready for review or a draft pull request. […] When you're ready to get feedback on your draft pull request, you can mark your pull request as ready for review.

Either way it would be nice to have something something similar to the developer notes for review work with clearly stated rationales for the guidelines.

@Sjors
Copy link
Member Author

Sjors commented Mar 1, 2019

I don't mind and usually just fix it in the next update, but whether it's useful depends on the type of nit.

Semi columns, whitespace, consts and return value stuff feedback is not useful imo, because those things are likely to be moved around. I suggest holding on off on those until I remove the WIP label. My own standard for WIP is anything that compiles and works in the happy-case scenario.

What I find more useful is help like "don't use unique_ptr in this way", or suggestions anywhere I put "TODO: this is terrible".

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@practicalswift e.g. this is the kind of thing I find feedback more useful on in the WIP stage

@ryanofsky
Copy link
Contributor

I took a look at this, and it seems well structured. I'm curious what the first use-case will be. Or I guess what's the minimum thing that needs that needs to be implemented here for this to be useful for hardware wallets and #14912? Current state as of df794753284cc1bd991a5cdf0bd747fffb1db3b9 seems to be that a descriptor wallet is a blank wallet that you're allowed to import public key descriptors to, without them being used for anything yet.

It does seem to me that the flag stuff might be overkill. I don't think we need a new flag or changes to createwallet now that we already have blank wallets. It looks like WALLET_FLAG_DESCRIPTOR_WALLET just creates a lot of new branches all over the code that don't need to exist or could be replaced with !m_descriptors.empty().

@Sjors
Copy link
Member Author

Sjors commented Mar 1, 2019

The reason for the flag is to prevent "legacy" keys from getting mixed with descriptors. Maybe later on I discover that such mixing is fine, then I can drop the flag.

Also note that the blank flag goes away when you add a key. Which reminds me that it should also go away when you add a descriptor; that's missing in this version.

@Sjors Sjors force-pushed the 2019/02/descriptor-wallet branch 2 times, most recently from 2adbe65 to aa03f8e Compare March 20, 2019 19:39
@Sjors Sjors force-pushed the 2019/02/descriptor-wallet branch from aa03f8e to a29ff2c Compare March 21, 2019 10:31
@Sjors Sjors force-pushed the 2019/02/descriptor-wallet branch from e192f02 to 4e4063d Compare March 21, 2019 18:18
@Sjors Sjors force-pushed the 2019/02/descriptor-wallet branch from 4e4063d to ad60f1e Compare March 21, 2019 18:41
@DrahtBot
Copy link
Contributor

Needs rebase

@Sjors
Copy link
Member Author

Sjors commented Jun 6, 2019

Closing in favor of @achow101's #15764 which has better momentum.

@Sjors Sjors closed this Jun 6, 2019
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Dec 16, 2021
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.

7 participants