Bitcoin ABC 0.30.7
P2P Digital Currency
Classes | Enumerations | Functions | Variables
psbt.h File Reference
#include <node/transaction.h>
#include <primitives/transaction.h>
#include <pubkey.h>
#include <script/sign.h>
#include <script/signingprovider.h>
#include <optional>
Include dependency graph for psbt.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  PSBTInput
 A structure for PSBTs which contain per-input information. More...
 
struct  PSBTOutput
 A structure for PSBTs which contains per output information. More...
 
struct  PartiallySignedTransaction
 A version of CTransaction with the PSBT format. More...
 

Enumerations

enum class  PSBTRole {
  CREATOR , UPDATER , SIGNER , FINALIZER ,
  EXTRACTOR
}
 

Functions

std::string PSBTRoleName (PSBTRole role)
 
bool PSBTInputSigned (const PSBTInput &input)
 Checks whether a PSBTInput is already signed. More...
 
bool SignPSBTInput (const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, SigHashType sighash=SigHashType(), SignatureData *out_sigdata=nullptr, bool use_dummy=false)
 Signs a PSBTInput, verifying that all provided data matches what is being signed. More...
 
void UpdatePSBTOutput (const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
 Updates a PSBTOutput with information from provider. More...
 
bool FinalizePSBT (PartiallySignedTransaction &psbtx)
 Finalizes a PSBT if possible, combining partial signatures. More...
 
bool FinalizeAndExtractPSBT (PartiallySignedTransaction &psbtx, CMutableTransaction &result)
 Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized. More...
 
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. More...
 
bool DecodeBase64PSBT (PartiallySignedTransaction &decoded_psbt, const std::string &base64_psbt, std::string &error)
 Decode a base64ed PSBT into a PartiallySignedTransaction. More...
 
bool DecodeRawPSBT (PartiallySignedTransaction &decoded_psbt, Span< const std::byte > 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_UTXO = 0x00
 
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_BIP32_DERIVATION = 0x06
 
static constexpr uint8_t PSBT_IN_SCRIPTSIG = 0x07
 
static constexpr uint8_t PSBT_OUT_REDEEMSCRIPT = 0x00
 
static constexpr uint8_t PSBT_OUT_BIP32_DERIVATION = 0x02
 
static constexpr uint8_t PSBT_SEPARATOR = 0x00
 
const std::streamsize MAX_FILE_SIZE_PSBT = 100000000
 

Enumeration Type Documentation

◆ PSBTRole

enum class PSBTRole
strong
Enumerator
CREATOR 
UPDATER 
SIGNER 
FINALIZER 
EXTRACTOR 

Definition at line 506 of file psbt.h.

Function Documentation

◆ CombinePSBTs()

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)

Definition at line 264 of file psbt.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DecodeBase64PSBT()

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

Decode a base64ed PSBT into a PartiallySignedTransaction.

Definition at line 296 of file psbt.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DecodeRawPSBT()

bool DecodeRawPSBT ( PartiallySignedTransaction decoded_psbt,
Span< const std::byte >  raw_psbt,
std::string &  error 
)

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

Definition at line 306 of file psbt.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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]psbtxPartiallySignedTransaction
[out]resultCMutableTransaction representing the complete transaction, if successful
Returns
True if we successfully extracted the transaction, false otherwise

Definition at line 247 of file psbt.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ FinalizePSBT()

bool FinalizePSBT ( PartiallySignedTransaction psbtx)

Finalizes a PSBT if possible, combining partial signatures.

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

Definition at line 232 of file psbt.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PSBTInputSigned()

bool PSBTInputSigned ( const PSBTInput input)

Checks whether a PSBTInput is already signed.

Definition at line 160 of file psbt.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ PSBTRoleName()

std::string PSBTRoleName ( PSBTRole  role)

Definition at line 279 of file psbt.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SignPSBTInput()

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

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

Definition at line 186 of file psbt.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Definition at line 164 of file psbt.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ MAX_FILE_SIZE_PSBT

const std::streamsize MAX_FILE_SIZE_PSBT = 100000000

Definition at line 41 of file psbt.h.

◆ PSBT_GLOBAL_UNSIGNED_TX

constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX = 0x00
staticconstexpr

Definition at line 20 of file psbt.h.

◆ PSBT_IN_BIP32_DERIVATION

constexpr uint8_t PSBT_IN_BIP32_DERIVATION = 0x06
staticconstexpr

Definition at line 27 of file psbt.h.

◆ PSBT_IN_PARTIAL_SIG

constexpr uint8_t PSBT_IN_PARTIAL_SIG = 0x02
staticconstexpr

Definition at line 24 of file psbt.h.

◆ PSBT_IN_REDEEMSCRIPT

constexpr uint8_t PSBT_IN_REDEEMSCRIPT = 0x04
staticconstexpr

Definition at line 26 of file psbt.h.

◆ PSBT_IN_SCRIPTSIG

constexpr uint8_t PSBT_IN_SCRIPTSIG = 0x07
staticconstexpr

Definition at line 28 of file psbt.h.

◆ PSBT_IN_SIGHASH

constexpr uint8_t PSBT_IN_SIGHASH = 0x03
staticconstexpr

Definition at line 25 of file psbt.h.

◆ PSBT_IN_UTXO

constexpr uint8_t PSBT_IN_UTXO = 0x00
staticconstexpr

Definition at line 23 of file psbt.h.

◆ PSBT_MAGIC_BYTES

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

Definition at line 17 of file psbt.h.

◆ PSBT_OUT_BIP32_DERIVATION

constexpr uint8_t PSBT_OUT_BIP32_DERIVATION = 0x02
staticconstexpr

Definition at line 32 of file psbt.h.

◆ PSBT_OUT_REDEEMSCRIPT

constexpr uint8_t PSBT_OUT_REDEEMSCRIPT = 0x00
staticconstexpr

Definition at line 31 of file psbt.h.

◆ PSBT_SEPARATOR

constexpr uint8_t PSBT_SEPARATOR = 0x00
staticconstexpr

Definition at line 37 of file psbt.h.