Changeset View
Changeset View
Standalone View
Standalone View
src/psbt.h
Show First 20 Lines • Show All 483 Lines • ▼ Show 20 Lines | |||||
enum class PSBTRole { | enum class PSBTRole { | ||||
UPDATER, | UPDATER, | ||||
SIGNER, | SIGNER, | ||||
FINALIZER, | FINALIZER, | ||||
EXTRACTOR, | EXTRACTOR, | ||||
}; | }; | ||||
/** | |||||
* Holds an analysis of one input from a PSBT | |||||
*/ | |||||
struct PSBTInputAnalysis { | |||||
//! Whether we have UTXO information for this input | |||||
bool has_utxo; | |||||
//! Whether the input has all required information including signatures | |||||
bool is_final; | |||||
//! Which of the BIP 174 roles needs to handle this input next | |||||
PSBTRole next; | |||||
//! Pubkeys whose BIP32 derivation path is missing | |||||
std::vector<CKeyID> missing_pubkeys; | |||||
//! Pubkeys whose signatures are missing | |||||
std::vector<CKeyID> missing_sigs; | |||||
//! Hash160 of redeem script, if missing | |||||
uint160 missing_redeem_script; | |||||
}; | |||||
/** | |||||
* Holds the results of AnalyzePSBT (miscellaneous information about a PSBT) | |||||
*/ | |||||
struct PSBTAnalysis { | |||||
//! Estimated weight of the transaction | |||||
Optional<size_t> estimated_vsize; | |||||
//! Estimated feerate (fee / weight) of the transaction | |||||
Optional<CFeeRate> estimated_feerate; | |||||
//! Amount of fee being paid by the transaction | |||||
Optional<Amount> fee; | |||||
//! More information about the individual inputs of the transaction | |||||
std::vector<PSBTInputAnalysis> inputs; | |||||
//! Which of the BIP 174 roles needs to handle the transaction next | |||||
PSBTRole next; | |||||
}; | |||||
std::string PSBTRoleName(PSBTRole role); | std::string PSBTRoleName(PSBTRole role); | ||||
/** Checks whether a PSBTInput is already signed. */ | /** Checks whether a PSBTInput is already signed. */ | ||||
bool PSBTInputSigned(const PSBTInput &input); | bool PSBTInputSigned(const PSBTInput &input); | ||||
/** | /** | ||||
* Signs a PSBTInput, verifying that all provided data matches what is being | * Signs a PSBTInput, verifying that all provided data matches what is being | ||||
* signed. | * signed. | ||||
Show All 32 Lines | |||||
* @param[in] psbtxs the PSBTs to combine | * @param[in] psbtxs the PSBTs to combine | ||||
* @return error (OK if we successfully combined the transactions, other error | * @return error (OK if we successfully combined the transactions, other error | ||||
* if they were not compatible) | * if they were not compatible) | ||||
*/ | */ | ||||
NODISCARD TransactionError | NODISCARD TransactionError | ||||
CombinePSBTs(PartiallySignedTransaction &out, | CombinePSBTs(PartiallySignedTransaction &out, | ||||
const std::vector<PartiallySignedTransaction> &psbtxs); | const std::vector<PartiallySignedTransaction> &psbtxs); | ||||
/** | |||||
* Provides helpful miscellaneous information about where a PSBT is in the | |||||
* signing workflow. | |||||
* | |||||
* @param[in] psbtx the PSBT to analyze | |||||
* @return A PSBTAnalysis with information about the provided PSBT. | |||||
*/ | |||||
PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx); | |||||
//! Decode a base64ed PSBT into a PartiallySignedTransaction | //! Decode a base64ed PSBT into a PartiallySignedTransaction | ||||
NODISCARD bool DecodeBase64PSBT(PartiallySignedTransaction &decoded_psbt, | NODISCARD bool DecodeBase64PSBT(PartiallySignedTransaction &decoded_psbt, | ||||
const std::string &base64_psbt, | const std::string &base64_psbt, | ||||
std::string &error); | std::string &error); | ||||
//! Decode a raw (binary blob) PSBT into a PartiallySignedTransaction | //! Decode a raw (binary blob) PSBT into a PartiallySignedTransaction | ||||
NODISCARD bool DecodeRawPSBT(PartiallySignedTransaction &decoded_psbt, | NODISCARD bool DecodeRawPSBT(PartiallySignedTransaction &decoded_psbt, | ||||
const std::string &raw_psbt, std::string &error); | const std::string &raw_psbt, std::string &error); | ||||
#endif // BITCOIN_PSBT_H | #endif // BITCOIN_PSBT_H |