104 std::vector<unsigned char>
key;
117template<
typename Stream,
typename...
X>
127template<
typename Stream,
typename...
X>
131 size_t remaining_before =
s.size();
133 size_t remaining_after =
s.size();
134 if (remaining_after + expected_size != remaining_before) {
135 throw std::ios_base::failure(
"Size of value was not the stated size");
140template<
typename Stream>
144 if (length % 4 || length == 0) {
145 throw std::ios_base::failure(
"Invalid length for HD key path");
150 for (
unsigned int i = 4; i < length; i +=
sizeof(uint32_t)) {
153 hd_keypath.
path.push_back(index);
159template<
typename Stream>
166template<
typename Stream>
171 throw std::ios_base::failure(
"Size of key was not the expected size for the type BIP32 keypath");
174 CPubKey pubkey(key.begin() + 1, key.end());
176 throw std::ios_base::failure(
"Invalid pubkey");
183 hd_keypaths.emplace(pubkey, std::move(keypath));
187template<
typename Stream>
191 for (
const auto& path : hd_keypath.
path) {
197template<
typename Stream>
205template<
typename Stream>
208 for (
const auto& keypath_pair : hd_keypaths) {
209 if (!keypath_pair.first.IsValid()) {
210 throw std::ios_base::failure(
"Invalid CPubKey being serialized");
218template<
typename Stream>
221 std::array<unsigned char, CPubKey::COMPRESSED_SIZE> agg_pubkey_bytes;
222 skey >> std::as_writable_bytes(std::span{agg_pubkey_bytes});
223 CPubKey agg_pubkey(agg_pubkey_bytes);
224 if (!agg_pubkey.IsFullyValid()) {
225 throw std::ios_base::failure(context +
" musig2 aggregate pubkey is invalid");
228 std::vector<CPubKey> participants;
229 std::vector<unsigned char> val;
233 std::array<unsigned char, CPubKey::COMPRESSED_SIZE> part_pubkey_bytes;
234 s_val >> std::as_writable_bytes(std::span{part_pubkey_bytes});
235 CPubKey participant(part_pubkey_bytes);
236 if (!participant.IsFullyValid()) {
237 throw std::ios_base::failure(context +
" musig2 participant pubkey is invalid");
239 participants.push_back(participant);
241 if (!s_val.empty()) {
242 throw std::ios_base::failure(context +
" musig2 participants pubkeys value size is not a multiple of 33");
245 out.emplace(agg_pubkey, participants);
250template<
typename Stream>
255 std::array<unsigned char, CPubKey::COMPRESSED_SIZE> part_pubkey_bytes;
256 std::array<unsigned char, CPubKey::COMPRESSED_SIZE> agg_pubkey_bytes;
258 skey >> std::as_writable_bytes(std::span{part_pubkey_bytes}) >> std::as_writable_bytes(std::span{agg_pubkey_bytes});
259 agg_pub.
Set(agg_pubkey_bytes.begin(), agg_pubkey_bytes.end());
261 throw std::ios_base::failure(
"musig2 aggregate pubkey is invalid");
264 part_pub.
Set(part_pubkey_bytes.begin(), part_pubkey_bytes.end());
266 throw std::ios_base::failure(
"musig2 participant pubkey is invalid");
274static inline void ExpectedKeySize(
const std::string& key_name,
const std::vector<unsigned char>& key, uint64_t expected_size) {
275 if (key.size() != expected_size) {
276 throw std::ios_base::failure(
tfm::format(
"Size of key was not %d for the type %s", expected_size, key_name));
321 std::map<std::vector<unsigned char>, std::vector<unsigned char>>
unknown;
349 template <
typename Stream>
359 template <
typename Stream>
375 s << sig_pair.second.second;
431 const auto& [xonly, leaf_hash] = pubkey_leaf;
438 const auto& [
script, leaf_ver] = leaf;
439 for (
const auto& control_block : control_blocks) {
441 std::vector<unsigned char> value_v(
script.begin(),
script.end());
442 value_v.push_back((uint8_t)leaf_ver);
449 const auto& [leaf_hashes, origin] = leaf_origin;
451 std::vector<unsigned char> value;
453 s_value << leaf_hashes;
473 std::vector<unsigned char> value;
475 for (
auto&
pk : part_pubs) {
476 s_value << std::span{
pk};
483 const auto& [agg_pubkey, leaf_hash] = agg_pubkey_leaf_hash;
484 for (
const auto& [part_pubkey, pubnonce] : pubnonces) {
485 if (leaf_hash.IsNull()) {
496 const auto& [agg_pubkey, leaf_hash] = agg_pubkey_leaf_hash;
497 for (
const auto& [pubkey, psig] : psigs) {
498 if (leaf_hash.IsNull()) {
558 template <
typename Stream>
561 std::set<std::vector<unsigned char>> key_lookup;
563 bool found_prev_txid =
false;
564 bool found_prev_out =
false;
567 bool found_sep =
false;
571 std::vector<unsigned char> key;
582 if (!key_lookup.emplace(key).second) {
583 throw std::ios_base::failure(
tfm::format(
"Duplicate Key, input key \"%s\" already provided",
HexStr(key)));
609 throw std::ios_base::failure(
"Size of key was not the expected size for the type partial signature pubkey");
612 CPubKey pubkey(key.begin() + 1, key.end());
614 throw std::ios_base::failure(
"Invalid pubkey");
618 std::vector<unsigned char> sig;
623 throw std::ios_base::failure(
"Signature is not a valid encoding");
669 std::vector<unsigned char> hash_vec(key.begin() + 1, key.end());
673 std::vector<unsigned char> preimage;
684 std::vector<unsigned char> hash_vec(key.begin() + 1, key.end());
688 std::vector<unsigned char> preimage;
699 std::vector<unsigned char> hash_vec(key.begin() + 1, key.end());
703 std::vector<unsigned char> preimage;
714 std::vector<unsigned char> hash_vec(key.begin() + 1, key.end());
718 std::vector<unsigned char> preimage;
729 throw std::ios_base::failure(
"Previous txid is not allowed in PSBTv0");
732 found_prev_txid =
true;
739 throw std::ios_base::failure(
"Previous output's index is not allowed in PSBTv0");
742 found_prev_out =
true;
749 throw std::ios_base::failure(
"Sequence is not allowed in PSBTv0");
759 throw std::ios_base::failure(
"Required time based locktime is not allowed in PSBTv0");
764 throw std::ios_base::failure(
"Required time based locktime is invalid (less than 500000000)");
772 throw std::ios_base::failure(
"Required height based locktime is not allowed in PSBTv0");
777 throw std::ios_base::failure(
"Required height based locktime is invalid (greater than or equal to 500000000)");
779 throw std::ios_base::failure(
"Required height based locktime is invalid (0)");
788 throw std::ios_base::failure(
"Input Taproot key path signature is shorter than 64 bytes");
790 throw std::ios_base::failure(
"Input Taproot key path signature is longer than 65 bytes");
802 std::vector<unsigned char> sig;
804 if (sig.size() < 64) {
805 throw std::ios_base::failure(
"Input Taproot script path signature is shorter than 64 bytes");
806 }
else if (sig.size() > 65) {
807 throw std::ios_base::failure(
"Input Taproot script path signature is longer than 65 bytes");
814 if (key.size() < 34) {
815 throw std::ios_base::failure(
"Input Taproot leaf script key is not at least 34 bytes");
816 }
else if ((key.size() - 2) % 32 != 0) {
817 throw std::ios_base::failure(
"Input Taproot leaf script key's control block size is not valid");
819 std::vector<unsigned char> script_v;
821 if (script_v.empty()) {
822 throw std::ios_base::failure(
"Input Taproot leaf script must be at least 1 byte");
824 uint8_t leaf_ver = script_v.back();
826 const auto leaf_script = std::make_pair(script_v, (
int)leaf_ver);
827 m_tap_scripts[leaf_script].insert(std::vector<unsigned char>(key.begin() + 1, key.end()));
836 std::set<uint256> leaf_hashes;
838 size_t before_hashes =
s.size();
840 size_t after_hashes =
s.size();
841 size_t hashes_len = before_hashes - after_hashes;
842 if (hashes_len > value_len) {
843 throw std::ios_base::failure(
"Input Taproot BIP32 keypath has an invalid length");
845 size_t origin_len = value_len - hashes_len;
870 throw std::ios_base::failure(
"Input musig2 pubnonce key is not expected size of 67 or 99 bytes");
876 std::vector<uint8_t> pubnonce;
879 throw std::ios_base::failure(
"Input musig2 pubnonce value is not 66 bytes");
888 throw std::ios_base::failure(
"Input musig2 partial sig key is not expected size of 67 or 99 bytes");
914 std::vector<unsigned char> val_bytes;
916 unknown.emplace(std::move(key), std::move(val_bytes));
922 throw std::ios_base::failure(
"Separator is missing at the end of an input map");
927 if (!found_prev_txid) {
928 throw std::ios_base::failure(
"Previous TXID is required in PSBTv2");
930 if (!found_prev_out) {
931 throw std::ios_base::failure(
"Previous output's index is required in PSBTv2");
949 std::vector<std::tuple<uint8_t, uint8_t, std::vector<unsigned char>>>
m_tap_tree;
953 std::map<std::vector<unsigned char>, std::vector<unsigned char>>
unknown;
973 template <
typename Stream>
983 template <
typename Stream>
1024 std::vector<unsigned char> value;
1028 s_value << leaf_ver;
1036 const auto& [leaf_hashes, origin] = leaf;
1038 std::vector<unsigned char> value;
1040 s_value << leaf_hashes;
1048 std::vector<unsigned char> value;
1050 for (
auto&
pk : part_pubs) {
1051 s_value << std::span{
pk};
1066 template <
typename Stream>
1069 std::set<std::vector<unsigned char>> key_lookup;
1071 bool found_amount =
false;
1072 bool found_script =
false;
1075 bool found_sep =
false;
1079 std::vector<unsigned char> key;
1090 if (!key_lookup.emplace(key).second) {
1091 throw std::ios_base::failure(
tfm::format(
"Duplicate Key, output key \"%s\" already provided",
HexStr(key)));
1123 throw std::ios_base::failure(
"Output amount is not allowed in PSBTv0");
1126 found_amount =
true;
1133 throw std::ios_base::failure(
"Output script is not allowed in PSBTv0");
1136 found_script =
true;
1148 std::vector<unsigned char> tree_v;
1151 if (s_tree.empty()) {
1152 throw std::ios_base::failure(
"Output Taproot tree must not be empty");
1155 while (!s_tree.empty()) {
1158 std::vector<unsigned char>
script;
1163 throw std::ios_base::failure(
"Output Taproot tree has as leaf greater than Taproot maximum depth");
1166 throw std::ios_base::failure(
"Output Taproot tree has a leaf with an invalid leaf version");
1169 builder.
Add((
int)depth,
script, (
int)leaf_ver,
true);
1172 throw std::ios_base::failure(
"Output Taproot tree is malformed");
1180 std::set<uint256> leaf_hashes;
1182 size_t before_hashes =
s.size();
1184 size_t after_hashes =
s.size();
1185 size_t hashes_len = before_hashes - after_hashes;
1186 if (hashes_len > value_len) {
1187 throw std::ios_base::failure(
"Output Taproot BIP32 keypath has an invalid length");
1189 size_t origin_len = value_len - hashes_len;
1204 this_prop.
key = key;
1213 std::vector<unsigned char> val_bytes;
1215 unknown.emplace(std::move(key), std::move(val_bytes));
1222 throw std::ios_base::failure(
"Separator is missing at the end of an output map");
1227 if (!found_amount) {
1228 throw std::ios_base::failure(
"Output amount is required in PSBTv2");
1230 if (!found_script) {
1231 throw std::ios_base::failure(
"Output script is required in PSBTv2");
1246 std::map<KeyOriginInfo, std::set<CExtPubKey>>
m_xpubs;
1250 std::map<std::vector<unsigned char>, std::vector<unsigned char>>
unknown;
1271 template <
typename Stream>
1286 for (
const auto& xpub_pair :
m_xpubs) {
1287 for (
const auto& xpub : xpub_pair.second) {
1289 xpub.EncodeWithVersion(ser_xpub);
1349 template <
typename Stream>
1355 throw std::ios_base::failure(
"Invalid PSBT magic bytes");
1359 std::set<std::vector<unsigned char>> key_lookup;
1362 bool found_sep =
false;
1363 std::optional<CMutableTransaction> tx;
1364 uint64_t input_count = 0;
1365 uint64_t output_count = 0;
1366 bool found_input_count =
false;
1367 bool found_output_count =
false;
1368 bool found_tx_version =
false;
1369 bool found_fallback_locktime =
false;
1373 std::vector<unsigned char> key;
1384 if (!key_lookup.emplace(key).second) {
1385 throw std::ios_base::failure(
tfm::format(
"Duplicate Key, global key \"%s\" already provided",
HexStr(key)));
1403 for (
const CTxIn& txin : tx->vin) {
1405 throw std::ios_base::failure(
"Unsigned tx does not have empty scriptSigs and scriptWitnesses.");
1411 input_count = tx->vin.size();
1412 output_count = tx->vout.size();
1419 found_tx_version =
true;
1427 found_fallback_locktime =
true;
1435 found_input_count =
true;
1443 found_output_count =
true;
1461 throw std::ios_base::failure(
"Invalid pubkey");
1469 if (!
m_xpubs.contains(keypath)) {
1474 m_xpubs[keypath].insert(xpub);
1485 throw std::ios_base::failure(
"Unsupported version number");
1494 this_prop.
key = key;
1503 std::vector<unsigned char> val_bytes;
1505 unknown.emplace(std::move(key), std::move(val_bytes));
1511 throw std::ios_base::failure(
"Separator is missing at the end of the global map");
1517 if (psbt_ver == 0) {
1520 throw std::ios_base::failure(
"No unsigned transaction was provided");
1523 if (found_tx_version) {
1524 throw std::ios_base::failure(
"PSBT_GLOBAL_TX_VERSION is not allowed in PSBTv0");
1526 if (found_fallback_locktime) {
1527 throw std::ios_base::failure(
"PSBT_GLOBAL_FALLBACK_LOCKTIME is not allowed in PSBTv0");
1529 if (found_input_count) {
1530 throw std::ios_base::failure(
"PSBT_GLOBAL_INPUT_COUNT is not allowed in PSBTv0");
1532 if (found_output_count) {
1533 throw std::ios_base::failure(
"PSBT_GLOBAL_OUTPUT_COUNT is not allowed in PSBTv0");
1536 throw std::ios_base::failure(
"PSBT_GLOBAL_TX_MODIFIABLE is not allowed in PSBTv0");
1540 if (psbt_ver == 1) {
1541 throw std::ios_base::failure(
"There is no PSBT version 1");
1543 if (psbt_ver == 2) {
1545 if (!found_tx_version) {
1546 throw std::ios_base::failure(
"PSBT_GLOBAL_TX_VERSION is required in PSBTv2");
1548 if (!found_input_count) {
1549 throw std::ios_base::failure(
"PSBT_GLOBAL_INPUT_COUNT is required in PSBTv2");
1551 if (!found_output_count) {
1552 throw std::ios_base::failure(
"PSBT_GLOBAL_OUTPUT_COUNT is required in PSBTv2");
1556 throw std::ios_base::failure(
"PSBT_GLOBAL_UNSIGNED_TX is not allowed in PSBTv2");
1560 throw std::ios_base::failure(
"Unknown PSBT version");
1565 while (!
s.empty() && i < input_count) {
1567 inputs.emplace_back(psbt_ver, tx->vin[i].prevout.hash, tx->vin[i].prevout.n, tx->vin[i].nSequence);
1578 throw std::ios_base::failure(
"Non-witness UTXO does not match outpoint hash");
1581 throw std::ios_base::failure(
"Input specifies output index that does not exist");
1585 throw std::ios_base::failure(
"Non-witness UTXO does not match outpoint hash");
1588 throw std::ios_base::failure(
"Input specifies output index that does not exist");
1595 if (
inputs.size() != input_count) {
1596 throw std::ios_base::failure(
"Inputs provided does not match the number of inputs in transaction.");
1601 while (!
s.empty() && i < output_count) {
1603 outputs.emplace_back(psbt_ver, tx->vout[i].nValue, tx->vout[i].scriptPubKey);
1611 if (
outputs.size() != output_count) {
1612 throw std::ios_base::failure(
"Outputs provided does not match the number of outputs in transaction.");
1616 template <
typename Stream>
1683[[nodiscard]] std::optional<PartiallySignedTransaction>
CombinePSBTs(
const std::vector<PartiallySignedTransaction>& psbtxs);
int64_t CAmount
Amount in satoshis (Can be negative)
static constexpr size_t OUTPUT_SIZE
static constexpr size_t OUTPUT_SIZE
An outpoint - a combination of a transaction hash and an index n into its vout.
An encapsulated public key.
CKeyID GetID() const
Get the KeyID of this public key (hash of its serialization)
static constexpr unsigned int COMPRESSED_SIZE
static constexpr unsigned int SIZE
secp256k1:
bool IsFullyValid() const
fully validate whether this is a valid public key (more expensive than IsValid())
void Set(const T pbegin, const T pend)
Initialize a public key using begin/end iterators to byte data.
static constexpr size_t OUTPUT_SIZE
static constexpr size_t OUTPUT_SIZE
Serialized script, used inside transaction inputs and outputs.
An input of a transaction.
CScriptWitness scriptWitness
Only serialized through CTransaction.
An output of a transaction.
A structure for PSBTs which contains per output information.
std::map< CPubKey, std::vector< CPubKey > > m_musig2_participants
XOnlyPubKey m_tap_internal_key
std::map< XOnlyPubKey, std::pair< std::set< uint256 >, KeyOriginInfo > > m_tap_bip32_paths
bool operator==(const PSBTOutput &) const =default
std::set< PSBTProprietary > m_proprietary
PSBTOutput(deserialize_type, Stream &s, uint32_t psbt_version)
void Serialize(Stream &s) const
uint32_t GetVersion() const
bool Merge(const PSBTOutput &output)
std::map< CPubKey, KeyOriginInfo > hd_keypaths
std::vector< std::tuple< uint8_t, uint8_t, std::vector< unsigned char > > > m_tap_tree
void Unserialize(Stream &s)
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
void FillSignatureData(SignatureData &sigdata) const
PSBTOutput(uint32_t psbt_version, CAmount amount, const CScript &script)
void FromSignatureData(const SignatureData &sigdata)
A version of CTransaction with the PSBT format.
std::optional< std::bitset< 8 > > m_tx_modifiable
uint32_t GetVersion() const
bool Merge(const PartiallySignedTransaction &psbt)
Merge psbt into this.
std::map< KeyOriginInfo, std::set< CExtPubKey > > m_xpubs
std::optional< uint32_t > m_version
std::optional< Txid > GetUniqueID() const
std::map< std::vector< unsigned char >, std::vector< unsigned char > > unknown
std::vector< PSBTInput > inputs
void MergeGlobalXPubs(const PartiallySignedTransaction &psbt)
Merge the global xpubs of psbt into this, keeping the existing origin for an xpub seen again with a d...
std::optional< CMutableTransaction > GetUnsignedTx() const
std::optional< uint32_t > ComputeTimeLock() const
std::vector< PSBTOutput > outputs
std::set< PSBTProprietary > m_proprietary
void Serialize(Stream &s) const
bool AddOutput(const PSBTOutput &psbtout)
PartiallySignedTransaction(deserialize_type, Stream &s)
std::optional< uint32_t > fallback_locktime
void Unserialize(Stream &s)
PartiallySignedTransaction(const CMutableTransaction &tx, uint32_t version=2)
bool AddInput(const PSBTInput &psbtin)
An interface to be implemented by keystores that support signing.
Minimal stream for reading from an existing byte array by std::span.
Utility class to construct Taproot outputs from internal key and script tree.
bool IsComplete() const
Return whether there were either no leaves, or the leaves form a Huffman tree.
TaprootBuilder & Add(int depth, std::span< const unsigned char > script, int leaf_version, bool track=true)
Add a new script at a certain depth in the tree.
bool IsNull() const
Test whether this is the 0 key (the result of default construction).
constexpr bool IsNull() const
The util::Expected class provides a standard way for low-level functions to return either error value...
is a home for simple enum and struct type definitions that can be used internally by functions in the...
std::string HexStr(const std::span< const uint8_t > s)
Convert a span of bytes to a lower-case hexadecimal string.
bool CheckSignatureEncoding(const std::vector< unsigned char > &vchSig, script_verify_flags flags, ScriptError *serror)
constexpr uint8_t TAPROOT_LEAF_MASK
constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT
@ SCRIPT_VERIFY_STRICTENC
constexpr size_t MUSIG2_PUBNONCE_SIZE
constexpr TransactionSerParams TX_NO_WITNESS
constexpr TransactionSerParams TX_WITH_WITNESS
std::shared_ptr< const CTransaction > CTransactionRef
constexpr uint8_t PSBT_OUT_AMOUNT
void SerializeToVector(Stream &s, const X &... args)
constexpr uint8_t PSBT_IN_REQUIRED_HEIGHT_LOCKTIME
constexpr uint8_t PSBT_IN_RIPEMD160
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
constexpr uint8_t PSBT_IN_HASH256
constexpr uint8_t PSBT_IN_REQUIRED_TIME_LOCKTIME
constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX
constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO
util::Expected< void, PSBTError > SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, const PrecomputedTransactionData *txdata, const common::PSBTFillOptions &options, SignatureData *out_sigdata=nullptr)
Signs a PSBTInput, verifying that all provided data matches what is being signed.
constexpr uint8_t PSBT_IN_TAP_KEY_SIG
void UnserializeFromVector(Stream &s, X &&... args)
constexpr uint8_t PSBT_IN_SCRIPTSIG
constexpr uint8_t PSBT_IN_WITNESSSCRIPT
constexpr uint8_t PSBT_IN_OUTPUT_INDEX
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::string PSBTRoleName(PSBTRole role)
util::Result< PartiallySignedTransaction > DecodeBase64PSBT(const std::string &base64_tx)
Decode a base64ed PSBT into a PartiallySignedTransaction.
constexpr uint8_t PSBT_OUT_REDEEMSCRIPT
constexpr uint8_t PSBT_GLOBAL_VERSION
constexpr uint8_t PSBT_GLOBAL_TX_VERSION
constexpr uint8_t PSBT_IN_TAP_LEAF_SCRIPT
constexpr uint8_t PSBT_OUT_PROPRIETARY
constexpr uint8_t PSBT_MAGIC_BYTES[5]
std::optional< PartiallySignedTransaction > CombinePSBTs(const std::vector< PartiallySignedTransaction > &psbtxs)
Combines PSBTs with the same underlying transaction, resulting in a single PSBT with all partial sign...
constexpr uint32_t PSBT_HIGHEST_VERSION
constexpr uint8_t PSBT_SEPARATOR
constexpr uint8_t PSBT_IN_BIP32_DERIVATION
void DeserializeMuSig2ParticipantPubkeys(Stream &s, SpanReader &skey, std::map< CPubKey, std::vector< CPubKey > > &out, std::string context)
constexpr uint8_t PSBT_IN_SCRIPTWITNESS
constexpr uint8_t PSBT_OUT_TAP_TREE
constexpr uint8_t PSBT_IN_PREVIOUS_TXID
constexpr uint8_t PSBT_OUT_BIP32_DERIVATION
constexpr uint8_t PSBT_GLOBAL_PROPRIETARY
void RemoveUnnecessaryTransactions(PartiallySignedTransaction &psbtx)
Reduces the size of the PSBT by dropping unnecessary non_witness_utxos (i.e.
std::optional< PrecomputedTransactionData > PrecomputePSBTData(const PartiallySignedTransaction &psbt)
Compute a PrecomputedTransactionData object from a psbt.
constexpr uint8_t PSBT_IN_PROPRIETARY
constexpr uint8_t PSBT_GLOBAL_TX_MODIFIABLE
constexpr uint8_t PSBT_IN_SEQUENCE
KeyOriginInfo DeserializeKeyOrigin(Stream &s, uint64_t length)
void DeserializeMuSig2ParticipantDataIdentifier(Stream &skey, CPubKey &agg_pub, CPubKey &part_pub, uint256 &leaf_hash)
constexpr uint8_t PSBT_IN_TAP_SCRIPT_SIG
constexpr uint8_t PSBT_IN_MUSIG2_PUB_NONCE
void SerializeHDKeypaths(Stream &s, const std::map< CPubKey, KeyOriginInfo > &hd_keypaths, CompactSizeWriter type)
static void ExpectedKeySize(const std::string &key_name, const std::vector< unsigned char > &key, uint64_t expected_size)
constexpr uint8_t PSBT_IN_TAP_BIP32_DERIVATION
constexpr uint8_t PSBT_IN_HASH160
constexpr uint8_t PSBT_IN_REDEEMSCRIPT
constexpr uint8_t PSBT_OUT_WITNESSSCRIPT
constexpr uint8_t PSBT_GLOBAL_XPUB
constexpr uint8_t PSBT_OUT_MUSIG2_PARTICIPANT_PUBKEYS
constexpr uint8_t PSBT_GLOBAL_OUTPUT_COUNT
constexpr uint8_t PSBT_OUT_TAP_BIP32_DERIVATION
constexpr uint8_t PSBT_IN_PARTIAL_SIG
constexpr uint8_t PSBT_GLOBAL_FALLBACK_LOCKTIME
constexpr uint8_t PSBT_IN_TAP_INTERNAL_KEY
constexpr std::streamsize MAX_FILE_SIZE_PSBT
size_t CountPSBTUnsignedInputs(const PartiallySignedTransaction &psbt)
Counts the unsigned inputs of a PSBT.
bool FinalizeAndExtractPSBT(PartiallySignedTransaction &psbtx, CMutableTransaction &result)
Finalizes a PSBT if possible, and extracts it to a CMutableTransaction if it could be finalized.
constexpr uint8_t PSBT_OUT_TAP_INTERNAL_KEY
constexpr uint8_t PSBT_IN_TAP_MERKLE_ROOT
void SerializeKeyOrigin(Stream &s, KeyOriginInfo hd_keypath)
void DeserializeHDKeypaths(Stream &s, const std::vector< unsigned char > &key, std::map< CPubKey, KeyOriginInfo > &hd_keypaths)
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.
constexpr uint8_t PSBT_IN_MUSIG2_PARTICIPANT_PUBKEYS
void SerializeHDKeypath(Stream &s, KeyOriginInfo hd_keypath)
void DeserializeHDKeypath(Stream &s, KeyOriginInfo &hd_keypath)
bool FinalizePSBT(PartiallySignedTransaction &psbtx)
Finalizes a PSBT if possible, combining partial signatures.
constexpr uint8_t PSBT_OUT_SCRIPT
util::Result< PartiallySignedTransaction > DecodeRawPSBT(std::span< const std::byte > tx_data)
Decode a raw (binary blob) PSBT into a PartiallySignedTransaction.
constexpr uint8_t PSBT_GLOBAL_INPUT_COUNT
constexpr uint8_t PSBT_IN_WITNESS_UTXO
constexpr uint8_t PSBT_IN_MUSIG2_PARTIAL_SIG
constexpr uint8_t PSBT_IN_SHA256
constexpr unsigned int BIP32_EXTKEY_WITH_VERSION_SIZE
constexpr unsigned int LOCKTIME_THRESHOLD
std::vector< unsigned char > ToByteVector(const T &in)
void SerializeMany(Stream &s, const Args &... args)
Support for (un)serializing many things at once.
constexpr deserialize_type deserialize
void UnserializeMany(Stream &s, Args &&... args)
void WriteCompactSize(SizeComputer &os, uint64_t nSize)
uint64_t ReadCompactSize(Stream &is, bool range_check=true)
Decode a CompactSize-encoded variable-length integer.
std::pair< CPubKey, std::vector< unsigned char > > SigPair
void DecodeWithVersion(const unsigned char code[BIP32_EXTKEY_WITH_VERSION_SIZE])
A mutable version of CTransaction.
std::vector< std::vector< unsigned char > > stack
KeyFingerprint fingerprint
First 32 bits of the Hash160 of the public key at the root of the path.
std::vector< uint32_t > path
A structure for PSBT proprietary types.
std::vector< unsigned char > value
bool operator<(const PSBTProprietary &b) const
std::vector< unsigned char > identifier
std::vector< unsigned char > key
bool operator==(const PSBTProprietary &b) const
Instructions for how a PSBT should be signed or filled with information.
Dummy data type to identify deserializing constructors.
FuzzedDataProvider provider