76 std::vector<unsigned char>
key;
77 std::vector<unsigned char>
value;
89 template<
typename Stream,
typename...
X>
97 template<
typename Stream,
typename...
X>
101 size_t remaining_before = s.size();
103 size_t remaining_after = s.size();
104 if (remaining_after + expected_size != remaining_before) {
105 throw std::ios_base::failure(
"Size of value was not the stated size");
110 template<
typename Stream>
114 if (length % 4 || length == 0) {
115 throw std::ios_base::failure(
"Invalid length for HD key path");
120 for (
unsigned int i = 4; i < length; i +=
sizeof(uint32_t)) {
123 hd_keypath.
path.push_back(index);
129 template<
typename Stream>
136 template<
typename Stream>
137 void DeserializeHDKeypaths(Stream& s,
const std::vector<unsigned char>& key, std::map<CPubKey, KeyOriginInfo>& hd_keypaths)
141 throw std::ios_base::failure(
"Size of key was not the expected size for the type BIP32 keypath");
144 CPubKey pubkey(key.begin() + 1, key.end());
145 if (!pubkey.IsFullyValid()) {
146 throw std::ios_base::failure(
"Invalid pubkey");
148 if (hd_keypaths.count(pubkey) > 0) {
149 throw std::ios_base::failure(
"Duplicate Key, pubkey derivation path already provided");
156 hd_keypaths.emplace(pubkey, std::move(keypath));
160 template<
typename Stream>
164 for (
const auto& path : hd_keypath.
path) {
170 template<
typename Stream>
178 template<
typename Stream>
181 for (
const auto& keypath_pair : hd_keypaths) {
182 if (!keypath_pair.first.IsValid()) {
183 throw std::ios_base::failure(
"Invalid CPubKey being serialized");
214 std::map<std::vector<unsigned char>, std::vector<unsigned char>>
unknown;
224 template <
typename Stream>
241 s << sig_pair.second.second;
297 const auto& [xonly, leaf_hash] = pubkey_leaf;
304 const auto& [script, leaf_ver] = leaf;
305 for (
const auto& control_block : control_blocks) {
307 std::vector<unsigned char> value_v(script.begin(), script.end());
308 value_v.push_back((uint8_t)leaf_ver);
315 const auto& [leaf_hashes, origin] = leaf_origin;
317 std::vector<unsigned char> value;
319 s_value << leaf_hashes;
364 template <
typename Stream>
367 std::set<std::vector<unsigned char>> key_lookup;
370 bool found_sep =
false;
373 std::vector<unsigned char> key;
391 if (!key_lookup.emplace(key).second) {
392 throw std::ios_base::failure(
"Duplicate Key, input non-witness utxo already provided");
393 }
else if (key.size() != 1) {
394 throw std::ios_base::failure(
"Non-witness utxo key is more than one byte type");
402 if (!key_lookup.emplace(key).second) {
403 throw std::ios_base::failure(
"Duplicate Key, input witness utxo already provided");
404 }
else if (key.size() != 1) {
405 throw std::ios_base::failure(
"Witness utxo key is more than one byte type");
413 throw std::ios_base::failure(
"Size of key was not the expected size for the type partial signature pubkey");
416 CPubKey pubkey(key.begin() + 1, key.end());
417 if (!pubkey.IsFullyValid()) {
418 throw std::ios_base::failure(
"Invalid pubkey");
421 throw std::ios_base::failure(
"Duplicate Key, input partial signature for pubkey already provided");
425 std::vector<unsigned char> sig;
433 if (!key_lookup.emplace(key).second) {
434 throw std::ios_base::failure(
"Duplicate Key, input sighash type already provided");
435 }
else if (key.size() != 1) {
436 throw std::ios_base::failure(
"Sighash type key is more than one byte type");
444 if (!key_lookup.emplace(key).second) {
445 throw std::ios_base::failure(
"Duplicate Key, input redeemScript already provided");
446 }
else if (key.size() != 1) {
447 throw std::ios_base::failure(
"Input redeemScript key is more than one byte type");
454 if (!key_lookup.emplace(key).second) {
455 throw std::ios_base::failure(
"Duplicate Key, input witnessScript already provided");
456 }
else if (key.size() != 1) {
457 throw std::ios_base::failure(
"Input witnessScript key is more than one byte type");
469 if (!key_lookup.emplace(key).second) {
470 throw std::ios_base::failure(
"Duplicate Key, input final scriptSig already provided");
471 }
else if (key.size() != 1) {
472 throw std::ios_base::failure(
"Final scriptSig key is more than one byte type");
479 if (!key_lookup.emplace(key).second) {
480 throw std::ios_base::failure(
"Duplicate Key, input final scriptWitness already provided");
481 }
else if (key.size() != 1) {
482 throw std::ios_base::failure(
"Final scriptWitness key is more than one byte type");
491 throw std::ios_base::failure(
"Size of key was not the expected size for the type ripemd160 preimage");
494 std::vector<unsigned char> hash_vec(key.begin() + 1, key.end());
497 throw std::ios_base::failure(
"Duplicate Key, input ripemd160 preimage already provided");
501 std::vector<unsigned char> preimage;
512 throw std::ios_base::failure(
"Size of key was not the expected size for the type sha256 preimage");
515 std::vector<unsigned char> hash_vec(key.begin() + 1, key.end());
518 throw std::ios_base::failure(
"Duplicate Key, input sha256 preimage already provided");
522 std::vector<unsigned char> preimage;
533 throw std::ios_base::failure(
"Size of key was not the expected size for the type hash160 preimage");
536 std::vector<unsigned char> hash_vec(key.begin() + 1, key.end());
539 throw std::ios_base::failure(
"Duplicate Key, input hash160 preimage already provided");
543 std::vector<unsigned char> preimage;
554 throw std::ios_base::failure(
"Size of key was not the expected size for the type hash256 preimage");
557 std::vector<unsigned char> hash_vec(key.begin() + 1, key.end());
560 throw std::ios_base::failure(
"Duplicate Key, input hash256 preimage already provided");
564 std::vector<unsigned char> preimage;
573 if (!key_lookup.emplace(key).second) {
574 throw std::ios_base::failure(
"Duplicate Key, input Taproot key signature already provided");
575 }
else if (key.size() != 1) {
576 throw std::ios_base::failure(
"Input Taproot key signature key is more than one byte type");
580 throw std::ios_base::failure(
"Input Taproot key path signature is shorter than 64 bytes");
582 throw std::ios_base::failure(
"Input Taproot key path signature is longer than 65 bytes");
588 if (!key_lookup.emplace(key).second) {
589 throw std::ios_base::failure(
"Duplicate Key, input Taproot script signature already provided");
590 }
else if (key.size() != 65) {
591 throw std::ios_base::failure(
"Input Taproot script signature key is not 65 bytes");
598 std::vector<unsigned char> sig;
600 if (sig.size() < 64) {
601 throw std::ios_base::failure(
"Input Taproot script path signature is shorter than 64 bytes");
602 }
else if (sig.size() > 65) {
603 throw std::ios_base::failure(
"Input Taproot script path signature is longer than 65 bytes");
610 if (!key_lookup.emplace(key).second) {
611 throw std::ios_base::failure(
"Duplicate Key, input Taproot leaf script already provided");
612 }
else if (key.size() < 34) {
613 throw std::ios_base::failure(
"Taproot leaf script key is not at least 34 bytes");
614 }
else if ((key.size() - 2) % 32 != 0) {
615 throw std::ios_base::failure(
"Input Taproot leaf script key's control block size is not valid");
617 std::vector<unsigned char> script_v;
619 if (script_v.empty()) {
620 throw std::ios_base::failure(
"Input Taproot leaf script must be at least 1 byte");
622 uint8_t leaf_ver = script_v.back();
624 const auto leaf_script = std::make_pair(script_v, (
int)leaf_ver);
625 m_tap_scripts[leaf_script].insert(std::vector<unsigned char>(key.begin() + 1, key.end()));
630 if (!key_lookup.emplace(key).second) {
631 throw std::ios_base::failure(
"Duplicate Key, input Taproot BIP32 keypath already provided");
632 }
else if (key.size() != 33) {
633 throw std::ios_base::failure(
"Input Taproot BIP32 keypath key is not at 33 bytes");
638 std::set<uint256> leaf_hashes;
640 size_t before_hashes = s.size();
642 size_t after_hashes = s.size();
643 size_t hashes_len = before_hashes - after_hashes;
644 if (hashes_len > value_len) {
645 throw std::ios_base::failure(
"Input Taproot BIP32 keypath has an invalid length");
647 size_t origin_len = value_len - hashes_len;
653 if (!key_lookup.emplace(key).second) {
654 throw std::ios_base::failure(
"Duplicate Key, input Taproot internal key already provided");
655 }
else if (key.size() != 1) {
656 throw std::ios_base::failure(
"Input Taproot internal key key is more than one byte type");
663 if (!key_lookup.emplace(key).second) {
664 throw std::ios_base::failure(
"Duplicate Key, input Taproot merkle root already provided");
665 }
else if (key.size() != 1) {
666 throw std::ios_base::failure(
"Input Taproot merkle root key is more than one byte type");
679 throw std::ios_base::failure(
"Duplicate Key, proprietary key already found");
681 s >> this_prop.
value;
688 throw std::ios_base::failure(
"Duplicate Key, key for unknown value already provided");
691 std::vector<unsigned char> val_bytes;
693 unknown.emplace(std::move(key), std::move(val_bytes));
699 throw std::ios_base::failure(
"Separator is missing at the end of an input map");
703 template <
typename Stream>
716 std::vector<std::tuple<uint8_t, uint8_t, std::vector<unsigned char>>>
m_tap_tree;
718 std::map<std::vector<unsigned char>, std::vector<unsigned char>>
unknown;
727 template <
typename Stream>
759 std::vector<unsigned char> value;
761 for (
const auto& [depth, leaf_ver, script] :
m_tap_tree) {
771 const auto& [leaf_hashes, origin] = leaf;
773 std::vector<unsigned char> value;
775 s_value << leaf_hashes;
790 template <
typename Stream>
793 std::set<std::vector<unsigned char>> key_lookup;
796 bool found_sep =
false;
799 std::vector<unsigned char> key;
817 if (!key_lookup.emplace(key).second) {
818 throw std::ios_base::failure(
"Duplicate Key, output redeemScript already provided");
819 }
else if (key.size() != 1) {
820 throw std::ios_base::failure(
"Output redeemScript key is more than one byte type");
827 if (!key_lookup.emplace(key).second) {
828 throw std::ios_base::failure(
"Duplicate Key, output witnessScript already provided");
829 }
else if (key.size() != 1) {
830 throw std::ios_base::failure(
"Output witnessScript key is more than one byte type");
842 if (!key_lookup.emplace(key).second) {
843 throw std::ios_base::failure(
"Duplicate Key, output Taproot internal key already provided");
844 }
else if (key.size() != 1) {
845 throw std::ios_base::failure(
"Output Taproot internal key key is more than one byte type");
852 if (!key_lookup.emplace(key).second) {
853 throw std::ios_base::failure(
"Duplicate Key, output Taproot tree already provided");
854 }
else if (key.size() != 1) {
855 throw std::ios_base::failure(
"Output Taproot tree key is more than one byte type");
857 std::vector<unsigned char> tree_v;
860 if (s_tree.empty()) {
861 throw std::ios_base::failure(
"Output Taproot tree must not be empty");
864 while (!s_tree.empty()) {
867 std::vector<unsigned char> script;
872 throw std::ios_base::failure(
"Output Taproot tree has as leaf greater than Taproot maximum depth");
875 throw std::ios_base::failure(
"Output Taproot tree has a leaf with an invalid leaf version");
877 m_tap_tree.emplace_back(depth, leaf_ver, script);
878 builder.
Add((
int)depth, script, (
int)leaf_ver,
true);
881 throw std::ios_base::failure(
"Output Taproot tree is malformed");
887 if (!key_lookup.emplace(key).second) {
888 throw std::ios_base::failure(
"Duplicate Key, output Taproot BIP32 keypath already provided");
889 }
else if (key.size() != 33) {
890 throw std::ios_base::failure(
"Output Taproot BIP32 keypath key is not at 33 bytes");
893 std::set<uint256> leaf_hashes;
895 size_t before_hashes = s.size();
897 size_t after_hashes = s.size();
898 size_t hashes_len = before_hashes - after_hashes;
899 if (hashes_len > value_len) {
900 throw std::ios_base::failure(
"Output Taproot BIP32 keypath has an invalid length");
902 size_t origin_len = value_len - hashes_len;
914 throw std::ios_base::failure(
"Duplicate Key, proprietary key already found");
916 s >> this_prop.
value;
923 throw std::ios_base::failure(
"Duplicate Key, key for unknown value already provided");
926 std::vector<unsigned char> val_bytes;
928 unknown.emplace(std::move(key), std::move(val_bytes));
935 throw std::ios_base::failure(
"Separator is missing at the end of an output map");
939 template <
typename Stream>
948 std::optional<CMutableTransaction>
tx;
951 std::map<KeyOriginInfo, std::set<CExtPubKey>>
m_xpubs;
954 std::map<std::vector<unsigned char>, std::vector<unsigned char>>
unknown;
977 template <
typename Stream>
991 for (
const auto& xpub_pair :
m_xpubs) {
992 for (
const auto& xpub : xpub_pair.second) {
994 xpub.EncodeWithVersion(ser_xpub);
1034 template <
typename Stream>
1040 throw std::ios_base::failure(
"Invalid PSBT magic bytes");
1044 std::set<std::vector<unsigned char>> key_lookup;
1047 std::set<CExtPubKey> global_xpubs;
1050 bool found_sep =
false;
1053 std::vector<unsigned char> key;
1071 if (!key_lookup.emplace(key).second) {
1072 throw std::ios_base::failure(
"Duplicate Key, unsigned tx already provided");
1073 }
else if (key.size() != 1) {
1074 throw std::ios_base::failure(
"Global unsigned tx key is more than one byte type");
1080 tx = std::move(mtx);
1082 for (
const CTxIn& txin :
tx->vin) {
1084 throw std::ios_base::failure(
"Unsigned tx does not have empty scriptSigs and scriptWitnesses.");
1092 throw std::ios_base::failure(
"Size of key was not the expected size for the type global xpub");
1098 throw std::ios_base::failure(
"Invalid pubkey");
1100 if (global_xpubs.count(xpub) > 0) {
1101 throw std::ios_base::failure(
"Duplicate key, global xpub already provided");
1103 global_xpubs.insert(xpub);
1110 if (
m_xpubs.count(keypath) == 0) {
1115 m_xpubs[keypath].insert(xpub);
1122 throw std::ios_base::failure(
"Duplicate Key, version already provided");
1123 }
else if (key.size() != 1) {
1124 throw std::ios_base::failure(
"Global version key is more than one byte type");
1130 throw std::ios_base::failure(
"Unsupported version number");
1139 this_prop.
key = key;
1142 throw std::ios_base::failure(
"Duplicate Key, proprietary key already found");
1144 s >> this_prop.
value;
1151 throw std::ios_base::failure(
"Duplicate Key, key for unknown value already provided");
1154 std::vector<unsigned char> val_bytes;
1156 unknown.emplace(std::move(key), std::move(val_bytes));
1162 throw std::ios_base::failure(
"Separator is missing at the end of the global map");
1167 throw std::ios_base::failure(
"No unsigned transaction was provided");
1172 while (!s.empty() && i <
tx->vin.size()) {
1178 if (input.non_witness_utxo && input.non_witness_utxo->GetHash() !=
tx->vin[i].prevout.hash) {
1179 throw std::ios_base::failure(
"Non-witness UTXO does not match outpoint hash");
1184 if (
inputs.size() !=
tx->vin.size()) {
1185 throw std::ios_base::failure(
"Inputs provided does not match the number of inputs in transaction.");
1190 while (!s.empty() && i <
tx->vout.size()) {
1197 if (
outputs.size() !=
tx->vout.size()) {
1198 throw std::ios_base::failure(
"Outputs provided does not match the number of outputs in transaction.");
1202 template <
typename Stream>
1277 #endif // BITCOIN_PSBT_H std::shared_ptr< const CTransaction > CTransactionRef
static constexpr uint8_t PSBT_OUT_TAP_INTERNAL_KEY
static const std::string sighash
bool AddInput(const CTxIn &txin, PSBTInput &psbtin)
CONSTEXPR_IF_NOT_DEBUG Span< C > first(std::size_t count) const noexcept
CONSTEXPR_IF_NOT_DEBUG Span< C > subspan(std::size_t offset) const noexcept
std::set< PSBTProprietary > m_proprietary
unsigned char fingerprint[4]
First 32 bits of the Hash160 of the public key at the root of the path.
static constexpr uint8_t PSBT_OUT_PROPRIETARY
bool operator<(const PSBTProprietary &b) const
static const int SERIALIZE_TRANSACTION_NO_WITNESS
A flag that is ORed into the protocol version to designate that a transaction should be (un)serialize...
bool DecodeBase64PSBT(PartiallySignedTransaction &decoded_psbt, const std::string &base64_psbt, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
static constexpr unsigned int SIZE
secp256k1:
void DecodeWithVersion(const unsigned char code[BIP32_EXTKEY_WITH_VERSION_SIZE])
bool IsNull() const
Test whether this is the 0 key (the result of default construction).
static constexpr uint32_t PSBT_HIGHEST_VERSION
uint64_t ReadCompactSize(Stream &is, bool range_check=true)
Decode a CompactSize-encoded variable-length integer.
void WriteCompactSize(CSizeComputer &os, uint64_t nSize)
static constexpr uint8_t PSBT_SEPARATOR
static constexpr uint8_t PSBT_OUT_REDEEMSCRIPT
CScriptWitness scriptWitness
Only serialized through CTransaction.
static constexpr uint8_t PSBT_IN_PARTIAL_SIG
bool operator==(const PSBTProprietary &b) const
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...
std::vector< unsigned char > value
static constexpr uint8_t PSBT_IN_SCRIPTWITNESS
bool SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, const PrecomputedTransactionData *txdata, int sighash=SIGHASH_ALL, SignatureData *out_sigdata=nullptr, bool finalize=true)
Signs a PSBTInput, verifying that all provided data matches what is being signed. ...
std::vector< std::vector< unsigned char > > stack
void Merge(const PSBTOutput &output)
void Serialize(Stream &s) const
void SerializeToVector(Stream &s, const X &... args)
A version of CTransaction with the PSBT format.
static constexpr uint8_t PSBT_IN_PROPRIETARY
std::map< XOnlyPubKey, std::pair< std::set< uint256 >, KeyOriginInfo > > m_tap_bip32_paths
static const size_t OUTPUT_SIZE
void Serialize(Stream &s) const
bool AddOutput(const CTxOut &txout, const PSBTOutput &psbtout)
void SerializeKeyOrigin(Stream &s, KeyOriginInfo hd_keypath)
std::map< KeyOriginInfo, std::set< CExtPubKey > > m_xpubs
static constexpr uint8_t PSBT_IN_TAP_BIP32_DERIVATION
std::vector< unsigned char > identifier
std::string PSBTRoleName(PSBTRole role)
Dummy data type to identify deserializing constructors.
XOnlyPubKey m_tap_internal_key
static constexpr uint8_t PSBT_IN_WITNESS_UTXO
static constexpr uint8_t PSBT_IN_BIP32_DERIVATION
void FromSignatureData(const SignatureData &sigdata)
static constexpr uint8_t PSBT_OUT_TAP_BIP32_DERIVATION
Minimal stream for reading from an existing byte array by Span.
bool FinalizePSBT(PartiallySignedTransaction &psbtx)
Finalizes a PSBT if possible, combining partial signatures.
static constexpr uint8_t PSBT_IN_RIPEMD160
A structure for PSBTs which contains per output information.
static constexpr uint8_t PSBT_IN_TAP_KEY_SIG
std::optional< uint32_t > m_version
std::vector< PSBTOutput > outputs
static constexpr uint8_t PSBT_IN_SHA256
std::map< CPubKey, KeyOriginInfo > hd_keypaths
static constexpr uint8_t PSBT_IN_TAP_LEAF_SCRIPT
static constexpr unsigned int COMPRESSED_SIZE
static constexpr uint8_t PSBT_GLOBAL_PROPRIETARY
static constexpr uint8_t PSBT_IN_TAP_SCRIPT_SIG
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid()) ...
An input of a transaction.
uint32_t GetVersion() const
static const size_t OUTPUT_SIZE
static constexpr uint8_t TAPROOT_LEAF_MASK
static constexpr uint8_t PSBT_IN_SCRIPTSIG
An encapsulated public key.
static constexpr uint8_t PSBT_IN_HASH160
KeyOriginInfo DeserializeKeyOrigin(Stream &s, uint64_t length)
std::pair< CPubKey, std::vector< unsigned char > > SigPair
bool DecodeRawPSBT(PartiallySignedTransaction &decoded_psbt, Span< const std::byte > raw_psbt, std::string &error)
Decode a raw (binary blob) PSBT into a PartiallySignedTransaction.
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
const std::streamsize MAX_FILE_SIZE_PSBT
static constexpr uint8_t PSBT_IN_SIGHASH
bool PSBTInputSigned(const PSBTInput &input)
Checks whether a PSBTInput is already signed by checking for non-null finalized fields.
void Unserialize(Stream &s)
An output of a transaction.
static constexpr uint8_t PSBT_IN_REDEEMSCRIPT
PrecomputedTransactionData PrecomputePSBTData(const PartiallySignedTransaction &psbt)
Compute a PrecomputedTransactionData object from a psbt.
static constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX
constexpr bool IsNull() const
static constexpr uint8_t PSBT_GLOBAL_XPUB
std::vector< PSBTInput > inputs
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
void DeserializeHDKeypath(Stream &s, KeyOriginInfo &hd_keypath)
A structure for PSBT proprietary types.
Utility class to construct Taproot outputs from internal key and script tree.
static constexpr uint8_t PSBT_IN_TAP_INTERNAL_KEY
std::vector< std::tuple< uint8_t, uint8_t, std::vector< unsigned char > > > m_tap_tree
std::vector< unsigned char > ToByteVector(const T &in)
static constexpr uint8_t PSBT_IN_WITNESSSCRIPT
std::vector< unsigned char > key
static constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT
void FillSignatureData(SignatureData &sigdata) const
bool Merge(const PartiallySignedTransaction &psbt)
Merge psbt into this.
An interface to be implemented by keystores that support signing.
static constexpr uint8_t PSBT_IN_TAP_MERKLE_ROOT
bool error(const char *fmt, const Args &... args)
Serialized script, used inside transaction inputs and outputs.
static constexpr uint8_t PSBT_OUT_TAP_TREE
TaprootBuilder & Add(int depth, Span< const unsigned char > script, int leaf_version, bool track=true)
Add a new script at a certain depth in the tree.
size_t GetSerializeSizeMany(int nVersion, const T &... t)
void UnserializeFromVector(Stream &s, X &... args)
static const size_t OUTPUT_SIZE
void Unserialize(Stream &s)
static const size_t OUTPUT_SIZE
static constexpr uint8_t PSBT_OUT_BIP32_DERIVATION
A mutable version of CTransaction.
void SerializeHDKeypath(Stream &s, KeyOriginInfo hd_keypath)
PSBTOutput(deserialize_type, Stream &s)
bool IsComplete() const
Return whether there were either no leaves, or the leaves form a Huffman tree.
void SerializeMany(Stream &s, const Args &... args)
Support for (un)serializing many things at once.
static constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO
A Span is an object that can refer to a contiguous sequence of objects.
TransactionError CombinePSBTs(PartiallySignedTransaction &out, const std::vector< PartiallySignedTransaction > &psbtxs)
Combines PSBTs with the same underlying transaction, resulting in a single PSBT with all partial sign...
const unsigned int BIP32_EXTKEY_WITH_VERSION_SIZE
std::set< PSBTProprietary > m_proprietary
static constexpr uint8_t PSBT_OUT_WITNESSSCRIPT
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized...
void SerializeHDKeypaths(Stream &s, const std::map< CPubKey, KeyOriginInfo > &hd_keypaths, CompactSizeWriter type)
std::optional< CMutableTransaction > tx
PartiallySignedTransaction(deserialize_type, Stream &s)
std::vector< uint32_t > path
bool GetInputUTXO(CTxOut &utxo, int input_index) const
Finds the UTXO for a given input index.
PartiallySignedTransaction()
void RemoveUnnecessaryTransactions(PartiallySignedTransaction &psbtx, const int &sighash_type)
Reduces the size of the PSBT by dropping unnecessary non_witness_utxos (i.e.
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
void UnserializeMany(Stream &s, Args &&... args)
static constexpr uint8_t PSBT_GLOBAL_VERSION
static constexpr uint8_t PSBT_IN_HASH256
void DeserializeHDKeypaths(Stream &s, const std::vector< unsigned char > &key, std::map< CPubKey, KeyOriginInfo > &hd_keypaths)
static constexpr uint8_t PSBT_MAGIC_BYTES[5]
size_t CountPSBTUnsignedInputs(const PartiallySignedTransaction &psbt)
Counts the unsigned inputs of a PSBT.