Adds a BIP specifying PSBT version 2, as discussed on the mailing list: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-December/018300.html
This requires the formatting changes to BIP 174 to be merged first: #1055
Adds a BIP specifying PSBT version 2, as discussed on the mailing list: https://lists.linuxfoundation.org/pipermail/bitcoin-dev/2020-December/018300.html
This requires the formatting changes to BIP 174 to be merged first: #1055
Needs a backward compatibility section
Needs a backward compatibility section
There's a Compatibility section.
Would be nice to have it named per BIP 2
Let's use BIP number 370
Would be nice to have it named per BIP 2
Let's use BIP number 370
Done.
101 | +| Transaction Modifiable Flags 102 | +| <tt>PSBT_GLOBAL_TX_MODIFIABLE = 0x06</tt> 103 | +| None 104 | +| No key data 105 | +| <tt><8-bit uint></tt> 106 | +| An 8 bit little endian unsigned integer as a bitfield for various transaction modification flags. Bit 0 is the Inputs Modifiable Flag and indicates whether inputs can be modified. Bit 1 is the Outputs Modifiable Flag and indicates whether outputs can be modified. Bit 2 is the Has SIGHASH_SINGLE flag and indicates whether the transaction has a SIGHASH_SINGLE signature who's input and output pairing must be preserved. Bits 2 and 3 essentially indicate that the Constructor must iterate the inputs to determine whether and how to add an input.
Bits 2 and 3 indicate
I think this should be Bits 0 and 2?
Just bit 2. Fixed.
189 | +| Output Amount 190 | +| <tt>PSBT_OUT_AMOUNT = 0x03</tt> 191 | +| None 192 | +| No key data 193 | +| <tt><64-bit uint></tt> 194 | +| 64 bit signed little endian integer representing the output's amount in satoshis.
64-bit uint inconsistent with the description 64 bit signed little-endian. I think it should 64-bit int
Done
230 | + 231 | +===Creator=== 232 | + 233 | +In PSBTv2, the Creator initializes the PSBT with 0 inputs and 0 outputs. 234 | +The PSBT version number is set to 2. The transaction version number must be set to at least 2. <ref>'''Why does the transaction version number need to be at least 2?''' The transaction version number is part of the validation rules for some features such as OP_CHECKSEQUENCEVERIFY. Since it is backwards compatible, and there are other ways to disable those features (e.g. through sequence numbers), it is easier to require transactions be able to support these features than to try to negotiate the transaction version number.</ref> 235 | +The Creator should also PSBT_GLOBAL_PREFERRED_LOCKTIME.
Incomplete sentence. Missing specify/set.
Done
247 | +When an input or output is added, the corresponding PSBT_GLOBAL_INPUT_COUNT or PSBT_GLOBAL_OUTPUT_COUNT must be incremeted to reflect the number of inputs and outputs in the PSBT. 248 | +When an input is added, it must have PSBT_IN_PREVIOUS_TXID and PSBT_IN_OUTPUT_INDEX set. 249 | +When an output is added, it must have PSBT_OUT_VALUE and PSBT_OUT_OUTPUT_SCRIPT set. 250 | +If the input has a required timelock, Constructors must set the requisite timelock field. 251 | +If the input has a required time based timelock, then PSBT_IN_REQUIRED_TIME_TIMELOCK. 252 | +If the input has a required height based timelock, then PSBT_IN_REQUIRED_HEIGHT_TIMELOCK.
Incomplete sentences for PSBT_IN_REQUIRED_*_LOCKTIME
Fixed
256 | +If an input being added specifies a required time lock, then the Constructor must iterate through all of the existing inputs and ensure that the time lock types are compatible. 257 | +Additionally, if during this iteration, it finds that any inputs have signatures, it must ensure that the newly added input does not change the transaction's locktime. 258 | +If the newly added input has an incompatible time lock, then it must not be added. 259 | +If it changes the transaction's locktime when there are existing signatures, it must not be added. 260 | + 261 | +If the Has SIGHASH_SINGLE flag is True, then the Constructor must iterate through the inputs and find the inputs which have signatures that use SIGHASH_SINGLE.
Incomplete sentence, If the PSBT_GLOBAL_TX_MODIFIABLE field has
Has SIGHASH_SINGLE flag is the noun in this sentence.
495 | +| Output Amount 496 | +| <tt>PSBT_OUT_AMOUNT = 0x03</tt> 497 | +| None 498 | +| No key data 499 | +| <tt><64-bit uint></tt> 500 | +| 64 bit signed little endian integer representing the output's amount in satoshis.
same comment about signed/unsigned
Fixed.
ACK b3d224f384f3bae6e38d4fcf0028b046b414784b.
We will probably implement this in rust-bitcoin and cross check once we have test-vectors.
Previously these tests were using 0x0f as the unknown field number. As
these have now been defined, change them to use 0xf0 instead as it is
unlikely we will use those anything soon.
232 | + 233 | +In PSBTv2, the Creator initializes the PSBT with 0 inputs and 0 outputs. 234 | +The PSBT version number is set to 2. The transaction version number must be set to at least 2. <ref>'''Why does the transaction version number need to be at least 2?''' The transaction version number is part of the validation rules for some features such as OP_CHECKSEQUENCEVERIFY. Since it is backwards compatible, and there are other ways to disable those features (e.g. through sequence numbers), it is easier to require transactions be able to support these features than to try to negotiate the transaction version number.</ref> 235 | +The Creator should also set PSBT_GLOBAL_PREFERRED_LOCKTIME. 236 | +If the Creator is not also a Constructor and will be giving the PSBT to others to add inputs and outputs, the PSBT_GLOBAL_TX_MODIFIABLE field must be present and and the Inputs Modifiable and Outputs Modifiable flags set appropriately. 237 | +If the Creator is a Constructor and no inputs and outputs will be added by other entities, PSBT_GLOBAL_TX_MODIFIABLE may be omitted.
Should this also explicitly specify that if the no inputs/outputs will be modified(instead of added), then PSBT_GLOBAL_TX_MODIFIABLE can be omitted.
No, because things like signatures will be added to the inputs, so you would expect them to be modified.
What does "input modification" mean in the PSBT_GLOBAL_TX_MODIFIABLE flag? Does this mean don't touch any data apart from witness data? Is changing something like nSequence allowed?
It just means that the inputs vector can be modified, i.e. new inputs added. In terms of an input or output being modified, anything can be changed except for the things that uniquely identify the input or output. This means that you can't change the previous txid and output index in an input, and you can't change the scriptpubkey or the amount in an output.
173 | +| 0 174 | +| 2 175 | +| [[bip-psb2.mediawiki|psbt2]] 176 | +|- 177 | +| SIGHASH_SINGLE Inputs 178 | +| <tt>PSBT_GLOBAL_SIGHASH_SINGLE_INPUTS = 0x07</tt>
Post-merge coment: This field is not present in BIP370. Was it left here by mistake ? Or not added to BIP370 by mistake ?
Oops, that should have been removed from 174.
btw, if the BIP would require signers to add PSBT_IN_SIGHASH_TYPE if they used SIGHASH_SINGLE for the signature, and finalization to preserve PSBT_IN_SIGHASH_TYPE, then constructors could rely on this instead, and they would not need an interpreter. The problem would be older finalizers that can still remove this field, though. Was this bitmap planned to be used essentially for the same purpose ?