BIP 370: PSBT Version 2

2021-01-14

  BIP: 370
  Layer: Applications
  Title: PSBT Version 2
  Author: Andrew Chow <achow101@gmail.com>
  Comments-Summary: No comments yet.
  Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0370
  Status: Draft
  Type: Standards Track
  Created: 2021-01-14
  License: BSD-2-Clause

Introduction

Abstract

This document proposes a second version of the Partially Signed Bitcoin Transaction format described in BIP 174 which allows for inputs and outputs to be added to the PSBT after creation.

This BIP is licensed under the 2-clause BSD license.

Motivation

Partially Signed Bitcoin Transaction Version 0 as described in BIP 174 is unable to have new inputs and outputs be added to the transaction. The fixed global unsigned transaction cannot be changed which prevents any additional inputs or outputs to be added. PSBT Version 2 is intended to rectify this problem.

An additional benficial side effect is that all information for a given input or output will be provided by its or . With Version 0, to retrieve all of the information for an input or output, data would need to be found in two locations: the / and the global unsigned transaction. PSBT Version 2 now moves all related information to one place.

Specification

PSBT Version 2 (PSBTv2) only specifies new fields and field inclusion/exclusion requirements.

PSBT_GLOBAL_UNSIGNED_TX must be excluded in PSBTv2. PSBT_GLOBAL_VERSION must be included in PSBTv2 and set to version number 2[1].

The new global types for PSBT Version 2 are as follows:

Name Description DescriptionVersions Requiring InclusionVersions Requiring ExclusionVersions Allowing Inclusion
Transaction VersionPSBT_GLOBAL_TX_VERSION = 0x02NoneNo key data<32-bit uint>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.202
Fallback LocktimePSBT_GLOBAL_FALLBACK_LOCKTIME = 0x03NoneNo key data<32-bit uint>The 32-bit little endian unsigned integer representing the transaction locktime to use if no inputs specify a required locktime.02
Input CountPSBT_GLOBAL_INPUT_COUNT = 0x04NoneNo key dataCompact size unsigned integer representing the number of inputs in this PSBT.202
Output CountPSBT_GLOBAL_OUTPUT_COUNT = 0x05NoneNo key dataCompact size unsigned integer representing the number of outputs in this PSBT.202
Transaction Modifiable FlagsPSBT_GLOBAL_TX_MODIFIABLE = 0x06NoneNo key data<8-bit uint>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. Bit 2 essentially indicates that the Constructor must iterate the inputs to determine whether and how to add an input.02

The new per-input types for PSBT Version 2 are defined as follows:

Name Description DescriptionVersions Requiring InclusionVersions Requiring ExclusionVersions Allowing Inclusion
Previous TXIDPSBT_IN_PREVIOUS_TXID = 0x0eNoneNo key data32 byte txid of the previous transaction whose output at PSBT_IN_OUTPUT_INDEX is being spent.202
Spent Output IndexPSBT_IN_OUTPUT_INDEX = 0x0fNoneNo key data<32-bit uint>32 bit little endian integer representing the index of the output being spent in the transaction with the txid of PSBT_IN_PREVIOUS_TXID.202
Sequence NumberPSBT_IN_SEQUENCE = 0x10NoneNo key data<32-bit uint>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).02
Required Time-based LocktimePSBT_IN_REQUIRED_TIME_LOCKTIME = 0x11NoneNo key data<32-bit uint>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.02
Required Height-based LocktimePSBT_IN_REQUIRED_HEIGHT_LOCKTIME = 0x12NoneNo key data<32-bit uiht>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.02

The new per-output types for PSBT Version 2 are defined as follows:

Name

Description

Description

Versions Requiring Inclusion

Versions Requiring Exclusion

Versions Allowing Inclusion

Output Amount

PSBT_OUT_AMOUNT = 0x03

None

No key data

<64-bit int>

64 bit signed little endian integer representing the output's amount in satoshis.

2

0

2

Output Script

PSBT_OUT_SCRIPT = 0x04

None

No key data