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 : namespace node { 11 : /** 12 : * Holds an analysis of one input from a PSBT 13 : */ 14 0 : struct PSBTInputAnalysis { 15 : bool has_utxo; //!< Whether we have UTXO information for this input 16 : bool is_final; //!< Whether the input has all required information including signatures 17 : PSBTRole next; //!< Which of the BIP 174 roles needs to handle this input next 18 : 19 : std::vector<CKeyID> missing_pubkeys; //!< Pubkeys whose BIP32 derivation path is missing 20 : std::vector<CKeyID> missing_sigs; //!< Pubkeys whose signatures are missing 21 : uint160 missing_redeem_script; //!< Hash160 of redeem script, if missing 22 : }; 23 : 24 : /** 25 : * Holds the results of AnalyzePSBT (miscellaneous information about a PSBT) 26 : */ 27 : struct PSBTAnalysis { 28 : std::optional<size_t> estimated_vsize; //!< Estimated weight of the transaction 29 : std::optional<CFeeRate> estimated_feerate; //!< Estimated feerate (fee / weight) of the transaction 30 : std::optional<CAmount> fee; //!< Amount of fee being paid by the transaction 31 : std::vector<PSBTInputAnalysis> inputs; //!< More information about the individual inputs of the transaction 32 : PSBTRole next; //!< Which of the BIP 174 roles needs to handle the transaction next 33 : std::string error; //!< Error message 34 : 35 0 : void SetInvalid(std::string err_msg) 36 : { 37 0 : estimated_vsize = std::nullopt; 38 0 : estimated_feerate = std::nullopt; 39 0 : fee = std::nullopt; 40 0 : inputs.clear(); 41 0 : next = PSBTRole::CREATOR; 42 0 : error = err_msg; 43 0 : } 44 : }; 45 : 46 : /** 47 : * Provides helpful miscellaneous information about where a PSBT is in the signing workflow. 48 : * 49 : * @param[in] psbtx the PSBT to analyze 50 : * @return A PSBTAnalysis with information about the provided PSBT. 51 : */ 52 : PSBTAnalysis AnalyzePSBT(PartiallySignedTransaction psbtx); 53 : } // namespace node 54 : 55 : #endif // BITCOIN_NODE_PSBT_H