Skip to content

Commit 50f4591

Browse files
authored
Merge pull request bitcoin#459 from jl2012/segwitscript
Add policy descriptions to BIP141 and 143 and address some nits.
2 parents ed5661d + 3f59ccd commit 50f4591

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

bip-0141.mediawiki

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,12 +133,24 @@ The following definitions are not used for consensus limits, but are suggested t
133133

134134
''Transaction weight'' is defined as ''Base transaction size'' * 3 + ''Total transaction size'' (ie. the same method as calculating ''Block weight'' from ''Base size'' and ''Total size'').
135135

136-
''Virtual transaction size'' is defined as ''Transaction weight'' / 4 (rounded up to nearest integer).
136+
''Virtual transaction size'' is defined as ''Transaction weight'' / 4 (rounded up to the next integer).
137137

138-
''Base transaction size'' is the transaction size in bytes with the original transaction serialization without any witness-related data.
138+
''Base transaction size'' is the size of the transaction serialised with the witness data stripped.
139139

140140
''Total transaction size'' is the transaction size in bytes serialized as described in [[bip-0144.mediawiki|BIP144]], including base data and witness data.
141141

142+
=== New script semantics ===
143+
144+
Despite that the script language for P2WPKH and P2WSH looks very similar to pre-segregated witness script, there are several notable differences. Users MUST NOT assume that a script spendable in pre-segregated witness system would also be spendable as a P2WPKH or P2WSH script. Before large-scale deployment in the production network, developers should test the scripts on testnet with the default relay policy turned on, and with a small amount of money after BIP141 is activated on mainnet.
145+
146+
A major difference at consensus level is described in [https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki BIP143], as a new transaction digest algorithm for signature verification in version 0 witness program.
147+
148+
Three relay and mining policies are also included in the first release of segregated witness at reference implementation version 0.13.1. Softforks based on these policies are likely to be proposed in the near future. To avoid indefinite delay in transaction confirmation and permanent fund loss in a potential softfork, users MUST observe the new semantics carefully:
149+
150+
# Only compressed public keys are accepted in P2WPKH and P2WSH (See [https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki#Restrictions_on_public_key_type BIP143])
151+
# The argument of OP_IF/NOTIF in P2WSH must be minimal<ref>https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2016-August/013014.html</ref>
152+
# Signature(s) must be null vector(s) if an OP_CHECKSIG or OP_CHECKMULTISIG is failed (for both pre-segregated witness script and P2WSH. See [https://github.com/bitcoin/bips/blob/master/bip-0146.mediawiki BIP146])
153+
142154
== Examples ==
143155

144156
=== P2WPKH ===

bip-0143.mediawiki

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ Refer to the reference implementation, reproduced below, for the precise algorit
125125
return ss.GetHash();
126126
</source>
127127

128+
== Restrictions on public key type ==
129+
As a default policy, only compressed public keys are accepted in P2WPKH and P2WSH. Each public key passed to a sigop inside version 0 witness program must be a compressed key: the first byte MUST be either 0x02 or 0x03, and the size MUST be 33 bytes. Transactions that break this rule will not be relayed or mined by default.
130+
131+
Since this policy is preparation for a future softfork proposal, to avoid potential future funds loss, users MUST NOT use uncompressed keys in version 0 witness programs.
132+
128133
== Example ==
129134
=== Native P2WPKH ===
130135

@@ -538,7 +543,7 @@ As a soft fork, older software will continue to operate without modification. No
538543

539544
== Reference Implementation ==
540545

541-
https://github.com/bitcoin/bitcoin/pull/7910
546+
https://github.com/bitcoin/bitcoin/pull/8149
542547

543548
== References ==
544549

bip-0144.mediawiki

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ MSG_WITNESS_BLOCK requests will return a block message with transactions that ha
117117
Special thanks to Gregory Maxwell for originating many of the ideas in this BIP and Luke-Jr for figuring out how to deploy this as a soft fork.
118118

119119
== Reference Implementation ==
120-
https://github.com/sipa/bitcoin/commits/segwit
120+
https://github.com/bitcoin/bitcoin/pull/8149
121121

122122
== Copyright ==
123123
This document is placed in the public domain.

0 commit comments

Comments
 (0)