Add BIP 370: PSBT Version 2 #1059

pull achow101 wants to merge 2 commits into bitcoin:master from achow101:psbt2 changing 3 files +486 −31
  1. achow101 commented at 6:14 pm on January 28, 2021: member

    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

  2. luke-jr commented at 10:46 pm on February 3, 2021: member
    Needs a backward compatibility section
  3. luke-jr added the label New BIP on Feb 3, 2021
  4. achow101 commented at 0:00 am on February 4, 2021: member

    Needs a backward compatibility section

    There’s a Compatibility section.

  5. achow101 force-pushed on Feb 4, 2021
  6. luke-jr commented at 3:58 pm on February 4, 2021: member

    Would be nice to have it named per BIP 2

    Let’s use BIP number 370

  7. luke-jr renamed this:
    Add bip-psbt2
    Add BIP 370: PSBT2
    on Feb 4, 2021
  8. luke-jr renamed this:
    Add BIP 370: PSBT2
    Add BIP 370: PSBT Version 2
    on Feb 4, 2021
  9. achow101 force-pushed on Feb 4, 2021
  10. achow101 commented at 5:42 pm on February 4, 2021: member

    Would be nice to have it named per BIP 2

    Let’s use BIP number 370

    Done.

  11. in bip-0370.mediawiki:106 in 8bf4aa9424 outdated
    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.
    


    sanket1729 commented at 6:44 pm on February 12, 2021:

    Bits 2 and 3 indicate

    I think this should be Bits 0 and 2?


    achow101 commented at 9:09 pm on February 12, 2021:
    Just bit 2. Fixed.
  12. in bip-0370.mediawiki:194 in 8bf4aa9424 outdated
    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.
    


    sanket1729 commented at 7:06 pm on February 12, 2021:
    64-bit uint inconsistent with the description 64 bit signed little-endian. I think it should 64-bit int

    achow101 commented at 9:09 pm on February 12, 2021:
    Done
  13. in bip-0370.mediawiki:235 in 8bf4aa9424 outdated
    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.
    


    sanket1729 commented at 7:11 pm on February 12, 2021:
    Incomplete sentence. Missing specify/set.

    achow101 commented at 9:09 pm on February 12, 2021:
    Done
  14. in bip-0370.mediawiki:252 in 8bf4aa9424 outdated
    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.
    


    sanket1729 commented at 7:15 pm on February 12, 2021:
    Incomplete sentences for PSBT_IN_REQUIRED_*_LOCKTIME

    achow101 commented at 9:10 pm on February 12, 2021:
    Fixed
  15. in bip-0370.mediawiki:261 in 8bf4aa9424 outdated
    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.
    


    sanket1729 commented at 7:28 pm on February 12, 2021:
    Incomplete sentence, If the PSBT_GLOBAL_TX_MODIFIABLE field has

    achow101 commented at 9:11 pm on February 12, 2021:
    Has SIGHASH_SINGLE flag is the noun in this sentence.
  16. in bip-0174.mediawiki:499 in 8bf4aa9424 outdated
    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.
    


    sanket1729 commented at 7:30 pm on February 12, 2021:
    same comment about signed/unsigned

    achow101 commented at 9:12 pm on February 12, 2021:
    Fixed.
  17. Specify BIP 370 PSBTv2 b3d224f384
  18. achow101 force-pushed on Feb 12, 2021
  19. sanket1729 approved
  20. sanket1729 commented at 10:21 pm on February 12, 2021: contributor

    ACK b3d224f384f3bae6e38d4fcf0028b046b414784b.

    We will probably implement this in rust-bitcoin and cross check once we have test-vectors.

  21. achow101 cross-referenced this on Feb 25, 2021 from issue Roadmap to a 2.0 release by achow101
  22. achow101 cross-referenced this on Feb 25, 2021 from issue Implement PSBTv2 by achow101
  23. 174: Change PSBT unknown fields test to use higher numbers
    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.
    eaaf376099
  24. in bip-0370.mediawiki:237 in eaaf376099
    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.
    


    sanket1729 commented at 9:55 pm on March 10, 2021:
    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.

    achow101 commented at 0:41 am on March 13, 2021:
    No, because things like signatures will be added to the inputs, so you would expect them to be modified.

    sanket1729 commented at 1:01 am on March 13, 2021:
    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?

    achow101 commented at 1:30 am on March 13, 2021:
    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.
  25. luke-jr merged this on Mar 15, 2021
  26. luke-jr closed this on Mar 15, 2021

  27. in bip-0174.mediawiki:177 in eaaf376099
    173+| 0
    174+| 2
    175+| [[bip-psb2.mediawiki|psbt2]]
    176+|-
    177+| SIGHASH_SINGLE Inputs
    178+| <tt>PSBT_GLOBAL_SIGHASH_SINGLE_INPUTS = 0x07</tt>
    


    dgpv commented at 10:07 am on December 17, 2021:
    Post-merge coment: This field is not present in BIP370. Was it left here by mistake ? Or not added to BIP370 by mistake ?

    achow101 commented at 5:46 pm on December 17, 2021:
    Oops, that should have been removed from 174.

    dgpv commented at 7:59 pm on December 17, 2021:
    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 ?

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-12-26 18:10 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me