Skip to content

Commit 850d103

Browse files
authored
Merge pull request bitcoin#416 from jl2012/patch-26
BIP141 fix
2 parents 76e29be + 55c3d80 commit 850d103

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

bip-0141.mediawiki

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -123,14 +123,13 @@ Sigops per block is currently limited to 20,000. We change this restriction as f
123123
Sigops in the current pubkey script, signature script, and P2SH check script are counted at 4 times their previous value.
124124
The sigop limit is likewise quadrupled to ≤ 80,000.
125125

126-
In addition, opcodes within the witness program are counted identical to as previously within the P2SH check script.
127-
That is, CHECKSIG in a witness program is counted as only 1 sigop, and CHECKMULTISIG in a witness program is counted as 1 to 20 sigops according to the arguments. This rule applies to both native witness program and P2SH witness program.
126+
Each P2WPKH input is counted as 1 sigop. In addition, opcodes within a P2WSH <code>witnessScript</code> are counted identically as previously within the P2SH <code>redeemScript</code>. That is, CHECKSIG is counted as only 1 sigop, and CHECKMULTISIG is counted as 1 to 20 sigops according to the arguments. This rule applies to both native witness program and P2SH witness program.
128127

129128
== Examples ==
130129

131-
=== P2WPKH witness program ===
130+
=== P2WPKH ===
132131

133-
The following example is a version 0 pay-to-witness-public-key-hash (P2WPKH) witness program:
132+
The following example is a version 0 pay-to-witness-public-key-hash (P2WPKH):
134133

135134
witness: <signature> <pubkey>
136135
scriptSig: (empty)
@@ -147,7 +146,7 @@ Comparing with a traditional P2PKH output, the P2WPKH equivalent occupies 3 less
147146

148147
=== P2WPKH nested in BIP16 P2SH ===
149148

150-
The following example is the same P2WPKH witness program, but nested in a BIP16 P2SH output.
149+
The following example is the same P2WPKH, but nested in a BIP16 P2SH output.
151150

152151
witness: <signature> <pubkey>
153152
scriptSig: <0 <20-byte-key-hash>>
@@ -159,13 +158,13 @@ The only item in scriptSig is hashed with HASH160, compared against the 20-byte-
159158

160159
0 <20-byte-key-hash>
161160
162-
The P2WPKH witness program is then executed as described in the previous example.
161+
The public key and signature are then verified as described in the previous example.
163162

164163
Comparing with the previous example, the scriptPubKey is 1 byte bigger and the scriptSig is 23 bytes bigger. Although a nested witness program is less efficient, its payment address is fully transparent and backward compatible for all Bitcoin reference client since version 0.6.0.
165164

166-
=== P2WSH witness program ===
165+
=== P2WSH ===
167166

168-
The following example is an 1-of-2 multi-signature version 0 pay-to-witness-script-hash (P2WSH) witness program.
167+
The following example is an 1-of-2 multi-signature version 0 pay-to-witness-script-hash (P2WSH).
169168

170169
witness: 0 <signature1> <1 <pubkey1> <pubkey2> 2 CHECKMULTISIG>
171170
scriptSig: (empty)
@@ -180,13 +179,13 @@ The script is executed with the remaining data from witness:
180179

181180
0 <signature1> 1 <pubkey1> <pubkey2> 2 CHECKMULTISIG
182181
183-
A P2WSH witness program allows arbitrarily large script as the 520-byte push limit is bypassed.
182+
P2WSH allows maximum script size of 10,000 bytes, as the 520-byte push limit is bypassed.
184183

185184
The scriptPubKey occupies 34 bytes, as opposed to 23 bytes of BIP16 P2SH. The increased size improves security against possible collision attacks, as 2<sup>80</sup> work is not infeasible anymore (By the end of 2015, 2<sup>84</sup> hashes have been calculated in Bitcoin mining since the creation of Bitcoin). The spending script is same as the one for an equivalent BIP16 P2SH output but is moved to witness.
186185

187186
=== P2WSH nested in BIP16 P2SH ===
188187

189-
The following example is the same 1-of-2 multi-signature P2WSH witness program, but nested in a BIP16 P2SH output.
188+
The following example is the same 1-of-2 multi-signature P2WSH script, but nested in a BIP16 P2SH output.
190189

191190
witness: 0 <signature1> <1 <pubkey1> <pubkey2> 2 CHECKMULTISIG>
192191
scriptSig: <0 <32-byte-hash>>
@@ -198,7 +197,7 @@ The only item in scriptSig is hashed with HASH160, compared against the 20-byte-
198197

199198
0 <32-byte-hash>
200199
201-
The P2WSH witness program is then executed as described in the previous example.
200+
The P2WSH witnessScript is then executed as described in the previous example.
202201

203202
Comparing with the previous example, the scriptPubKey is 11 bytes smaller (with reduced security) while witness is the same. However, it also requires 35 bytes in scriptSig.
204203

@@ -249,8 +248,6 @@ Since a version byte is pushed before a witness program, and programs with unkno
249248

250249
Examples of new script system include Schnorr signatures which reduce the size of multisig transactions dramatically, Lamport signature which is quantum computing resistance, and Merklized abstract syntax trees which allow very compact witness for conditional scripts with extreme complexity.
251250

252-
The 32-byte limitation for witness program could be easily extended through a soft fork in case a stronger hash function is needed in the future. The version byte is also expandable through a softfork.
253-
254251
=== Per-input lock-time and relative-lock-time ===
255252

256253
Currently there is only one nLockTime field in a transaction and all inputs must share the same value. [https://github.com/bitcoin/bips/blob/master/bip-0068.mediawiki BIP68] enables per-input relative-lock-time using the nSequence field, however, with a limited lock-time period and resolution.

0 commit comments

Comments
 (0)