Bitcoin
Classes | Enumerations | Functions | Variables
psbt.h File Reference
#include <attributes.h>
#include <node/transaction.h>
#include <optional.h>
#include <policy/feerate.h>
#include <primitives/transaction.h>
#include <pubkey.h>
#include <script/sign.h>
#include <script/signingprovider.h>

Go to the source code of this file.

Classes

struct  PSBTInput
 
struct  PSBTOutput
 
struct  PartiallySignedTransaction
 

Enumerations

enum  PSBTRole { PSBTRole::UPDATER, PSBTRole::SIGNER, PSBTRole::FINALIZER, PSBTRole::EXTRACTOR }
 

Functions

std::string PSBTRoleName (PSBTRole role)
 
bool PSBTInputSigned (const PSBTInput &input)
 
bool SignPSBTInput (const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, int sighash=SIGHASH_ALL, SignatureData *out_sigdata=nullptr, bool use_dummy=false)
 
void UpdatePSBTOutput (const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
 
bool FinalizePSBT (PartiallySignedTransaction &psbtx)
 
bool FinalizeAndExtractPSBT (PartiallySignedTransaction &psbtx, CMutableTransaction &result)
 
NODISCARD TransactionError CombinePSBTs (PartiallySignedTransaction &out, const std::vector< PartiallySignedTransaction > &psbtxs)
 
NODISCARD bool DecodeBase64PSBT (PartiallySignedTransaction &decoded_psbt, const std::string &base64_psbt, std::string &error)
 Decode a base64ed PSBT into a PartiallySignedTransaction. More...
 
NODISCARD bool DecodeRawPSBT (PartiallySignedTransaction &decoded_psbt, const std::string &raw_psbt, std::string &error)
 Decode a raw (binary blob) PSBT into a PartiallySignedTransaction. More...
 

Variables

static constexpr uint8_t PSBT_MAGIC_BYTES [5] = {'p', 's', 'b', 't', 0xff}
 
static constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX = 0x00
 
static constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO = 0x00
 
static constexpr uint8_t PSBT_IN_WITNESS_UTXO = 0x01
 
static constexpr uint8_t PSBT_IN_PARTIAL_SIG = 0x02
 
static constexpr uint8_t PSBT_IN_SIGHASH = 0x03
 
static constexpr uint8_t PSBT_IN_REDEEMSCRIPT = 0x04
 
static constexpr uint8_t PSBT_IN_WITNESSSCRIPT = 0x05
 
static constexpr uint8_t PSBT_IN_BIP32_DERIVATION = 0x06
 
static constexpr uint8_t PSBT_IN_SCRIPTSIG = 0x07
 
static constexpr uint8_t PSBT_IN_SCRIPTWITNESS = 0x08
 
static constexpr uint8_t PSBT_OUT_REDEEMSCRIPT = 0x00
 
static constexpr uint8_t PSBT_OUT_WITNESSSCRIPT = 0x01
 
static constexpr uint8_t PSBT_OUT_BIP32_DERIVATION = 0x02
 
static constexpr uint8_t PSBT_SEPARATOR = 0x00
 

Enumeration Type Documentation

◆ PSBTRole

enum PSBTRole
strong
Enumerator
UPDATER 
SIGNER 
FINALIZER 
EXTRACTOR 

Function Documentation

◆ CombinePSBTs()

NODISCARD TransactionError CombinePSBTs ( PartiallySignedTransaction out,
const std::vector< PartiallySignedTransaction > &  psbtxs 
)

Combines PSBTs with the same underlying transaction, resulting in a single PSBT with all partial signatures from each input.

Parameters
[out]&outthe combined PSBT, if successful
[in]psbtxsthe PSBTs to combine
Returns
error (OK if we successfully combined the transactions, other error if they were not compatible)

◆ DecodeBase64PSBT()

NODISCARD bool DecodeBase64PSBT ( PartiallySignedTransaction decoded_psbt,
const std::string &  base64_psbt,
std::string &  error 
)

Decode a base64ed PSBT into a PartiallySignedTransaction.

◆ DecodeRawPSBT()

NODISCARD bool DecodeRawPSBT ( PartiallySignedTransaction decoded_psbt,
const std::string &  raw_psbt,
std::string &  error 
)

Decode a raw (binary blob) PSBT into a PartiallySignedTransaction.

◆ FinalizeAndExtractPSBT()

bool FinalizeAndExtractPSBT ( PartiallySignedTransaction psbtx,
CMutableTransaction result 
)

Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized.

Parameters
[in]&psbtxreference to PartiallySignedTransaction
[out]resultCMutableTransaction representing the complete transaction, if successful
Returns
True if we successfully extracted the transaction, false otherwise

◆ FinalizePSBT()

bool FinalizePSBT ( PartiallySignedTransaction psbtx)

Finalizes a PSBT if possible, combining partial signatures.

Parameters
[in,out]&psbtxreference to PartiallySignedTransaction to finalize return True if the PSBT is now complete, false otherwise

◆ PSBTInputSigned()

bool PSBTInputSigned ( const PSBTInput input)

Checks whether a PSBTInput is already signed.

◆ PSBTRoleName()

std::string PSBTRoleName ( PSBTRole  role)

◆ SignPSBTInput()

bool SignPSBTInput ( const SigningProvider provider,
PartiallySignedTransaction psbt,
int  index,
int  sighash = SIGHASH_ALL,
SignatureData out_sigdata = nullptr,
bool  use_dummy = false 
)

Signs a PSBTInput, verifying that all provided data matches what is being signed.

◆ UpdatePSBTOutput()

void UpdatePSBTOutput ( const SigningProvider provider,
PartiallySignedTransaction psbt,
int  index 
)

Updates a PSBTOutput with information from provider.

This fills in the redeem_script, witness_script, and hd_keypaths where possible.

Variable Documentation

◆ PSBT_GLOBAL_UNSIGNED_TX

constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX = 0x00
static

◆ PSBT_IN_BIP32_DERIVATION

constexpr uint8_t PSBT_IN_BIP32_DERIVATION = 0x06
static

◆ PSBT_IN_NON_WITNESS_UTXO

constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO = 0x00
static

◆ PSBT_IN_PARTIAL_SIG

constexpr uint8_t PSBT_IN_PARTIAL_SIG = 0x02
static

◆ PSBT_IN_REDEEMSCRIPT

constexpr uint8_t PSBT_IN_REDEEMSCRIPT = 0x04
static

◆ PSBT_IN_SCRIPTSIG

constexpr uint8_t PSBT_IN_SCRIPTSIG = 0x07
static

◆ PSBT_IN_SCRIPTWITNESS

constexpr uint8_t PSBT_IN_SCRIPTWITNESS = 0x08
static

◆ PSBT_IN_SIGHASH

constexpr uint8_t PSBT_IN_SIGHASH = 0x03
static

◆ PSBT_IN_WITNESS_UTXO

constexpr uint8_t PSBT_IN_WITNESS_UTXO = 0x01
static

◆ PSBT_IN_WITNESSSCRIPT

constexpr uint8_t PSBT_IN_WITNESSSCRIPT = 0x05
static

◆ PSBT_MAGIC_BYTES

constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff}
static

◆ PSBT_OUT_BIP32_DERIVATION

constexpr uint8_t PSBT_OUT_BIP32_DERIVATION = 0x02
static

◆ PSBT_OUT_REDEEMSCRIPT

constexpr uint8_t PSBT_OUT_REDEEMSCRIPT = 0x00
static

◆ PSBT_OUT_WITNESSSCRIPT

constexpr uint8_t PSBT_OUT_WITNESSSCRIPT = 0x01
static

◆ PSBT_SEPARATOR

constexpr uint8_t PSBT_SEPARATOR = 0x00
static