Skip to content

Conversation

@ryanofsky
Copy link
Contributor

@ryanofsky ryanofsky commented Sep 6, 2018

Add some implementation details, and tweak phrasing in examples section to be more explicit about how expressions are used for matching.

Add some implementation details, and tweak phrasing in examples section to be
more explicit about how script expressions are used for matching.
@fanquake fanquake added the Docs label Sep 6, 2018
@ryanofsky ryanofsky force-pushed the pr/ddoc branch 2 times, most recently from b27f440 to bce4db1 Compare September 6, 2018 17:39
@laanwj laanwj requested a review from sipa September 6, 2018 17:51
@laanwj laanwj added this to the 0.17.0 milestone Sep 6, 2018
@practicalswift
Copy link
Contributor

practicalswift commented Sep 6, 2018

Concept ACK


### Output Descriptors vs. Addresses

Like a bitcoin address, a bitcoin output descriptor can be used as a human
Copy link
Member

Choose a reason for hiding this comment

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

I think this is not a similarity but a difference: an address does not (generally) convey information on how to spend it; a descriptor does (unless raw or addr are used).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, this sentence would probably be clearer dropping "that a given wallet knows how to spend" from the end. The difference you are describing is basically difference #1 in the list below.

But I think it might be a good idea to drop this section entirely. Basically I was trying to describe the properties of descriptors by contrasting them with addresses. But I think it might be better to have a section just describing some ways descriptors can be used (internally or externally), since this is something actually I'm fuzzy on.

Copy link
Member

Choose a reason for hiding this comment

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

I suspect this will clear itself up when more uses for descriptors appear.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, just dropped this section. Pushed to ryanofsky@9592a1b for reference.

- `pk(xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8)` refers to a single P2PK output, using the public key part from the specified xpub.
- `pkh(xpub68Gmy5EdvgibQVfPdqkBBCHxA5htiqg55crXYuXoQRKfDBFA1WEjWgP6LHhwBZeNK1VTsfTFUHCdrfp1bgwQ9xv5ski8PX9rL2dZXvgGDnw/1'/2)` refers to a single P2PKH output, using child key *1'/2* of the specified xpub.
- `wsh(multi(1,xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/1/0/*,xpub69H7F5d8KSRgmmdJg2KhpAK8SR3DjMwAdkxj3ZuxV27CprR9LgpeyGmXUbC6wb7ERfvrnKZjXoUmmDznezpbZb7ap6r1D3tgFxHmwMkQTPH/1/0/*))` refers to a chain of *1-of-2* P2WSH multisig outputs, using public keys taken from two HD chains with corresponding derivation paths.
- `pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)` matches a P2PK output with the specified public key.
Copy link
Member

Choose a reason for hiding this comment

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

I haven't really thought of descriptors as "filters" that match certain sPK, more as compact descriptions for specifically instantiated scripts.

Perhaps it makes sense to describe it this way (especially in the context of scantxoutset), but perhaps it is also confusing. It may make people wonder why a range needs to be explicitly specified, or why an addr(1...) can't match a P2PK output.

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well, these edits are just suggestions. I'm happy to revert anything or change it however you'd like.

But I guess I don't really get the point about BIP32 ranges and addr() with P2PK, because it seems like you have to document the behavior either way. And in theory if we wanted to match P2PK keys & hashes, it wouldn't actually complicate the current implementation very much.

I like saying "matches" here just because "matches" is concrete. It seems clearer to say that a descriptor either "matches" or "doesn't match" a script than to say that it "represents," or "refers," or sometimes "constructs" one. But if you wanted to replace "matches" with a different concrete term like "generates" or "constructs" everywhere, I think that would be good, too.

Copy link
Member

@sipa sipa Oct 12, 2018

Choose a reason for hiding this comment

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

Ah, perhaps this isn't clear from the current implementation yet.

One of the original goals was to have an explicit representation for the actual set of scriptPubKeys that match the wallet. This would permit much faster rescans, as it avoids the need to feed every scriptPubKey seen in the chain through the IsMine machinery, and instead just test for inclusion in a set. Alternatively, it permits even faster structures such as using a bloom filter for the wallet, or using the BIP158 filters for blocks.

Having functionality in the descriptors language which just specifies a pubkey hash but encompasses P2PK outputs is not compatible with that intended feature.

Does that clear things up? If you think using the term 'matches' doesn't convey the wrong meaning taking that into account I'm fine with it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced "matches" with a "describes" in a followup commit.

After hearing about plans for the wallet, I think I now agree "matches scriptingPubKeys" is too narrow, since we're not only going to use descriptors as a way of matching tx outputs, but also as a way of generating outputs and addresses (by replacing keypools in the wallet, and serving as a bridge between wallet and the "policy language" you described at coredev).

Having functionality in the descriptors language which just specifies a pubkey hash but encompasses P2PK outputs is not compatible with that intended feature.

I didn't know about the bloom filtering idea, and I see how this does impose constraints on the types of scriptPubKeys that could be matched efficiently. I think it doesn't really have bearing on how you document the descriptor language, though. For example, we talk about matching regexes despite the fact that regex languages are limited and won't match many string patterns.

multisig policy, where any *k* out of the *n* provided public keys must
sign.

Key order is significant. A `multi()` expression will only match multisig
Copy link
Member

Choose a reason for hiding this comment

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

