Bitcoin Core 31.99.0
P2P Digital Currency
Functions
psbt.cpp File Reference
#include <psbt.h>
#include <common/types.h>
#include <node/types.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <script/signingprovider.h>
#include <util/check.h>
#include <util/result.h>
#include <util/strencodings.h>
Include dependency graph for psbt.cpp:

Go to the source code of this file.

Functions

bool PSBTInputSigned (const PSBTInput &input)
 Checks whether a PSBTInput is already signed by checking for non-null finalized fields. More...
 
bool PSBTInputSignedAndVerified (const PartiallySignedTransaction &psbt, unsigned int input_index, const PrecomputedTransactionData *txdata)
 Checks whether a PSBTInput is already signed by doing script verification using final fields. More...
 
size_t CountPSBTUnsignedInputs (const PartiallySignedTransaction &psbt)
 Counts the unsigned inputs of a PSBT. More...
 
void UpdatePSBTOutput (const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
 Updates a PSBTOutput with information from provider. More...
 
std::optional< PrecomputedTransactionDataPrecomputePSBTData (const PartiallySignedTransaction &psbt)
 Compute a PrecomputedTransactionData object from a psbt. More...
 
PSBTError SignPSBTInput (const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, const PrecomputedTransactionData *txdata, const common::PSBTFillOptions &options, SignatureData *out_sigdata)
 Signs a PSBTInput, verifying that all provided data matches what is being signed. More...
 
void RemoveUnnecessaryTransactions (PartiallySignedTransaction &psbtx)
 Reduces the size of the PSBT by dropping unnecessary non_witness_utxos (i.e. 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...
 
std::optional< PartiallySignedTransactionCombinePSBTs (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...
 
std::string PSBTRoleName (PSBTRole role)
 
util::Result< PartiallySignedTransactionDecodeBase64PSBT (const std::string &base64_tx)
 Decode a base64ed PSBT into a PartiallySignedTransaction. More...
 
util::Result< PartiallySignedTransactionDecodeRawPSBT (std::span< const std::byte > tx_data)
 Decode a raw (binary blob) PSBT into a PartiallySignedTransaction. More...
 

Function Documentation

◆ CombinePSBTs()

std::optional< PartiallySignedTransaction > CombinePSBTs ( 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
[in]psbtxsthe PSBTs to combine
Returns
The combined PSBT or std::nullopt if the PSBTs cannot be combined

Definition at line 837 of file psbt.cpp.

Here is the caller graph for this function:

◆ CountPSBTUnsignedInputs()

size_t CountPSBTUnsignedInputs ( const PartiallySignedTransaction psbt)

Counts the unsigned inputs of a PSBT.

Definition at line 588 of file psbt.cpp.

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

◆ DecodeBase64PSBT()

util::Result< PartiallySignedTransaction > DecodeBase64PSBT ( const std::string &  base64_tx)

Decode a base64ed PSBT into a PartiallySignedTransaction.

Definition at line 861 of file psbt.cpp.

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

◆ DecodeRawPSBT()

util::Result< PartiallySignedTransaction > DecodeRawPSBT ( std::span< const std::byte >  tx_data)

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

Definition at line 870 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 817 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 797 of file psbt.cpp.

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

◆ PrecomputePSBTData()

std::optional< PrecomputedTransactionData > PrecomputePSBTData ( const PartiallySignedTransaction psbt)

Compute a PrecomputedTransactionData object from a psbt.

Definition at line 623 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 by checking for non-null finalized fields.

Definition at line 549 of file psbt.cpp.

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

◆ PSBTInputSignedAndVerified()

bool PSBTInputSignedAndVerified ( const PartiallySignedTransaction psbt,
unsigned int  input_index,
const PrecomputedTransactionData txdata 
)

Checks whether a PSBTInput is already signed by doing script verification using final fields.

Definition at line 554 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 850 of file psbt.cpp.

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

◆ RemoveUnnecessaryTransactions()

void RemoveUnnecessaryTransactions ( PartiallySignedTransaction psbtx)

Reduces the size of the PSBT by dropping unnecessary non_witness_utxos (i.e.

complete previous transactions) from a psbt when all inputs are segwit v1.

Definition at line 760 of file psbt.cpp.

Here is the caller graph for this function:

◆ SignPSBTInput()

PSBTError SignPSBTInput ( const SigningProvider provider,
PartiallySignedTransaction psbt,
int  index,
const PrecomputedTransactionData txdata,
const common::PSBTFillOptions options,
SignatureData out_sigdata = nullptr 
)

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

txdata should be the output of PrecomputePSBTData (which can be shared across multiple SignPSBTInput calls). If it is nullptr, a dummy signature will be created.

Definition at line 644 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 599 of file psbt.cpp.

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