Skip to content

Commit

Permalink
Clarify exactly which scripts are witness outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
sipa committed Jan 8, 2024
1 parent cdcb680 commit 7a833c1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion bip-0141.mediawiki
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,11 @@ 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 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".
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".
In more detail, this means a <code>scriptPubKey</code> or <code>redeemScript</code> which consists of (in order):
* 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).
* Then, a byte ''l'' between 0x02 (push of 2 bytes) and 0x18 (push of 40 bytes) inclusive.
* Finally, ''l'' arbitrary bytes (the witness program).
There are two cases in which witness validation logic are triggered. Each case determines the location of the witness version byte and program, as well as the form of the scriptSig:
# Triggered by a <code>scriptPubKey</code> that is exactly a push of a version byte, plus a push of a witness program. The scriptSig must be exactly empty or validation fails. (''"native witness program"'')
Expand Down

0 comments on commit 7a833c1

Please sign in to comment.