Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify exactly which scripts are witness outputs #1537

Merged
merged 1 commit into from Apr 26, 2024

Conversation

sipa
Copy link
Member

@sipa sipa commented Jan 8, 2024

No description provided.

@josibake
Copy link
Member

josibake commented Jan 8, 2024

ACK ff9feab

LGTM, clears up the confusion I had regarding OP_PUSHBYTES_x vs OP_PUSHDATA1 x.

bip-0141.mediawiki Outdated Show resolved Hide resolved
@sipa sipa force-pushed the 202401_clarify_segwit_direct_push branch from ff9feab to 50e750a Compare April 26, 2024 12:27
@sipa
Copy link
Member Author

sipa commented Apr 26, 2024

Rebased after the merge of #487. I believe the text here contains further improvements.

@@ -83,19 +83,23 @@ If all transactions in a block do not have witness data, the commitment is optio

=== Witness program ===

A <code>scriptPubKey</code> (or <code>redeemScript</code> as defined in BIP16/P2SH) that consists of a select subset of opcodes (<code>OP_0,OP_1,OP_2,...,OP_16</code>) followed by a data push between 2 and 40 bytes gets a new special meaning. The value of the first push is called the "version byte". The following byte vector pushed is called the "witness program".
A <code>scriptPubKey</code> (or <code>redeemScript</code> as defined in BIP16/P2SH) that consists of a 1-byte push opcode (one of <code>OP_0,OP_1,OP_2,...,OP_16</code>) followed by a direct data push between 2 and 40 bytes gets a new special meaning. The value of the first push is called the "version byte". The following byte vector pushed is called the "witness program".
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure about the added word "direct" here. Perhaps "canonical" or "minimal" would be clearer?

Copy link
Member Author

@sipa sipa Apr 26, 2024

Choose a reason for hiding this comment

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

These are the terms as I use them. Bitcoin script knows 3 types of pushes:

  • The OP_n opcodes (0x4f through 0x60, inclusive)
  • The direct pushes (0x01 through 0x4b)
  • The OP_PUSHDATA opcodes (0x4c through 0x4e)

By "minimal push" I understand "whichever of those 3 types that is applicable and minimal in encoded size". It happens to be the case that in this context (for pushes of 2 to 40 bytes) the direct push is always the minimal one, but that seems like a very indirect way of describing it.

It's true that there isn't any well-established terminology for what I call direct pushes here, but given that it's clarified explicitly immediately after, is that an issue?

Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for the clarification, the word "direct" makes complete sense now.

@jonathancross
Copy link
Contributor

ACK 50e750a

Copy link
Contributor

@murchandamus murchandamus left a comment

Choose a reason for hiding this comment

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

ACK 50e750a

@murchandamus murchandamus merged commit d3576b9 into bitcoin:master Apr 26, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
6 participants