diff options
Diffstat (limited to 'src/psbt.h')
-rw-r--r-- | src/psbt.h | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/src/psbt.h b/src/psbt.h index d89fd68c21..0f17a71a44 100644 --- a/src/psbt.h +++ b/src/psbt.h @@ -7,6 +7,8 @@ #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> @@ -548,8 +550,36 @@ struct PartiallySignedTransaction } }; +enum class PSBTRole { + UPDATER, + SIGNER, + FINALIZER, + EXTRACTOR +}; + +struct PSBTInputAnalysis { + bool has_utxo; + bool is_final; + PSBTRole next; + + std::vector<CKeyID> missing_pubkeys; + std::vector<CKeyID> missing_sigs; + uint160 missing_redeem_script; + uint256 missing_witness_script; +}; + +struct PSBTAnalysis { + Optional<size_t> estimated_vsize; + Optional<CFeeRate> estimated_feerate; + Optional<CAmount> fee; + std::vector<PSBTInputAnalysis> inputs; + PSBTRole next; +}; + +std::string PSBTRoleName(PSBTRole role); + /** Checks whether a PSBTInput is already signed. */ -bool PSBTInputSigned(PSBTInput& input); +bool PSBTInputSigned(const PSBTInput& input); /** Signs a PSBTInput, verifying that all provided data matches what is being signed. */ bool SignPSBTInput(const SigningProvider& provider, PartiallySignedTransaction& psbt, int index, int sighash = SIGHASH_ALL, SignatureData* out_sigdata = nullptr, bool use_dummy = false); @@ -580,6 +610,14 @@ bool FinalizeAndExtractPSBT(PartiallySignedTransaction& psbtx, CMutableTransacti */ NODISCARD TransactionError CombinePSBTs(PartiallySignedTransaction& out, 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 NODISCARD bool DecodeBase64PSBT(PartiallySignedTransaction& decoded_psbt, const std::string& base64_psbt, std::string& error); //! Decode a raw (binary blob) PSBT into a PartiallySignedTransaction |