From 6057fede052900d442e8fe826f789263769b002d Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Tue, 28 Jul 2020 11:33:06 +0930 Subject: [PATCH 1/7] BIP 174: clarify format of proprietary extensions. "Variable length string identifier" is not defined anywhere, and the suggestion to use "0x00" is also deeply unclear. I assumed it meant a nul-terminated string! Be explicit: you mean it must be a compact siz1\e unsigned int length, followed by that many identifier bytes, followed by a compact size unsigned int subtype, followed by optional keydata. Signed-off-by: Rusty Russell --- bip-0174.mediawiki | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index c424c5d7..30a2bc25 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -133,8 +133,8 @@ The currently defined global types are as follows: *** {32-bit uint} * Type: Proprietary Use Type PSBT_GLOBAL_PROPRIETARY = 0xFC -** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. -*** {0xFC}||{subtype}|{key data} +** Key: Compact size unsigned integer, followed by identifier prefix of that length, followed by a subtype, followed by the key data itself. +*** {0xFC}|{prefixlen}||{subtype}|{key data} ** Value: Any value data as defined by the proprietary type user. *** @@ -225,8 +225,8 @@ The currently defined per-input types are defined as follows: *** {preimage} * Type: Proprietary Use Type PSBT_IN_PROPRIETARY = 0xFC -** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. -*** {0xFC}||{subtype}|{key data} +** Key: Compact size unsigned integer, followed by identifier prefix of that length, followed by a subtype, followed by the key data itself. +*** {0xFC}|{prefixlen}||{subtype}|{key data} ** Value: Any value data as defined by the proprietary type user. *** @@ -253,8 +253,8 @@ determine which outputs are change outputs and verify that the change is returni *** {master key fingerprint}|{32-bit uint}|...|{32-bit uint} * Type: Proprietary Use Type PSBT_OUT_PROPRIETARY = 0xFC -** Key: Variable length identifier prefix, followed by a subtype, followed by the key data itself. -*** {0xFC}||{subtype}|{key data} +** Key: Compact size unsigned integer, followed by identifier prefix of that length, followed by a subtype, followed by the key data itself. +*** {0xFC}|{prefixlen}||{subtype}|{key data} ** Value: Any value data as defined by the proprietary type user. *** @@ -336,10 +336,10 @@ values are valid, then it does not matter which is chosen as either way the tran ===Proprietary Use Type=== For all global, per-input, and per-output maps, the types 0xFC is reserved for proprietary use. -The proprietary use type requires keys that follow the type with a variable length string identifer, then a subtype. +The proprietary use type requires keys that follow the type with a compact size unsigned integer representing the length of the string identifer, followed by the string identifier, then a subtype, and finally any key data. The identifier can be any variable length string that software can use to identify whether the particular data in the proprietary type can be used by it. -It can also be the empty string and just be a single 0x00 byte although this is not recommended. +It can also be the empty string although this is not recommended. The subtype is defined by the proprietary type user and can mean whatever they want it to mean. The subtype must also be a compact size unsigned integer in the same form as the normal types. From 50fdf5435ebbc2e9dfb98b74b2ff4a835ef94034 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Wed, 13 Jan 2021 17:09:35 -0500 Subject: [PATCH 2/7] Reformat BIP 174 --- bip-0174.mediawiki | 451 +++++++++++++++++++++------------------------ 1 file changed, 206 insertions(+), 245 deletions(-) diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index 30a2bc25..a20432a1 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -48,272 +48,233 @@ is the separator here 0x00 instead of 0xff?''' The separator here is used to distinguish between each chunk of data. A separator of 0x00 would mean that the unserializer can read it as a key length of 0, which would never occur with actual keys. It can thus be used as a separator and allow for easier unserializer implementation.. -Each key-value pair must have a unique key within its scope; duplicates are not allowed. The format -of a record is as follows: -Note: <..> indicates that the data is prefixed by a compact size unsigned integer representing -the length of that data. {..} indicates the raw data itself. -
-|
-
+ := * * + := 0x70 0x73 0x62 0x74 0xFF + := * 0x00 + := * 0x00 + := * 0x00 + := + := + := -{| class="wikitable" style="width: auto; text-align: center; font-size: smaller; table-layout: fixed;" -!Name -!Type -!Description -|- -| Key Length -| Compact Size Unsigned Integer -| Specify how long the key is -|- -| Key -| byte[] -| The Key itself -|- -| Value Length -| Compact Size Unsigned Integer -| Specify how long the value is -|- -| Value -| byte[] -| The Value itself -|} +Where: -The format of each key-value map is as follows: - -
-{key-value pair}|{key-value pair}|...|{0x00}
-
- -{| class="wikitable" style="width: auto; text-align: center; font-size: smaller; table-layout: fixed;" -!Field Size -!Name -!Type -!Value -!Description -|- -| 1+ -| Key-value pairs -| Array of key-value pairs -| varies -| The key-value pairs. -|- -| 1 -| separator -| char -| 0x00 -| Must be 0x00 at the end of the map. -|} - -At the beginning of each key is a compact size unsigned integer representing the type. -This compact size unsigned integer must be minimally encoded, i.e. if the value can be represented using one byte, it must be represented as one byte. -For convenience, this BIP will specify types using their full serialization, so a multi-byte type will have it's full prefix and zero padding as necessary. -There are global types, per-input types, and per-output types. +; +: A compact size unsigned integer representing the type. This compact size unsigned integer must be minimally encoded, i.e. if the value can be represented using one byte, it must be represented as one byte. This must be unique within a specific . +; +: The compact size unsigned integer containing the combined length of and +; +: The compact size unsigned integer containing the length of . +; +: Magic bytes which are ASCII for psbt '''Why use 4 bytes for psbt?''' The +transaction format needed to start with a 5 byte header which uniquely identifies +it. The first bytes were chosen to be the ASCII for psbt because that stands for +Partially Signed Bitcoin Transaction. followed by a separator of 0xFF +'''Why Use a separator after the magic bytes?''' The separator +is part of the 5 byte header for PSBT. This byte is a separator of 0xff because +this will cause any non-PSBT unserializer to fail to properly unserialize the PSBT +as a normal transaction. Likewise, since the 5 byte header is fixed, no transaction +in the non-PSBT format will be able to be unserialized by a PSBT unserializer.. This integer must be serialized +in most significant byte order. The currently defined global types are as follows: -* Type: Unsigned Transaction PSBT_GLOBAL_UNSIGNED_TX = 0x00 -** Key: None. The key must only contain the 1 byte type. -*** {0x00} -** Value: The transaction in network serialization. The scriptSigs and witnesses for each input must be empty. The transaction must be in the old serialization format (without witnesses). A PSBT must have a transaction, otherwise it is invalid. -*** {transaction} -** Note: Every PSBT must have a field with this type. - -* Type: Extended Public Key PSBT_GLOBAL_XPUB = 0x01 -** Key: The type followed by the 78 byte serialized extended public key as defined by BIP 32. Extended public keys are those that can be used to derive public keys used in the inputs and outputs of this transaction. It should be the public key at the highest hardened derivation index so that the unhardened child keys used in the transaction can be derived. -*** {0x01}|{xpub} -** Value: The master key fingerprint as defined by BIP 32 concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. The number of 32 bit unsigned integer indexes must match the depth provided in the extended public key. -*** {master key fingerprint}|{32-bit uint}|...|{32-bit uint} - -* Type: Version Number PSBT_GLOBAL_VERSION = 0xFB -** Key: None. The key must only contain the 1 byte type. -*** {0xFB} -** Value: The 32-bit little endian unsigned integer representing the version number of this PSBT. If ommitted, the version number is 0. -*** {32-bit uint} - -* Type: Proprietary Use Type PSBT_GLOBAL_PROPRIETARY = 0xFC -** Key: Compact size unsigned integer, followed by identifier prefix of that length, followed by a subtype, followed by the key data itself. -*** {0xFC}|{prefixlen}||{subtype}|{key data} -** Value: Any value data as defined by the proprietary type user. -*** +{| +! Name +! +! +! Description +! +! Description +|- +| Unsigned Transaction +| PSBT_GLOBAL_UNSIGNED_TX = 0x00 +| None +| No key data +| +| The transaction in network serialization. The scriptSigs and witnesses for each input must be empty. The transaction must be in the old serialization format (without witnesses). A PSBT must have a transaction, otherwise it is invalid. +|- +| Extended Public Key +| PSBT_GLOBAL_XPUB = 0x01 +| +| The 78 byte serialized extended public key as defined by BIP 32. Extended public keys are those that can be used to derive public keys used in the inputs and outputs of this transaction. It should be the public key at the highest hardened derivation index so that the unhardened child keys used in the transaction can be derived. +| <32-bit uint> <32-bit uint>* +| The master key fingerprint as defined by BIP 32 concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. The number of 32 bit unsigned integer indexes must match the depth provided in the extended public key. +|- +| PSBT Version Number +| PSBT_GLOBAL_VERSION = 0xFB +| None +| No key data +| <32-bit uint> +| The 32-bit little endian unsigned integer representing the version number of this PSBT. If ommitted, the version number is 0. +|- +| Proprietary Use Type +| PSBT_GLOBAL_PROPRIETARY = 0xFC +| +| Compact size unsigned integer , followed by identifier prefix of that length , followed by a subtype , followed by the key data itself . +| +| Any value data as defined by the proprietary type user. +|} The currently defined per-input types are defined as follows: -* Type: Non-Witness UTXO PSBT_IN_NON_WITNESS_UTXO = 0x00 -** Key: None. The key must only contain the 1 byte type. -***{0x00} -** Value: The transaction in network serialization format the current input spends from. This should be present for inputs that spend non-segwit outputs and can be present for inputs that spend segwit outputs. An input can have both PSBT_IN_NON_WITNESS_UTXO and PSBT_IN_WITNESS_UTXO. '''Why can both UTXO types be provided?''' Many wallets began requiring the full previous transaction (i.e. PSBT_IN_NON_WITNESS_UTXO) for segwit inputs when PSBT was already in use. In order to be compatible with software which were expecting PSBT_IN_WITNESS_UTXO, both UTXO types must be allowed. -*** {transaction} - -* Type: Witness UTXO PSBT_IN_WITNESS_UTXO = 0x01 -** Key: None. The key must only contain the 1 byte type. -*** {0x01} -** Value: The entire transaction output in network serialization which the current input spends from. This should only be present for inputs which spend segwit outputs, including P2SH embedded ones. An input can have both PSBT_IN_NON_WITNESS_UTXO and PSBT_IN_WITNESS_UTXO -*** {serialized transaction output({output value}|)} - -* Type: Partial Signature PSBT_IN_PARTIAL_SIG = 0x02 -** Key: The public key which corresponds to this signature. -*** {0x02}|{public key} -** Value: The signature as would be pushed to the stack from a scriptSig or witness. -*** {signature} - -* Type: Sighash Type PSBT_IN_SIGHASH_TYPE = 0x03 -** Key: None. The key must only contain the 1 byte type. -*** {0x03} -** Value: The 32-bit unsigned integer specifying the sighash type to be used for this input. Signatures for this input must use the sighash type, finalizers must fail to finalize inputs which have signatures that do not match the specified sighash type. Signers who cannot produce signatures with the sighash type must not provide a signature. -*** {sighash type} - -* Type: Redeem Script PSBT_IN_REDEEM_SCRIPT = 0x04 -** Key: None. The key must only contain the 1 byte type. -*** {0x04} -** Value: The redeemScript for this input if it has one. -*** {redeemScript} - -* Type: Witness Script PSBT_IN_WITNESS_SCRIPT = 0x05 -** Key: None. The key must only contain the 1 byte type. -*** {0x05} -** Value: The witnessScript for this input if it has one. -*** {witnessScript} - -* Type: BIP 32 Derivation Path PSBT_IN_BIP32_DERIVATION = 0x06 -** Key: The public key -*** {0x06}|{public key} -** Value: The master key fingerprint as defined by BIP 32 concatenated with the derivation path of the public key. The derivation path is represented as 32 bit unsigned integer indexes concatenated with each other. Public keys are those that will be needed to sign this input. -*** {master key fingerprint}|{32-bit uint}|...|{32-bit uint} - -* Type: Finalized scriptSig PSBT_IN_FINAL_SCRIPTSIG = 0x07 -** Key: None. The key must only contain the 1 byte type. -*** {0x07} -** Value: The Finalized scriptSig contains a fully constructed scriptSig with signatures and any other scripts necessary for the input to pass validation. -*** {scriptSig} - -* Type: Finalized scriptWitness PSBT_IN_FINAL_SCRIPTWITNESS = 0x08 -** Key: None. The key must only contain the 1 byte type. -*** {0x08} -** Value: The Finalized scriptWitness contains a fully constructed scriptWitness with signatures and any other scripts necessary for the input to pass validation. -*** {scriptWitness} - -* Type: Proof-of-reserves commitment PSBT_IN_POR_COMMITMENT = 0x09 -** Key: None. The key must only contain the 1 byte type. -*** {0x09} -** Value: The UTF-8 encoded commitment message string for the proof-of-reserves. See [[bip-0127.mediawiki|BIP 127]] for more information. -*** {porCommitment} - -* Type: RIPEMD160 preimage PSBT_IN_RIPEMD160 = 0x0a -** Key: The resulting hash of the preimage -*** {0x0a}|{20-byte hash} -** Value: The hash preimage, encoded as a byte vector, which must equal the key when run through the `RIPEMD160` algorithm -*** {preimage} - -* Type: SHA256 preimage PSBT_IN_SHA256 = 0x0b -** Key: The resulting hash of the preimage -*** {0x0b}|{32-byte hash} -** Value: The hash preimage, encoded as a byte vector, which must equal the key when run through the `SHA256` algorithm -*** {preimage} - -* Type: HASH160 preimage PSBT_IN_HASH160 = 0x0c -** Key: The resulting hash of the preimage -*** {0x0c}|{20-byte hash} -** Value: The hash preimage, encoded as a byte vector, which must equal the key when run through the `SHA256` algorithm followed by the `RIPEMD160` algorithm -*** {preimage} - -* Type: HASH256 preimage PSBT_IN_HASH256 = 0x0d -** Key: The resulting hash of the preimage -*** {0x0d}|{32-byte hash} -** Value: The hash preimage, encoded as a byte vector, which must equal the key when run through the `SHA256` algorithm twice -*** {preimage} - -* Type: Proprietary Use Type PSBT_IN_PROPRIETARY = 0xFC -** Key: Compact size unsigned integer, followed by identifier prefix of that length, followed by a subtype, followed by the key data itself. -*** {0xFC}|{prefixlen}||{subtype}|{key data} -** Value: Any value data as defined by the proprietary type user. -*** +{| +! Name +! +! +! Description +! +! Description +|- +| Non-Witness UTXO +| PSBT_IN_NON_WITNESS_UTXO = 0x00 +| None +| No key data +| +| The transaction in network serialization format the current input spends from. This should be present for inputs that spend non-segwit outputs and can be present for inputs that spend segwit outputs. An input can have both PSBT_IN_NON_WITNESS_UTXO and PSBT_IN_WITNESS_UTXO. '''Why can both UTXO types be provided?''' Many wallets began requiring the full previous transaction (i.e. PSBT_IN_NON_WITNESS_UTXO) for segwit inputs when PSBT was already in use. In order to be compatible with software which were expecting PSBT_IN_WITNESS_UTXO, both UTXO types must be allowed. +|- +| Witness UTXO +| PSBT_IN_WITNESS_UTXO = 0x01 +| None +| No key data +| <64-bit uint> +| The entire transaction output in network serialization which the current input spends from. This should only be present for inputs which spend segwit outputs, including P2SH embedded ones. An input can have both PSBT_IN_NON_WITNESS_UTXO and PSBT_IN_WITNESS_UTXO +|- +| Partial Signature +| PSBT_IN_PARTIAL_SIG = 0x02 +| +| The public key which corresponds to this signature. +| +| The signature as would be pushed to the stack from a scriptSig or witness. +|- +| Sighash Type +| PSBT_IN_SIGHASH_TYPE = 0x03 +| None +| No key data +| <32-bit uint> +| The 32-bit unsigned integer specifying the sighash type to be used for this input. Signatures for this input must use the sighash type, finalizers must fail to finalize inputs which have signatures that do not match the specified sighash type. Signers who cannot produce signatures with the sighash type must not provide a signature. +|- +| Redeem Script +| PSBT_IN_REDEEM_SCRIPT = 0x04 +| None +| No key data +| +| The redeemScript for this input if it has one. +|- +| Witness Script +| PSBT_IN_WITNESS_SCRIPT = 0x05 +| None +| No key data +| +| The witnessScript for this input if it has one. +|- +| BIP 32 Derivation Path +| PSBT_IN_BIP32_DERIVATION = 0x06 +| +| The public key +| <32-bit uint> <32-bit uint>* +| The master key fingerprint as defined by BIP 32 concatenated with the derivation path of the public key. The derivation path is represented as 32 bit unsigned integer indexes concatenated with each other. Public keys are those that will be needed to sign this input. +|- +| Finalized scriptSig +| PSBT_IN_FINAL_SCRIPTSIG = 0x07 +| None +| No key data +| +| The Finalized scriptSig contains a fully constructed scriptSig with signatures and any other scripts necessary for the input to pass validation. +|- +| Finalized scriptWitness +| PSBT_IN_FINAL_SCRIPTWITNESS = 0x08 +| None +| No key data +| +| The Finalized scriptWitness contains a fully constructed scriptWitness with signatures and any other scripts necessary for the input to pass validation. +|- +| Proof-of-reserves commitment +| PSBT_IN_POR_COMMITMENT = 0x09 +| None +| No key data +| +| The UTF-8 encoded commitment message string for the proof-of-reserves. See [[bip-0127.mediawiki|BIP 127]] for more information. +|- +| RIPEMD160 preimage +| PSBT_IN_RIPEMD160 = 0x0a +| <20-byte hash> +| The resulting hash of the preimage +| +| The hash preimage, encoded as a byte vector, which must equal the key when run through the RIPEMD160 algorithm +|- +| SHA256 preimage +| PSBT_IN_SHA256 = 0x0b +| <32-byte hash> +| The resulting hash of the preimage +| +| The hash preimage, encoded as a byte vector, which must equal the key when run through the SHA256 algorithm +|- +| HASH160 preimage +| PSBT_IN_HASH160 = 0x0c +| <20-byte hash> +| The resulting hash of the preimage +| +| The hash preimage, encoded as a byte vector, which must equal the key when run through the SHA256 algorithm followed by the RIPEMD160 algorithm +|- +| HASH256 preimage +| PSBT_IN_HASH256 = 0x0d +| <32-byte hash> +| The resulting hash of the preimage +| +| The hash preimage, encoded as a byte vector, which must equal the key when run through the SHA256 algorithm twice +|- +| Proprietary Use Type +| PSBT_IN_PROPRIETARY = 0xFC +| +| Compact size unsigned integer , followed by identifier prefix of that length , followed by a subtype , followed by the key data itself . +| +| Any value data as defined by the proprietary type user. +|} The currently defined per-output '''Why do we need per-output data?''' Per-output data allows signers to verify that the outputs are going to the intended recipient. The output data can also be use by signers to determine which outputs are change outputs and verify that the change is returning to the correct place. types are defined as follows: -* Type: Redeem Script PSBT_OUT_REDEEM_SCRIPT = 0x00 -** Key: None. The key must only contain the 1 byte type. -*** {0x00} -** Value: The redeemScript for this output if it has one. -*** {redeemScript} - -* Type: Witness Script PSBT_OUT_WITNESS_SCRIPT = 0x01 -** Key: None. The key must only contain the 1 byte type. -*** {0x01} -** Value: The witnessScript for this output if it has one. -*** {witnessScript} - -* Type: BIP 32 Derivation Path PSBT_OUT_BIP32_DERIVATION = 0x02 -** Key: The public key -*** {0x02}|{public key} -** Value: The master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output. -*** {master key fingerprint}|{32-bit uint}|...|{32-bit uint} - -* Type: Proprietary Use Type PSBT_OUT_PROPRIETARY = 0xFC -** Key: Compact size unsigned integer, followed by identifier prefix of that length, followed by a subtype, followed by the key data itself. -*** {0xFC}|{prefixlen}||{subtype}|{key data} -** Value: Any value data as defined by the proprietary type user. -*** - -The transaction format is specified as follows: - - -
-    {0x70736274}|{0xff}|{global key-value map}|{input key-value map}|...|{input key-value map}|{output key-value map}|...|{output key-value map}|
-
- -{| class="wikitable" style="width: auto; text-align: center; font-size: smaller; table-layout: fixed;" -!Field Size -!Name -!Type -!Value -!Description +{| +! Name +! +! +! Description +! +! Description |- -| 4 -| Magic Bytes -| int32_t -| 0x70736274 -| Magic bytes which are ASCII for psbt. '''Why use 4 bytes for psbt?''' The -transaction format needed to start with a 5 byte header which uniquely identifies -it. The first bytes were chosen to be the ASCII for psbt because that stands for -Partially Signed Bitcoin Transaction. This integer should be serialized -in most significant byte order. +| Redeem Script +| PSBT_OUT_REDEEM_SCRIPT = 0x00 +| None +| No key data +| +| The redeemScript for this output if it has one. |- -| 1 -| separator -| char -| 0xff -| Must be 0xff '''Why Use a separator after the magic bytes?''' The separator -is part of the 5 byte header for PSBT. This byte is a separator of 0xff because -this will cause any non-PSBT unserializer to fail to properly unserialize the PSBT -as a normal transaction. Likewise, since the 5 byte header is fixed, no transaction -in the non-PSBT format will be able to be unserialized by a PSBT unserializer. +| Witness Script +| PSBT_OUT_WITNESS_SCRIPT = 0x01 +| None +| No key data +| +| The witnessScript for this output if it has one. |- -| 1+ -| Global data -| Key-value Map -| varies -| The key-value pairs for all global data. +| BIP 32 Derivation Path +| PSBT_OUT_BIP32_DERIVATION = 0x02 +| +| The public key +| <{32-bit uint> <32-bit uint>* +| The master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output. |- -| 1+ -| Inputs -| Array of key-value maps -| varies -| The key-value pairs for each input as described above. Every input in the unsigned transaction must have a corresponding input map. -|- -| 1+ -| Outputs -| Array of key-value maps -| varies -| The key-value pairs for each output as described above. Every output in the unsigned transaction must have a corresponding output map. +| Proprietary Use Type +| PSBT_OUT_PROPRIETARY = 0xFC +| +| Compact size unsigned integer , followed by identifier prefix of that length , followed by a subtype , followed by the key data itself . +| +| Any value data as defined by the proprietary type user. |} -Each block of data between separators can be viewed as a scope, and all separators -are required'''Why are all separators required?''' The separators are required -so that the unserializer knows which input it is unserializing data for.. Types can be skipped when they are unnecessary. For example, if an input is a witness input, then it should not have a Non-Witness UTXO key-value pair. From c0991047e25a35d1ddf241f304a079e9893eed69 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Thu, 14 Jan 2021 13:31:15 -0500 Subject: [PATCH 3/7] Explicitly specify PSBTv0 --- README.mediawiki | 2 +- bip-0174.mediawiki | 13 +++++++++++-- scripts/buildtable.pl | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/README.mediawiki b/README.mediawiki index 83120ab8..e9fe7052 100644 --- a/README.mediawiki +++ b/README.mediawiki @@ -850,7 +850,7 @@ Those proposing changes should consider that ultimately consent may rest with th |- style="background-color: #ffffcf" | [[bip-0174.mediawiki|174]] | Applications -| Partially Signed Bitcoin Transaction Format +| Partially Signed Bitcoin Transaction Format and Version 0 | Andrew Chow | Standard | Proposed diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki index a20432a1..a1beaef7 100644 --- a/bip-0174.mediawiki +++ b/bip-0174.mediawiki @@ -1,7 +1,7 @@
   BIP: 174
   Layer: Applications
-  Title: Partially Signed Bitcoin Transaction Format
+  Title: Partially Signed Bitcoin Transaction Format and Version 0
   Author: Andrew Chow 
   Comments-Summary: No comments yet.
   Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0174
@@ -21,6 +21,9 @@ signatures for an input while the input does not have a complete set of signatur
 The signer can be offline as all necessary information will be provided in the
 transaction.
 
+The generic format is described here in addition to the specification for version 0
+of this format.
+
 ===Copyright===
 
 This BIP is licensed under the 2-clause BSD license.
@@ -94,7 +97,7 @@ The currently defined global types are as follows:
 | None
 | No key data
 | 
-| The transaction in network serialization. The scriptSigs and witnesses for each input must be empty. The transaction must be in the old serialization format (without witnesses). A PSBT must have a transaction, otherwise it is invalid.
+| The transaction in network serialization. The scriptSigs and witnesses for each input must be empty. The transaction must be in the old serialization format (without witnesses).
 |-
 | Extended Public Key
 | PSBT_GLOBAL_XPUB = 0x01
@@ -311,6 +314,12 @@ It is useful when there are additional data that they need attached to a PSBT bu
 The proprietary use type is not to be used by any public specification and there is no expectation that any publicly available software be able to understand any specific meanings of it and the subtypes.
 This type must be used for internal processes only.
 
+==Version 0==
+
+Partially Signed Bitcoin Transactions version 0 is the first version of the PSBT format.
+Version 0 PSBTs must either omit PSBT_GLOBAL_VERSION or include it and set it to 0.
+Version 0 PSBTs must include PSBT_GLOBAL_UNSIGNED_TX, if omitted, the PSBT is invalid.
+
 ==Roles==
 
 Using the transaction format involves many different roles. Multiple roles can be handled by a single entity, but each role is specialized in what it should be capable of doing.
diff --git a/scripts/buildtable.pl b/scripts/buildtable.pl
index 1edd8c0d..ed71f7c4 100755
--- a/scripts/buildtable.pl
+++ b/scripts/buildtable.pl
@@ -89,7 +89,7 @@ my %DefinedLicenses = (
 );
 my %GrandfatheredPD = map { $_ => undef } qw(9 36 37 38 42 49 50 60 65 67 69 74 80 81 83 90 99 105 107 109 111 112 113 114 122 124 125 126 130 131 132 133 140 141 142 143 144 146 147 150 151 152);
 my %TolerateMissingLicense = map { $_ => undef } qw(1 10 11 12 13 14 15 16 21 31 33 34 35 39 43 44 45 47 61 64 68 70 71 72 73 101 102 106 120 121);
-my %TolerateTitleTooLong = map { $_ => undef } qw(39 44 45 47 49 60 67 68 69 73 74 75 80 81 99 105 106 109 113 122 126 131 143 145 147 173);
+my %TolerateTitleTooLong = map { $_ => undef } qw(39 44 45 47 49 60 67 68 69 73 74 75 80 81 99 105 106 109 113 122 126 131 143 145 147 173 174);
 
 my %emails;
 

From a4fb1b9de0997ef5f47cca6e684353a89ad0b440 Mon Sep 17 00:00:00 2001
From: Andrew Chow 
Date: Thu, 14 Jan 2021 13:50:00 -0500
Subject: [PATCH 4/7] Specify procedure for new fields and versions

---
 bip-0174.mediawiki | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki
index a1beaef7..3ea95d5b 100644
--- a/bip-0174.mediawiki
+++ b/bip-0174.mediawiki
@@ -479,6 +479,18 @@ Updaters and combiners that need to add a version number to a PSBT should use th
 For example, if a combiner sees two PSBTs for the same transaction, one with version 0, and the other with version 1, then it should combine them and produce a PSBT with version 1.
 If an updater is updating a PSBT and needs to add a field that is only available in version 1, then it should set the PSBT version number to 1 unless a version higher than that is already specified.
 
+===Procedure For New Fields===
+
+New fields should first be proposed on the bitcoin-dev mailing list.
+If a field requires significatn description as to its usage, it should be accompanied by a separate BIP.
+The field must be added to the field listing tables in the Specification section.
+
+===Procedure For New Versions===
+
+New PSBT versions must be described in a separate BIP.
+The BIP may reference this BIP and any components of PSBT version 0 that are retained in the new version.
+Any new fields described in the new version must be added to the field listing tables in the Specification section.
+
 ==Compatibility==
 
 This transaction format is designed so that it is unable to be properly unserialized

From 80df41818ecbd2a16f351513da8e33e0ac17a4fd Mon Sep 17 00:00:00 2001
From: Andrew Chow 
Date: Thu, 14 Jan 2021 13:52:07 -0500
Subject: [PATCH 5/7] Include PSBT versions that can or must include field

---
 bip-0174.mediawiki | 78 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 78 insertions(+)

diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki
index 3ea95d5b..9e1de135 100644
--- a/bip-0174.mediawiki
+++ b/bip-0174.mediawiki
@@ -91,6 +91,9 @@ The currently defined global types are as follows:
 !  Description
 ! 
 !  Description
+! Versions Requiring Inclusion
+! Versions Requiring Exclusion
+! Versions Allowing Inclusion
 |-
 | Unsigned Transaction
 | PSBT_GLOBAL_UNSIGNED_TX = 0x00
@@ -98,6 +101,9 @@ The currently defined global types are as follows:
 | No key data
 | 
 | The transaction in network serialization. The scriptSigs and witnesses for each input must be empty. The transaction must be in the old serialization format (without witnesses).
+| 0
+|
+| 0
 |-
 | Extended Public Key
 | PSBT_GLOBAL_XPUB = 0x01
@@ -105,6 +111,9 @@ The currently defined global types are as follows:
 | The 78 byte serialized extended public key as defined by BIP 32. Extended public keys are those that can be used to derive public keys used in the inputs and outputs of this transaction. It should be the public key at the highest hardened derivation index so that the unhardened child keys used in the transaction can be derived.
 | <32-bit uint> <32-bit uint>*
 | The master key fingerprint as defined by BIP 32 concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. The number of 32 bit unsigned integer indexes must match the depth provided in the extended public key.
+|
+|
+| 0
 |-
 | PSBT Version Number
 | PSBT_GLOBAL_VERSION = 0xFB
@@ -112,6 +121,9 @@ The currently defined global types are as follows:
 | No key data
 | <32-bit uint>
 | The 32-bit little endian unsigned integer representing the version number of this PSBT. If ommitted, the version number is 0.
+|
+|
+| 0
 |-
 | Proprietary Use Type
 | PSBT_GLOBAL_PROPRIETARY = 0xFC
@@ -119,6 +131,9 @@ The currently defined global types are as follows:
 | Compact size unsigned integer , followed by identifier prefix of that length , followed by a subtype , followed by the key data itself .
 | 
 | Any value data as defined by the proprietary type user.
+|
+|
+| 0
 |}
 
 The currently defined per-input types are defined as follows:
@@ -130,6 +145,9 @@ The currently defined per-input types are defined as follows:
 !  Description
 ! 
 !  Description
+! Versions Requiring Inclusion
+! Versions Requiring Exclusion
+! Versions Allowing Inclusion
 |-
 | Non-Witness UTXO
 | PSBT_IN_NON_WITNESS_UTXO = 0x00
@@ -137,6 +155,9 @@ The currently defined per-input types are defined as follows:
 | No key data
 | 
 | The transaction in network serialization format the current input spends from. This should be present for inputs that spend non-segwit outputs and can be present for inputs that spend segwit outputs. An input can have both PSBT_IN_NON_WITNESS_UTXO and PSBT_IN_WITNESS_UTXO. '''Why can both UTXO types be provided?''' Many wallets began requiring the full previous transaction (i.e. PSBT_IN_NON_WITNESS_UTXO) for segwit inputs when PSBT was already in use. In order to be compatible with software which were expecting PSBT_IN_WITNESS_UTXO, both UTXO types must be allowed.
+|
+|
+| 0
 |-
 | Witness UTXO
 | PSBT_IN_WITNESS_UTXO = 0x01
@@ -144,6 +165,9 @@ The currently defined per-input types are defined as follows:
 | No key data
 | <64-bit uint>  
 | The entire transaction output in network serialization which the current input spends from. This should only be present for inputs which spend segwit outputs, including P2SH embedded ones. An input can have both PSBT_IN_NON_WITNESS_UTXO and PSBT_IN_WITNESS_UTXO
+|
+|
+| 0
 |-
 | Partial Signature
 | PSBT_IN_PARTIAL_SIG = 0x02
@@ -151,6 +175,9 @@ The currently defined per-input types are defined as follows:
 | The public key which corresponds to this signature.
 | 
 | The signature as would be pushed to the stack from a scriptSig or witness.
+|
+|
+| 0
 |-
 | Sighash Type
 | PSBT_IN_SIGHASH_TYPE = 0x03
@@ -158,6 +185,9 @@ The currently defined per-input types are defined as follows:
 | No key data
 | <32-bit uint>
 | The 32-bit unsigned integer specifying the sighash type to be used for this input. Signatures for this input must use the sighash type, finalizers must fail to finalize inputs which have signatures that do not match the specified sighash type. Signers who cannot produce signatures with the sighash type must not provide a signature.
+|
+|
+| 0
 |-
 | Redeem Script
 | PSBT_IN_REDEEM_SCRIPT = 0x04
@@ -165,6 +195,9 @@ The currently defined per-input types are defined as follows:
 | No key data
 | 
 | The redeemScript for this input if it has one.
+|
+|
+| 0
 |-
 | Witness Script
 | PSBT_IN_WITNESS_SCRIPT = 0x05
@@ -172,6 +205,9 @@ The currently defined per-input types are defined as follows:
 | No key data
 | 
 | The witnessScript for this input if it has one.
+|
+|
+| 0
 |-
 | BIP 32 Derivation Path
 | PSBT_IN_BIP32_DERIVATION = 0x06
@@ -179,6 +215,9 @@ The currently defined per-input types are defined as follows:
 | The public key
 | <32-bit uint> <32-bit uint>*
 | The master key fingerprint as defined by BIP 32 concatenated with the derivation path of the public key. The derivation path is represented as 32 bit unsigned integer indexes concatenated with each other. Public keys are those that will be needed to sign this input.
+|
+|
+| 0
 |-
 | Finalized scriptSig
 | PSBT_IN_FINAL_SCRIPTSIG = 0x07
@@ -186,6 +225,9 @@ The currently defined per-input types are defined as follows:
 | No key data
 | 
 | The Finalized scriptSig contains a fully constructed scriptSig with signatures and any other scripts necessary for the input to pass validation.
+|
+|
+| 0
 |-
 | Finalized scriptWitness
 | PSBT_IN_FINAL_SCRIPTWITNESS = 0x08
@@ -193,6 +235,9 @@ The currently defined per-input types are defined as follows:
 | No key data
 | 
 | The Finalized scriptWitness contains a fully constructed scriptWitness with signatures and any other scripts necessary for the input to pass validation.
+|
+|
+| 0
 |-
 | Proof-of-reserves commitment
 | PSBT_IN_POR_COMMITMENT = 0x09
@@ -200,6 +245,9 @@ The currently defined per-input types are defined as follows:
 | No key data
 | 
 | The UTF-8 encoded commitment message string for the proof-of-reserves.  See [[bip-0127.mediawiki|BIP 127]] for more information.
+|
+|
+| 0
 |-
 | RIPEMD160 preimage
 | PSBT_IN_RIPEMD160 = 0x0a
@@ -207,6 +255,9 @@ The currently defined per-input types are defined as follows:
 | The resulting hash of the preimage
 | 
 | The hash preimage, encoded as a byte vector, which must equal the key when run through the RIPEMD160 algorithm
+|
+|
+| 0
 |-
 | SHA256 preimage
 | PSBT_IN_SHA256 = 0x0b
@@ -214,6 +265,9 @@ The currently defined per-input types are defined as follows:
 | The resulting hash of the preimage
 | 
 | The hash preimage, encoded as a byte vector, which must equal the key when run through the SHA256 algorithm
+|
+|
+| 0
 |-
 | HASH160 preimage
 | PSBT_IN_HASH160 = 0x0c
@@ -221,6 +275,9 @@ The currently defined per-input types are defined as follows:
 | The resulting hash of the preimage
 | 
 | The hash preimage, encoded as a byte vector, which must equal the key when run through the SHA256 algorithm followed by the RIPEMD160 algorithm
+|
+|
+| 0
 |-
 | HASH256 preimage
 | PSBT_IN_HASH256 = 0x0d
@@ -228,6 +285,9 @@ The currently defined per-input types are defined as follows:
 | The resulting hash of the preimage
 | 
 | The hash preimage, encoded as a byte vector, which must equal the key when run through the SHA256 algorithm twice
+|
+|
+| 0
 |-
 | Proprietary Use Type
 | PSBT_IN_PROPRIETARY = 0xFC
@@ -235,6 +295,9 @@ The currently defined per-input types are defined as follows:
 | Compact size unsigned integer , followed by identifier prefix of that length , followed by a subtype , followed by the key data itself .
 | 
 | Any value data as defined by the proprietary type user.
+|
+|
+| 0
 |}
 
 The currently defined per-output '''Why do we need per-output data?''' Per-output data allows signers
@@ -248,6 +311,9 @@ determine which outputs are change outputs and verify that the change is returni
 !  Description
 ! 
 !  Description
+! Versions Requiring Inclusion
+! Versions Requiring Exclusion
+! Versions Allowing Inclusion
 |-
 | Redeem Script
 | PSBT_OUT_REDEEM_SCRIPT = 0x00
@@ -255,6 +321,9 @@ determine which outputs are change outputs and verify that the change is returni
 | No key data
 | 
 | The redeemScript for this output if it has one.
+|
+|
+| 0
 |-
 | Witness Script
 | PSBT_OUT_WITNESS_SCRIPT = 0x01
@@ -262,6 +331,9 @@ determine which outputs are change outputs and verify that the change is returni
 | No key data
 | 
 | The witnessScript for this output if it has one.
+|
+|
+| 0
 |-
 | BIP 32 Derivation Path
 | PSBT_OUT_BIP32_DERIVATION = 0x02
@@ -269,6 +341,9 @@ determine which outputs are change outputs and verify that the change is returni
 | The public key
 | <{32-bit uint> <32-bit uint>*
 | The master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output.
+|
+|
+| 0
 |-
 | Proprietary Use Type
 | PSBT_OUT_PROPRIETARY = 0xFC
@@ -276,6 +351,9 @@ determine which outputs are change outputs and verify that the change is returni
 | Compact size unsigned integer , followed by identifier prefix of that length , followed by a subtype , followed by the key data itself .
 | 
 | Any value data as defined by the proprietary type user.
+|
+|
+| 0
 |}
 
 Types can be skipped when they are unnecessary. For example, if an input is a witness

From c27d5e8b9643a478ed7b6fd4e7cda15238f418fe Mon Sep 17 00:00:00 2001
From: Andrew Chow 
Date: Thu, 14 Jan 2021 14:38:36 -0500
Subject: [PATCH 6/7] Mark BIP 174 as final

---
 README.mediawiki   | 4 ++--
 bip-0174.mediawiki | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/README.mediawiki b/README.mediawiki
index e9fe7052..f77ce56f 100644
--- a/README.mediawiki
+++ b/README.mediawiki
@@ -847,13 +847,13 @@ Those proposing changes should consider that ultimately consent may rest with th
 | Pieter Wuille, Greg Maxwell
 | Informational
 | Final
-|- style="background-color: #ffffcf"
+|- style="background-color: #cfffcf"
 | [[bip-0174.mediawiki|174]]
 | Applications
 | Partially Signed Bitcoin Transaction Format and Version 0
 | Andrew Chow
 | Standard
-| Proposed
+| Final
 |-
 | [[bip-0175.mediawiki|175]]
 | Applications
diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki
index 9e1de135..303c0013 100644
--- a/bip-0174.mediawiki
+++ b/bip-0174.mediawiki
@@ -5,7 +5,7 @@
   Author: Andrew Chow 
   Comments-Summary: No comments yet.
   Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0174
-  Status: Proposed
+  Status: Final
   Type: Standards Track
   Created: 2017-07-12
   License: BSD-2-Clause

From 88fb2052647f5f7a73127dad7ad6f4d46149cf79 Mon Sep 17 00:00:00 2001
From: Andrew Chow 
Date: Thu, 14 Jan 2021 16:09:52 -0500
Subject: [PATCH 7/7] Combine Appendix with field listing tables

---
 bip-0174.mediawiki | 152 ++++++++-------------------------------------
 1 file changed, 26 insertions(+), 126 deletions(-)

diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki
index 303c0013..81958fdd 100644
--- a/bip-0174.mediawiki
+++ b/bip-0174.mediawiki
@@ -94,6 +94,7 @@ The currently defined global types are as follows:
 ! Versions Requiring Inclusion
 ! Versions Requiring Exclusion
 ! Versions Allowing Inclusion
+! Parent BIP
 |-
 | Unsigned Transaction
 | PSBT_GLOBAL_UNSIGNED_TX = 0x00
@@ -104,6 +105,7 @@ The currently defined global types are as follows:
 | 0
 |
 | 0
+| 174
 |-
 | Extended Public Key
 | PSBT_GLOBAL_XPUB = 0x01
@@ -114,6 +116,7 @@ The currently defined global types are as follows:
 |
 |
 | 0
+| 174
 |-
 | PSBT Version Number
 | PSBT_GLOBAL_VERSION = 0xFB
@@ -124,6 +127,7 @@ The currently defined global types are as follows:
 |
 |
 | 0
+| 174
 |-
 | Proprietary Use Type
 | PSBT_GLOBAL_PROPRIETARY = 0xFC
@@ -134,6 +138,7 @@ The currently defined global types are as follows:
 |
 |
 | 0
+| 174
 |}
 
 The currently defined per-input types are defined as follows:
@@ -148,6 +153,7 @@ The currently defined per-input types are defined as follows:
 ! Versions Requiring Inclusion
 ! Versions Requiring Exclusion
 ! Versions Allowing Inclusion
+! Parent BIP
 |-
 | Non-Witness UTXO
 | PSBT_IN_NON_WITNESS_UTXO = 0x00
@@ -158,6 +164,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | Witness UTXO
 | PSBT_IN_WITNESS_UTXO = 0x01
@@ -168,6 +175,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | Partial Signature
 | PSBT_IN_PARTIAL_SIG = 0x02
@@ -178,6 +186,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | Sighash Type
 | PSBT_IN_SIGHASH_TYPE = 0x03
@@ -188,6 +197,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | Redeem Script
 | PSBT_IN_REDEEM_SCRIPT = 0x04
@@ -198,6 +208,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | Witness Script
 | PSBT_IN_WITNESS_SCRIPT = 0x05
@@ -208,6 +219,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | BIP 32 Derivation Path
 | PSBT_IN_BIP32_DERIVATION = 0x06
@@ -218,6 +230,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | Finalized scriptSig
 | PSBT_IN_FINAL_SCRIPTSIG = 0x07
@@ -228,6 +241,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | Finalized scriptWitness
 | PSBT_IN_FINAL_SCRIPTWITNESS = 0x08
@@ -238,6 +252,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | Proof-of-reserves commitment
 | PSBT_IN_POR_COMMITMENT = 0x09
@@ -248,6 +263,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| [[bip-0127.mediawiki|127]]
 |-
 | RIPEMD160 preimage
 | PSBT_IN_RIPEMD160 = 0x0a
@@ -258,6 +274,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | SHA256 preimage
 | PSBT_IN_SHA256 = 0x0b
@@ -268,6 +285,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | HASH160 preimage
 | PSBT_IN_HASH160 = 0x0c
@@ -278,6 +296,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | HASH256 preimage
 | PSBT_IN_HASH256 = 0x0d
@@ -288,6 +307,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |-
 | Proprietary Use Type
 | PSBT_IN_PROPRIETARY = 0xFC
@@ -298,6 +318,7 @@ The currently defined per-input types are defined as follows:
 |
 |
 | 0
+| 174
 |}
 
 The currently defined per-output '''Why do we need per-output data?''' Per-output data allows signers
@@ -314,6 +335,7 @@ determine which outputs are change outputs and verify that the change is returni
 ! Versions Requiring Inclusion
 ! Versions Requiring Exclusion
 ! Versions Allowing Inclusion
+! Parent BIP
 |-
 | Redeem Script
 | PSBT_OUT_REDEEM_SCRIPT = 0x00
@@ -324,6 +346,7 @@ determine which outputs are change outputs and verify that the change is returni
 |
 |
 | 0
+| 174
 |-
 | Witness Script
 | PSBT_OUT_WITNESS_SCRIPT = 0x01
@@ -334,6 +357,7 @@ determine which outputs are change outputs and verify that the change is returni
 |
 |
 | 0
+| 174
 |-
 | BIP 32 Derivation Path
 | PSBT_OUT_BIP32_DERIVATION = 0x02
@@ -344,6 +368,7 @@ determine which outputs are change outputs and verify that the change is returni
 |
 |
 | 0
+| 174
 |-
 | Proprietary Use Type
 | PSBT_OUT_PROPRIETARY = 0xFC
@@ -354,6 +379,7 @@ determine which outputs are change outputs and verify that the change is returni
 |
 |
 | 0
+| 174
 |}
 
 Types can be skipped when they are unnecessary. For example, if an input is a witness
@@ -817,129 +843,3 @@ and for coming up with the name and abbreviation of PSBT.
 
 Thanks to Pieter Wuille, Gregory Maxwell, Jonathan Underwood, Daniel Cousens and those who commented on the bitcoin-dev mailing list for additional comments
 and suggestions for improving this proposal.
-
-==Appendix A: Data types and their specifications==
-
-Any data types, their associated scope and BIP number must be defined here
-
-{| class="wikitable" style="width: auto; text-align: center; font-size: smaller; table-layout: fixed;"
-!Scope
-!Type values
-!Name
-!BIP Number
-|-
-| Global
-| 0
-| PSBT_GLOBAL_UNSIGNED_TX
-| BIP 174
-|-
-| Global
-| 1
-| PSBT_GLOBAL_XPUB
-| BIP 174
-|-
-| Global
-| 251
-| PSBT_GLOBAL_VERSION
-| BIP 174
-|-
-| Global
-| 252
-| PSBT_GLOBAL_PROPRIETARY
-| BIP 174
-|-
-| Input
-| 0
-| PSBT_IN_NON_WITNESS_UTXO
-| BIP 174
-|-
-| Input
-| 1
-| PSBT_IN_WITNESS_UTXO
-| BIP 174
-|-
-| Input
-| 2
-| PSBT_IN_PARTIAL_SIG
-| BIP 174
-|-
-| Input
-| 3
-| PSBT_IN_SIGHASH_TYPE
-| BIP 174
-|-
-| Input
-| 4
-| PSBT_IN_REDEEM_SCRIPT
-| BIP 174
-|-
-| Input
-| 5
-| PSBT_IN_WITNESS_SCRIPT
-| BIP 174
-|-
-| Input
-| 6
-| PSBT_IN_BIP32_DERIVATION
-| BIP 174
-|-
-| Input
-| 7
-| PSBT_IN_FINAL_SCRIPTSIG
-| BIP 174
-|-
-| Input
-| 8
-| PSBT_IN_FINAL_SCRIPTWITNESS
-| BIP 174
-|-
-| Input
-| 9
-| PSBT_IN_POR_COMMITMENT
-| [[bip-0127.mediawiki|BIP 127]]
-|-
-| Input
-| 10
-| PSBT_IN_RIPEMD160
-| BIP 174
-|-
-| Input
-| 11
-| PSBT_IN_SHA256
-| BIP 174
-|-
-| Input
-| 12
-| PSBT_IN_HASH160
-| BIP 174
-|-
-| Input
-| 13
-| PSBT_IN_HASH256
-| BIP 174
-|-
-| Input
-| 252
-| PSBT_IN_PROPRIETARY
-| BIP 174
-|-
-| Output
-| 0
-| PSBT_OUT_REDEEM_SCRIPT
-| BIP 174
-|-
-| Output
-| 1
-| PSBT_OUT_WITNESS_SCRIPT
-| BIP 174
-|-
-| Output
-| 2
-| PSBT_OUT_BIP32_DERIVATION
-| BIP 174
-|-
-| Output
-| 252
-| PSBT_OUT_PROPRIETARY
-| BIP 174
-|}