You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bip-0141.mediawiki
+12-15Lines changed: 12 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -108,13 +108,13 @@ If the version byte is 1 to 16, no further interpretation of the witness program
108
108
109
109
Blocks are currently limited to 1,000,000 bytes (1MB) total size. We change this restriction as follows:
110
110
111
-
''Block cost'' is defined as ''Base size'' * 3 + ''Total size''. (rationale<ref>Rationale of using a single composite constraint, instead of two separate limits such as 1MB base data and 3MB witness data: Using two separate limits would make mining and fee estimation nearly impossible. Miners would need to solve a complex non-linear optimization problem to find the set of transactions that maximize fees given both constraints, and wallets would not be able to know what to pay as it depends on which of the two conditions is most constrained by the time miners try to produce blocks with their transactions in. Another problem with such an approach is freeloading. Once a set of transactions hit the base data 1MB constraint, up to 3MB extra data could be added to the witness by just minimally increasing the fee. The marginal cost for extra witness space effectively becomes zero in that case.</ref>)
111
+
''Block weight'' is defined as ''Base size'' * 3 + ''Total size''. (rationale<ref>Rationale of using a single composite constraint, instead of two separate limits such as 1MB base data and 3MB witness data: Using two separate limits would make mining and fee estimation nearly impossible. Miners would need to solve a complex non-linear optimization problem to find the set of transactions that maximize fees given both constraints, and wallets would not be able to know what to pay as it depends on which of the two conditions is most constrained by the time miners try to produce blocks with their transactions in. Another problem with such an approach is freeloading. Once a set of transactions hit the base data 1MB constraint, up to 3MB extra data could be added to the witness by just minimally increasing the fee. The marginal cost for extra witness space effectively becomes zero in that case.</ref>)
112
112
113
113
''Base size'' is the block size in bytes with the original transaction serialization without any witness-related data, as seen by a non-upgraded node.
114
114
115
115
''Total size'' is the block size in bytes with transactions serialized as described in [[bip-0144.mediawiki|BIP144]], including base data and witness data.
116
116
117
-
The new rule is ''block cost'' ≤ 4,000,000.
117
+
The new rule is ''block weight'' ≤ 4,000,000.
118
118
119
119
==== Sigops ====
120
120
@@ -123,14 +123,13 @@ Sigops per block is currently limited to 20,000. We change this restriction as f
123
123
Sigops in the current pubkey script, signature script, and P2SH check script are counted at 4 times their previous value.
124
124
The sigop limit is likewise quadrupled to ≤ 80,000.
125
125
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.
128
127
129
128
== Examples ==
130
129
131
-
=== P2WPKH witness program ===
130
+
=== P2WPKH ===
132
131
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):
134
133
135
134
witness: <signature> <pubkey>
136
135
scriptSig: (empty)
@@ -147,7 +146,7 @@ Comparing with a traditional P2PKH output, the P2WPKH equivalent occupies 3 less
147
146
148
147
=== P2WPKH nested in BIP16 P2SH ===
149
148
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.
151
150
152
151
witness: <signature> <pubkey>
153
152
scriptSig: <0 <20-byte-key-hash>>
@@ -159,13 +158,13 @@ The only item in scriptSig is hashed with HASH160, compared against the 20-byte-
159
158
160
159
0 <20-byte-key-hash>
161
160
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.
163
162
164
163
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.
165
164
166
-
=== P2WSH witness program ===
165
+
=== P2WSH ===
167
166
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).
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.
184
183
185
184
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.
186
185
187
186
=== P2WSH nested in BIP16 P2SH ===
188
187
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.
@@ -198,7 +197,7 @@ The only item in scriptSig is hashed with HASH160, compared against the 20-byte-
198
197
199
198
0 <32-byte-hash>
200
199
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.
202
201
203
202
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.
204
203
@@ -249,8 +248,6 @@ Since a version byte is pushed before a witness program, and programs with unkno
249
248
250
249
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.
251
250
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
-
254
251
=== Per-input lock-time and relative-lock-time ===
255
252
256
253
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