Clarify exactly which scripts are witness outputs #1537

pull sipa wants to merge 1 commits into bitcoin:master from sipa:202401_clarify_segwit_direct_push changing 1 files +7 −3
  1. sipa commented at 6:10 PM on January 8, 2024: member

    No description provided.

  2. josibake commented at 6:33 PM on January 8, 2024: member

    ACK https://github.com/bitcoin/bips/pull/1537/commits/ff9feab538e7f814a694ad92f4487f998649b920

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

  3. in bip-0141.mediawiki:89 in ff9feab538 outdated
      82 | @@ -83,19 +83,23 @@ If all transactions in a block do not have witness data, the commitment is optio
      83 |  
      84 |  === Witness program ===
      85 |  
      86 | -A <code>scriptPubKey</code> (or <code>redeemScript</code> as defined in BIP16/P2SH) that consists of a 1-byte push opcode (for 0 to 16) 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".
      87 | +A <code>scriptPubKey</code> (or <code>redeemScript</code> as defined in BIP16/P2SH) that consists of a 1-byte push opcode (<code>OP_0</code> through <code>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".
      88 | +In more detail, this means a <code>scriptPubKey</code> or <code>redeemScript</code> which consists of (in order):
      89 | +* First, byte 0x00 (<code>OP_0</code>) or any byte between 0x51 (<code>OP_1</code>) and 0x60 (<code>OP_16</code>) inclusive (the version byte).
      90 | +* Then, a byte ''L'' between 0x02 (push of 2 bytes) and 0x18 (push of 40 bytes) inclusive.
    


    ajtowns commented at 5:28 AM on January 14, 2024:

    0x18 should be 0x28 presumably


    sipa commented at 12:27 PM on April 26, 2024:

    Fixed.

  4. Clarify exactly which scripts are witness outputs 50e750a882
  5. sipa force-pushed on Apr 26, 2024
  6. sipa commented at 12:29 PM on April 26, 2024: member

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

  7. in bip-0141.mediawiki:86 in 50e750a882
      82 | @@ -83,19 +83,23 @@ If all transactions in a block do not have witness data, the commitment is optio
      83 |  
      84 |  === Witness program ===
      85 |  
      86 | -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".
      87 | +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".
    


    vostrnad commented at 12:35 PM on April 26, 2024:

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


    sipa commented at 12:54 PM on April 26, 2024:

    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?


    vostrnad commented at 1:44 PM on April 26, 2024:

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

  8. murchandamus approved
  9. murchandamus commented at 9:25 PM on April 26, 2024: contributor

    ACK 50e750a882f525cc9a297b75ca35682f3deb1f95

  10. murchandamus merged this on Apr 26, 2024
  11. murchandamus closed this on Apr 26, 2024


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-01 20:10 UTC

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