Skip to content

Commit ae9947f

Browse files
committed
Merge pull request bitcoin#289 from jl2012/patch-6
Tidy up Witness Program section
2 parents a849f8c + 1a3eaae commit ae9947f

File tree

1 file changed

+7
-11
lines changed

1 file changed

+7
-11
lines changed

bip-0141.mediawiki

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,17 @@ If there are more than one scriptPubKey matching the pattern, the one with highe
5757

5858
A scriptPubKey (or redeemScript 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 32 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".
5959

60-
Witness verification logic is either
61-
# triggered by a scriptPubKey that is exactly a push of a version byte, plus a push of a witness program, or
62-
# triggered when a scriptPubKey is a P2SH script, and the BIP16 redeemScript pushed in the scriptSig is exactly a push of a version byte plus a push of a witness program.
60+
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:
61+
# Triggered by a scriptPubKey that is exactly a push of a version byte, plus a push of a witness program. The scriptSig must be exactly empty.
62+
# Triggered when a scriptPubKey is a P2SH script, and the BIP16 redeemScript pushed in the scriptSig is exactly a push of a version byte plus a push of a witness program. The scriptSig must be exactly a push of the BIP16 redeemScript.
6363
64-
New rules for scriptSig:
65-
* In case 1, the scriptSig must be exactly empty.
66-
* In case 2, the scriptSig must be exactly a push of the BIP16 redeemScript.
67-
68-
If the version byte is 0, and the witness program is 20 bytes,
64+
If the version byte is 0, and the witness program is 20 bytes:
6965
* It is interpreted as a pay-to-witness-public-key-hash (P2WPKH) program.
70-
* The witness must consist of exactly 2 items. The first one is a signature, and the second one is a public key.
71-
* HASH160 of the public key must match the 20-byte witness program.
66+
* The witness must consist of exactly 2 items. The first one a signature, and the second one a public key.
67+
* The HASH160 of the public key must match the 20-byte witness program.
7268
* After normal script evaluation, the signature is verified against the public key with CHECKSIG operation. The verification must result in a single TRUE on the stack.
7369
74-
If the version byte is 0, and the witness program is 32 bytes,
70+
If the version byte is 0, and the witness program is 32 bytes:
7571
* It is interpreted as a pay-to-witness-script-hash (P2WSH) program.
7672
* The witness must consist of an input stack to feed to the script, followed by a serialized script ("witnessScript").
7773
* The witnessScript is popped off the initial witness stack. SHA256 of the witnessScript must match the 32-byte witness program.

0 commit comments

Comments
 (0)