Branch data Line data Source code
# 1 : : // Copyright (c) 2009-2021 The Bitcoin Core developers # 2 : : // Distributed under the MIT software license, see the accompanying # 3 : : // file COPYING or http://www.opensource.org/licenses/mit-license.php. # 4 : : # 5 : : #ifndef BITCOIN_NODE_PSBT_H # 6 : : #define BITCOIN_NODE_PSBT_H # 7 : : # 8 : : #include <psbt.h> # 9 : : # 10 : : #include <optional> # 11 : : # 12 : : namespace node { # 13 : : /** # 14 : : * Holds an analysis of one input from a PSBT # 15 : : */ # 16 : : struct PSBTInputAnalysis { # 17 : : bool has_utxo; //!< Whether we have UTXO information for this input # 18 : : bool is_final; //!< Whether the input has all required information including signatures # 19 : : PSBTRole next; //!< Which of the BIP 174 roles needs to handle this input next # 20 : : # 21 : : std::vector<CKeyID> missing_pubkeys; //!< Pubkeys whose BIP32 derivation path is missing # 22 : : std::vector<CKeyID> missing_sigs; //!< Pubkeys whose signatures are missing # 23 : : uint160 missing_redeem_script; //!< Hash160 of redeem script, if missing # 24 : : uint256 missing_witness_script; //!< SHA256 of witness script, if missing # 25 : : }; # 26 : : # 27 : : /** # 28 : : * Holds the results of AnalyzePSBT (miscellaneous information about a PSBT) # 29 : : */ # 30 : : struct PSBTAnalysis { # 31 : : std::optional<size_t> estimated_vsize; //!< Estimated weight of the transaction # 32 : : std::optional<CFeeRate> estimated_feerate; //!< Estimated feerate (fee / weight) of the transaction # 33 : : std::optional<CAmount> fee; //!< Amount of fee being paid by the transaction # 34 : : std::vector<PSBTInputAnalysis> inputs; //!< More information about the individual inputs of the transaction # 35 : : PSBTRole next; //!< Which of the BIP 174 roles needs to handle the transaction next # 36 : : std::string error; //!< Error message # 37 : : # 38 : : void SetInvalid(std::string err_msg) # 39 : 8 : { # 40 : 8 : estimated_vsize = std::nullopt; # 41 : 8 : estimated_feerate = std::nullopt; # 42 : 8 : fee = std::nullopt; # 43 : 8 : inputs.clear(); # 44 : 8 : next = PSBTRole::CREATOR; # 45 : 8 : error = err_msg; # 46 : 8 : } # 47 : : }; # 48 : : # 49 : : /** # 50 : : * Provides helpful miscellaneous information about where a PSBT is in the signing workflow. # 51 : : * # 52 : : * @param[in] psbtx the PSBT to analyze # 53 : : * @return A PSBTAnalysis with information about the provided PSBT. # 54 : : */ # 55 : : PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx); # 56 : : } // namespace node # 57 : : # 58 : : #endif // BITCOIN_NODE_PSBT_H