From b3d224f384f3bae6e38d4fcf0028b046b414784b Mon Sep 17 00:00:00 2001
From: Andrew Chow <achow101-github@achow101.com>
Date: Thu, 14 Jan 2021 15:04:06 -0500
Subject: Specify BIP 370 PSBTv2

---
 bip-0174.mediawiki | 189 ++++++++++++++++++++++++++++++++++++++++++++++-------
 1 file changed, 166 insertions(+), 23 deletions(-)

(limited to 'bip-0174.mediawiki')

diff --git a/bip-0174.mediawiki b/bip-0174.mediawiki
index c034f05..6f50891 100644
--- a/bip-0174.mediawiki
+++ b/bip-0174.mediawiki
@@ -115,9 +115,75 @@ The currently defined global types are as follows:
 | 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
+| 0, 2
 | 174
 |-
+| Transaction Version
+| <tt>PSBT_GLOBAL_TX_VERSION = 0x02</tt>
+| None
+| No key data
+| <tt><32-bit uint></tt>
+| The 32-bit little endian signed integer representing the version number of the transaction being created. Note that this is not the same as the PSBT version number specified by the PSBT_GLOBAL_VERSION field.
+| 2
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
+| Fallback Locktime
+| <tt>PSBT_GLOBAL_FALLBACK_LOCKTIME = 0x03</tt>
+| None
+| No key data
+| <tt><32-bit uint></tt>
+| The 32-bit little endian unsigned integer representing the transaction locktime to use if no inputs specify a required locktime.
+|
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
+| Input Count
+| <tt>PSBT_GLOBAL_INPUT_COUNT = 0x04</tt>
+| None
+| No key data
+| <tt><compact size uint></tt>
+| Compact size unsigned integer representing the number of inputs in this PSBT.
+| 2
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
+| Output Count
+| <tt>PSBT_GLOBAL_OUTPUT_COUNT = 0x05</tt>
+| None
+| No key data
+| <tt><compact size uint></tt>
+| Compact size unsigned integer representing the number of outputs in this PSBT.
+| 2
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
+| Transaction Modifiable Flags
+| <tt>PSBT_GLOBAL_TX_MODIFIABLE = 0x06</tt>
+| None
+| No key data
+| <tt><single byte boolean> <single byte boolean> <bitvector></tt>
+| A single byte boolean (0 for False, 1 for True) representing whether inputs can be modified, followed by a single byte boolean representing whether outputs can be modified.
+|
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
+| SIGHASH_SINGLE Inputs
+| <tt>PSBT_GLOBAL_SIGHASH_SINGLE_INPUTS = 0x07</tt>
+| None
+| No key data
+| <tt><bit vector></tt>
+| A bit vector representing which input indexes use SIGHASH_SINGLE. If the bit for an index is set to 1, then the input and output pair at that index are tied together with SIGHASH_SINGLE and must be moved together.
+|
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
 | PSBT Version Number
 | <tt>PSBT_GLOBAL_VERSION = 0xFB</tt>
 | None
@@ -126,7 +192,7 @@ The currently defined global types are as follows:
 | The 32-bit little endian unsigned integer representing the version number of this PSBT. If ommitted, the version number is 0.
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | Proprietary Use Type
@@ -137,7 +203,7 @@ The currently defined global types are as follows:
 | Any value data as defined by the proprietary type user.
 |
 |
-| 0
+| 0, 2
 | 174
 |}
 
@@ -163,18 +229,18 @@ The currently defined per-input types are defined as follows:
 | 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 <tt>PSBT_IN_NON_WITNESS_UTXO</tt> and <tt>PSBT_IN_WITNESS_UTXO</tt>. <ref>'''Why can both UTXO types be provided?''' Many wallets began requiring the full previous transaction (i.e. <tt>PSBT_IN_NON_WITNESS_UTXO</tt>) for segwit inputs when PSBT was already in use. In order to be compatible with software which were expecting <tt>PSBT_IN_WITNESS_UTXO</tt>, both UTXO types must be allowed.</ref>
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | Witness UTXO
 | <tt>PSBT_IN_WITNESS_UTXO = 0x01</tt>
 | None
 | No key data
-| <tt><64-bit uint> <scriptPubKeylen> <scriptPubKey></tt>
+| <tt><64-bit int> <scriptPubKeylen> <scriptPubKey></tt>
 | 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 <tt>PSBT_IN_NON_WITNESS_UTXO</tt> and <tt>PSBT_IN_WITNESS_UTXO</tt>
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | Partial Signature
@@ -185,7 +251,7 @@ The currently defined per-input types are defined as follows:
 | The signature as would be pushed to the stack from a scriptSig or witness.
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | Sighash Type
@@ -196,7 +262,7 @@ The currently defined per-input types are defined as follows:
 | 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
+| 0, 2
 | 174
 |-
 | Redeem Script
@@ -207,7 +273,7 @@ The currently defined per-input types are defined as follows:
 | The redeemScript for this input if it has one.
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | Witness Script
@@ -218,7 +284,7 @@ The currently defined per-input types are defined as follows:
 | The witnessScript for this input if it has one.
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | BIP 32 Derivation Path
@@ -229,7 +295,7 @@ The currently defined per-input types are defined as follows:
 | 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
+| 0, 2
 | 174
 |-
 | Finalized scriptSig