Big +1 on this section; that information was really missing.

@maflcko maflcko modified the milestones: 0.17.0, 0.17.1 Sep 30, 2018
@maflcko
Copy link
Member

maflcko commented Sep 30, 2018

Is this for 0.17.0? It seems it still needs some more work or feedback addressed?

@sipa
Copy link
Member

sipa commented Oct 17, 2018

@ryanofsky Ping, what do you think about my comments above?

Copy link
Contributor Author

@ryanofsky ryanofsky left a comment

Choose a reason for hiding this comment

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

Updated bce4db1 -> eeeaa29 (pr/ddoc.3 -> pr/ddoc.4) dropping address section and replacing "matches" with "describes".

- `pk(xpub661MyMwAqRbcFtXgS5sYJABqqG9YLmC4Q1Rdap9gSE8NqtwybGhePY2gZ29ESFjqJoCu1Rupje8YtGqsefD265TMg7usUDFdp6W1EGMcet8)` refers to a single P2PK output, using the public key part from the specified xpub.
- `pkh(xpub68Gmy5EdvgibQVfPdqkBBCHxA5htiqg55crXYuXoQRKfDBFA1WEjWgP6LHhwBZeNK1VTsfTFUHCdrfp1bgwQ9xv5ski8PX9rL2dZXvgGDnw/1'/2)` refers to a single P2PKH output, using child key *1'/2* of the specified xpub.
- `wsh(multi(1,xpub661MyMwAqRbcFW31YEwpkMuc5THy2PSt5bDMsktWQcFF8syAmRUapSCGu8ED9W6oDMSgv6Zz8idoc4a6mr8BDzTJY47LJhkJ8UB7WEGuduB/1/0/*,xpub69H7F5d8KSRgmmdJg2KhpAK8SR3DjMwAdkxj3ZuxV27CprR9LgpeyGmXUbC6wb7ERfvrnKZjXoUmmDznezpbZb7ap6r1D3tgFxHmwMkQTPH/1/0/*))` refers to a chain of *1-of-2* P2WSH multisig outputs, using public keys taken from two HD chains with corresponding derivation paths.
- `pk(0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798)` matches a P2PK output with the specified public key.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Replaced "matches" with a "describes" in a followup commit.

After hearing about plans for the wallet, I think I now agree "matches scriptingPubKeys" is too narrow, since we're not only going to use descriptors as a way of matching tx outputs, but also as a way of generating outputs and addresses (by replacing keypools in the wallet, and serving as a bridge between wallet and the "policy language" you described at coredev).

Having functionality in the descriptors language which just specifies a pubkey hash but encompasses P2PK outputs is not compatible with that intended feature.

I didn't know about the bloom filtering idea, and I see how this does impose constraints on the types of scriptPubKeys that could be matched efficiently. I think it doesn't really have bearing on how you document the descriptor language, though. For example, we talk about matching regexes despite the fact that regex languages are limited and won't match many string patterns.


### Output Descriptors vs. Addresses

Like a bitcoin address, a bitcoin output descriptor can be used as a human
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, just dropped this section. Pushed to ryanofsky@9592a1b for reference.

@sipa
Copy link
Member

sipa commented Oct 17, 2018

utACK

@jonasschnelli
Copy link
Contributor

utACK eeeaa29

@DrahtBot
Copy link
Contributor

Reviewers, this pull request conflicts with the following ones:

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.

@maflcko maflcko merged commit eeeaa29 into bitcoin:master Oct 21, 2018
maflcko pushed a commit that referenced this pull request Oct 21, 2018
eeeaa29 descriptors.md: Refer to descriptors as describing instead of matching (Russell Yanofsky)
eb49412 doc/descriptors.md tweaks (Russell Yanofsky)

Pull request description:

  Add some implementation details, and tweak phrasing in examples section to be more explicit about how expressions are used for matching.

Tree-SHA512: a9dc7bc0fc370548189a789f31c04bd11103cdd2a99bcb909fa1b1dfa4e78509813dad5d5c9e3db98d66929f45cb5704f5c46ab4cbd800fef22cd8465f80ef33
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Oct 25, 2018
Add some implementation details, and tweak phrasing in examples section to be
more explicit about how script expressions are used for matching.

Github-Pull: bitcoin#14161
Rebased-From: eb49412
maflcko pushed a commit to maflcko/bitcoin-core that referenced this pull request Oct 25, 2018
toxeus pushed a commit to toxeus/bitcoin that referenced this pull request Nov 28, 2018
Add some implementation details, and tweak phrasing in examples section to be
more explicit about how script expressions are used for matching.

Github-Pull: bitcoin#14161
Rebased-From: eb49412
toxeus pushed a commit to toxeus/bitcoin that referenced this pull request Nov 28, 2018
jasonbcox pushed a commit to Bitcoin-ABC/bitcoin-abc that referenced this pull request Oct 8, 2020
Summary:
eeeaa29214 descriptors.md: Refer to descriptors as describing instead of matching (Russell Yanofsky)
eb49412562 doc/descriptors.md tweaks (Russell Yanofsky)

Pull request description:

  Add some implementation details, and tweak phrasing in examples section to be more explicit about how expressions are used for matching.

---

Backport of Core [[bitcoin/bitcoin#14161 | PR14161]]

Test Plan:
  read it

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D7828
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Sep 8, 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.

9 participants