@@ -240,7 +306,7 @@ The currently defined per-input types are defined as follows:
 | The Finalized scriptSig contains a fully constructed scriptSig with signatures and any other scripts necessary for the input to pass validation.
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | Finalized scriptWitness
@@ -251,7 +317,7 @@ The currently defined per-input types are defined as follows:
 | The Finalized scriptWitness contains a fully constructed scriptWitness with signatures and any other scripts necessary for the input to pass validation.
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | Proof-of-reserves commitment
@@ -262,7 +328,7 @@ The currently defined per-input types are defined as follows:
 | The UTF-8 encoded commitment message string for the proof-of-reserves.  See [[bip-0127.mediawiki|BIP 127]] for more information.
 |
 |
-| 0
+| 0, 2
 | [[bip-0127.mediawiki|127]]
 |-
 | RIPEMD160 preimage
@@ -273,7 +339,7 @@ The currently defined per-input types are defined as follows:
 | The hash preimage, encoded as a byte vector, which must equal the key when run through the <tt>RIPEMD160</tt> algorithm
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | SHA256 preimage
@@ -284,7 +350,7 @@ The currently defined per-input types are defined as follows:
 | The hash preimage, encoded as a byte vector, which must equal the key when run through the <tt>SHA256</tt> algorithm
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | HASH160 preimage
@@ -295,7 +361,7 @@ The currently defined per-input types are defined as follows:
 | The hash preimage, encoded as a byte vector, which must equal the key when run through the <tt>SHA256</tt> algorithm followed by the <tt>RIPEMD160</tt> algorithm
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | HASH256 preimage
@@ -306,9 +372,64 @@ The currently defined per-input types are defined as follows:
 | The hash preimage, encoded as a byte vector, which must equal the key when run through the <tt>SHA256</tt> algorithm twice
 |
 |
-| 0
+| 0, 2
 | 174
 |-
+| Previous TXID
+| <tt>PSBT_IN_PREVIOUS_TXID = 0x0e</tt>
+| None
+| No key data
+| <tt><txid></tt>
+| 32 byte txid of the previous transaction whose output at PSBT_IN_OUTPUT_INDEX is being spent.
+| 2
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
+| Spent Output Index
+| <tt>PSBT_IN_OUTPUT_INDEX = 0x0f</tt>
+| None
+| No key data
+| <tt><32-bit uint></tt>
+| 32 bit little endian integer representing the index of the output being spent in the transaction with the txid of PSBT_IN_PREVIOUS_TXID.
+| 2
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
+| Sequence Number
+| <tt>PSBT_IN_SEQUENCE = 0x10</tt>
+| None
+| No key data
+| <tt><32-bit uint></tt>
+| The 32 bit unsigned little endian integer for the sequence number of this input. If omitted, the sequence number is assumed to be the final sequence number (0xffffffff).
+|
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
+| Required Time-based Locktime
+| <tt>PSBT_IN_REQUIRED_TIME_LOCKTIME = 0x11</tt>
+| None
+| No key data
+| <tt><32-bit uint></tt>
+| 32 bit unsigned little endian integer greater than or equal to 500000000 representing the minimum Unix timestamp that this input requires to be set as the transaction's lock time.
+|
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
+| Required Height-based Locktime
+| <tt>PSBT_IN_REQUIRED_HEIGHT_LOCKTIME = 0x12</tt>
+| None
+| No key data
+| <tt><32-bit uiht></tt>
+| 32 bit unsigned little endian integer less than 500000000 representing the minimum block height that this input requires to be set as the transaction's lock time.
+|
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
 | Proprietary Use Type
 | <tt>PSBT_IN_PROPRIETARY = 0xFC</tt>
 | <tt><identifierlen> <identifier> <subtype> <subkeydata></tt>
@@ -317,7 +438,7 @@ The currently defined per-input types are defined as follows:
 | Any value data as defined by the proprietary type user.
 |
 |
-| 0
+| 0, 2
 | 174
 |}
 
@@ -345,7 +466,7 @@ determine which outputs are change outputs and verify that the change is returni
 | The redeemScript for this output if it has one.
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | Witness Script
@@ -356,7 +477,7 @@ determine which outputs are change outputs and verify that the change is returni
 | The witnessScript for this output if it has one.
 |
 |
-| 0
+| 0, 2
 | 174
 |-
 | BIP 32 Derivation Path
@@ -367,9 +488,31 @@ determine which outputs are change outputs and verify that the change is returni
 | 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
+| 0, 2
 | 174
 |-
+| Output Amount
+| <tt>PSBT_OUT_AMOUNT = 0x03</tt>
+| None
+| No key data
+| <tt><64-bit int></tt>
+| 64 bit signed little endian integer representing the output's amount in satoshis.
+| 2
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
+| Output Script
+| <tt>PSBT_OUT_SCRIPT = 0x03</tt>
+| None
+| No key data
+| <tt><script></tt>
+| The script for this output, also known as the scriptPubKey. Must be omitted in PSBTv0. Must be provided in PSBTv2.
+| 2
+| 0
+| 2
+| [[bip-psb2.mediawiki|psbt2]]
+|-
 | Proprietary Use Type
 | <tt>PSBT_OUT_PROPRIETARY = 0xFC</tt>
 | <tt><identifierlen> <identifier> <subtype> <subkeydata></tt>
@@ -378,7 +521,7 @@ determine which outputs are change outputs and verify that the change is returni
 | Any value data as defined by the proprietary type user.
 |
 |
-| 0
+| 0, 2
 | 174
 |}
 
-- 
cgit v1.2.3

