102 std::vector<unsigned char>
key;
115template<
typename Stream,
typename...
X>
125template<
typename Stream,
typename...
X>
129 size_t remaining_before =
s.size();
131 size_t remaining_after =
s.size();
132 if (remaining_after + expected_size != remaining_before) {
133 throw std::ios_base::failure(
"Size of value was not the stated size");
138template<
typename Stream>
142 if (length % 4 || length == 0) {
143 throw std::ios_base::failure(
"Invalid length for HD key path");
148 for (
unsigned int i = 4; i < length; i +=
sizeof(uint32_t)) {
151 hd_keypath.
path.push_back(index);
157template<
typename Stream>
164template<
typename Stream>
165void DeserializeHDKeypaths(Stream&
s,
const std::vector<unsigned char>& key, std::map<CPubKey, KeyOriginInfo>& hd_keypaths)
169 throw std::ios_base::failure(
"Size of key was not the expected size for the type BIP32 keypath");
172 CPubKey pubkey(key.begin() + 1, key.end());
174 throw std::ios_base::failure(
"Invalid pubkey");
181 hd_keypaths.emplace(pubkey, std::move(keypath));
185template<
typename Stream>
189 for (
const auto& path : hd_keypath.
path) {
195template<
typename Stream>
203template<
typename Stream>
206 for (
const auto& keypath_pair : hd_keypaths) {
207 if (!keypath_pair.first.IsValid()) {
208 throw std::ios_base::failure(
"Invalid CPubKey being serialized");
216template<
typename Stream>
219 std::array<unsigned char, CPubKey::COMPRESSED_SIZE> agg_pubkey_bytes;
220 skey >> std::as_writable_bytes(std::span{agg_pubkey_bytes});
221 CPubKey agg_pubkey(agg_pubkey_bytes);
222 if (!agg_pubkey.IsFullyValid()) {
223 throw std::ios_base::failure(context +
" musig2 aggregate pubkey is invalid");
226 std::vector<CPubKey> participants;
227 std::vector<unsigned char> val;
231 std::array<unsigned char, CPubKey::COMPRESSED_SIZE> part_pubkey_bytes;
232 s_val >> std::as_writable_bytes(std::span{part_pubkey_bytes});
233 CPubKey participant(part_pubkey_bytes);
234 if (!participant.IsFullyValid()) {
235 throw std::ios_base::failure(context +
" musig2 participant pubkey is invalid");
237 participants.push_back(participant);
239 if (!s_val.empty()) {
240 throw std::ios_base::failure(context +
" musig2 participants pubkeys value size is not a multiple of 33");
243 out.emplace(agg_pubkey, participants);
248template<
typename Stream>
253 std::array<unsigned char, CPubKey::COMPRESSED_SIZE> part_pubkey_bytes;
254 std::array<unsigned char, CPubKey::COMPRESSED_SIZE> agg_pubkey_bytes;
256 skey >> std::as_writable_bytes(std::span{part_pubkey_bytes}) >> std::as_writable_bytes(std::span{agg_pubkey_bytes});
257 agg_pub.
Set(agg_pubkey_bytes.begin(), agg_pubkey_bytes.end());
259 throw std::ios_base::failure(
"musig2 aggregate pubkey is invalid");
262 part_pub.
Set(part_pubkey_bytes.begin(), part_pubkey_bytes.end());
264 throw std::ios_base::failure(
"musig2 participant pubkey is invalid");
272static inline void ExpectedKeySize(
const std::string& key_name,
const std::vector<unsigned char>& key, uint64_t expected_size) {
273 if (key.size() != expected_size) {
274 throw std::ios_base::failure(
tfm::format(
"Size of key was not %d for the type %s", expected_size, key_name));
319 std::map<std::vector<unsigned char>, std::vector<unsigned char>>
unknown;
348 template <
typename Stream>
358 template <
typename Stream>
374 s << sig_pair.second.second;
430 const auto& [xonly, leaf_hash] = pubkey_leaf;
437 const auto& [
script, leaf_ver] = leaf;
438 for (
const auto& control_block : control_blocks) {
440 std::vector<unsigned char> value_v(
script.begin(),
script.end());
441 value_v.push_back((uint8_t)leaf_ver);
448 const auto& [leaf_hashes, origin] = leaf_origin;
450 std::vector<unsigned char> value;
452 s_value << leaf_hashes;
472 std::vector<unsigned char> value;
474 for (
auto&
pk : part_pubs) {
475 s_value << std::span{
pk};
482 const auto& [agg_pubkey, leaf_hash] = agg_pubkey_leaf_hash;
483 for (
const auto& [part_pubkey, pubnonce] : pubnonces) {
484 if (leaf_hash.IsNull()) {
495 const auto& [agg_pubkey, leaf_hash] = agg_pubkey_leaf_hash;
496 for (
const auto& [pubkey, psig] : psigs) {
497 if (leaf_hash.IsNull()) {
557 template <
typename Stream>
560 std::set<std::vector<unsigned char>> key_lookup;
562 bool found_prev_txid =
false;
563 bool found_prev_out =
false;
566 bool found_sep =
false;
570 std::vector<unsigned char> key;
581 if (!key_lookup.emplace(key).second) {
582 throw std::ios_base::failure(
tfm::format(
"Duplicate Key, input key \"%s\" already provided",
HexStr(key)));
608 throw std::ios_base::failure(
"Size of key was not the expected size for the type partial signature pubkey");
611 CPubKey pubkey(key.begin() + 1, key.end());
613 throw std::ios_base::failure(
"Invalid pubkey");
617 std::vector<unsigned char> sig;
622 throw std::ios_base::failure(
"Signature is not a valid encoding");
668 std::vector<unsigned char> hash_vec(key.begin() + 1, key.end());
672 std::vector<unsigned char> preimage;
683 std::vector<unsigned char> hash_vec(key.begin() + 1, key.end());
687 std::vector<unsigned char> preimage;
698 std::vector<unsigned char> hash_vec(key.begin() + 1, key.end());
702 std::vector<unsigned char> preimage;
713 std::vector<unsigned char> hash_vec(key.begin() + 1, key.end());
717 std::vector<unsigned char> preimage;
728 throw std::ios_base::failure(
"Previous txid is not allowed in PSBTv0");
731 found_prev_txid =
true;
738 throw std::ios_base::failure(
"Previous output's index is not allowed in PSBTv0");
741 found_prev_out =
true;
748 throw std::ios_base::failure(
"Sequence is not allowed in PSBTv0");
758 throw std::ios_base::failure(
"Required time based locktime is not allowed in PSBTv0");
763 throw std::ios_base::failure(
"Required time based locktime is invalid (less than 500000000)");
771 throw std::ios_base::failure(
"Required height based locktime is not allowed in PSBTv0");
776 throw std::ios_base::failure(
"Required height based locktime is invalid (greater than or equal to 500000000)");
778 throw std::ios_base::failure(
"Required height based locktime is invalid (0)");
787 throw std::ios_base::failure(
"Input Taproot key path signature is shorter than 64 bytes");
789 throw std::ios_base::failure(
"Input Taproot key path signature is longer than 65 bytes");
801 std::vector<unsigned char> sig;
803 if (sig.size() < 64) {
804 throw std::ios_base::failure(
"Input Taproot script path signature is shorter than 64 bytes");
805 }
else if (sig.size() > 65) {
806 throw std::ios_base::failure(
"Input Taproot script path signature is longer than 65 bytes");
813 if (key.size() < 34) {
814 throw std::ios_base::failure(
"Input Taproot leaf script key is not at least 34 bytes");
815 }
else if ((key.size() - 2) % 32 != 0) {
816 throw std::ios_base::failure(
"Input Taproot leaf script key's control block size is not valid");
818 std::vector<unsigned char> script_v;
820 if (script_v.empty()) {
821 throw std::ios_base::failure(
"Input Taproot leaf script must be at least 1 byte");
823 uint8_t leaf_ver = script_v.back();
825 const auto leaf_script = std::make_pair(script_v, (
int)leaf_ver);
826 m_tap_scripts[leaf_script].insert(std::vector<unsigned char>(key.begin() + 1, key.end()));
835 std::set<uint256> leaf_hashes;
837 size_t before_hashes =
s.size();
839 size_t after_hashes =
s.size();
840 size_t hashes_len = before_hashes - after_hashes;
841 if (hashes_len > value_len) {
842 throw std::ios_base::failure(
"Input Taproot BIP32 keypath has an invalid length");
844 size_t origin_len = value_len - hashes_len;
869 throw std::ios_base::failure(
"Input musig2 pubnonce key is not expected size of 67 or 99 bytes");
875 std::vector<uint8_t> pubnonce;
878 throw std::ios_base::failure(
"Input musig2 pubnonce value is not 66 bytes");
887 throw std::ios_base::failure(
"Input musig2 partial sig key is not expected size of 67 or 99 bytes");
913 std::vector<unsigned char> val_bytes;
915 unknown.emplace(std::move(key), std::move(val_bytes));
921 throw std::ios_base::failure(
"Separator is missing at the end of an input map");
926 if (!found_prev_txid) {
927 throw std::ios_base::failure(
"Previous TXID is required in PSBTv2");
929 if (!found_prev_out) {
930 throw std::ios_base::failure(
"Previous output's index is required in PSBTv2");
948 std::vector<std::tuple<uint8_t, uint8_t, std::vector<unsigned char>>>
m_tap_tree;
952 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;
1269 template <
typename Stream>
1284 for (
const auto& xpub_pair :
m_xpubs) {
1285 for (
const auto& xpub : xpub_pair.second) {
1287 xpub.EncodeWithVersion(ser_xpub);
1347 template <
typename Stream>
1353 throw std::ios_base::failure(
"Invalid PSBT magic bytes");
1357 std::set<std::vector<unsigned char>> key_lookup;
1360 std::set<CExtPubKey> global_xpubs;
1363 bool found_sep =
false;
1364 std::optional<CMutableTransaction> tx;
1365 uint64_t input_count = 0;
1366 uint64_t output_count = 0;
1367 bool found_input_count =
false;
1368 bool found_output_count =
false;
1369 bool found_tx_version =
false;
1370 bool found_fallback_locktime =
false;
1374 std::vector<unsigned char> key;
1385 if (!key_lookup.emplace(key).second) {
1386 throw std::ios_base::failure(
tfm::format(
"Duplicate Key, global key \"%s\" already provided",
HexStr(key)));
1404 for (
const CTxIn& txin : tx->vin) {
1406 throw std::ios_base::failure(
"Unsigned tx does not have empty scriptSigs and scriptWitnesses.");
1412 input_count = tx->vin.size();
1413 output_count = tx->vout.size();
1420 found_tx_version =
true;
1428 found_fallback_locktime =
true;
1436 found_input_count =
true;
1444 found_output_count =
true;
1462 throw std::ios_base::failure(
"Invalid pubkey");
1464 global_xpubs.insert(xpub);
1471 if (!
m_xpubs.contains(keypath)) {
1476 m_xpubs[keypath].insert(xpub);
1487 throw std::ios_base::failure(
"Unsupported version number");
1496 this_prop.
key = key;
1505 std::vector<unsigned char> val_bytes;
1507 unknown.emplace(std::move(key), std::move(val_bytes));
1513 throw std::ios_base::failure(
"Separator is missing at the end of the global map");
1519 if (psbt_ver == 0) {
1522 throw std::ios_base::failure(
"No unsigned transaction was provided");
1525 if (found_tx_version) {
1526 throw std::ios_base::failure(
"PSBT_GLOBAL_TX_VERSION is not allowed in PSBTv0");
1528 if (found_fallback_locktime) {
1529 throw std::ios_base::failure(
"PSBT_GLOBAL_FALLBACK_LOCKTIME is not allowed in PSBTv0");
1531 if (found_input_count) {
1532 throw std::ios_base::failure(
"PSBT_GLOBAL_INPUT_COUNT is not allowed in PSBTv0");
1534 if (found_output_count) {
1535 throw std::ios_base::failure(
"PSBT_GLOBAL_OUTPUT_COUNT is not allowed in PSBTv0");
1538 throw std::ios_base::failure(
"PSBT_GLOBAL_TX_MODIFIABLE is not allowed in PSBTv0");
1542 if (psbt_ver == 1) {
1543 throw std::ios_base::failure(
"There is no PSBT version 1");
1545 if (psbt_ver == 2) {
1547 if (!found_tx_version) {
1548 throw std::ios_base::failure(
"PSBT_GLOBAL_TX_VERSION is required in PSBTv2");
1550 if (!found_input_count) {
1551 throw std::ios_base::failure(
"PSBT_GLOBAL_INPUT_COUNT is required in PSBTv2");
1553 if (!found_output_count) {
1554 throw std::ios_base::failure(
"PSBT_GLOBAL_OUTPUT_COUNT is required in PSBTv2");
1558 throw std::ios_base::failure(
"PSBT_GLOBAL_UNSIGNED_TX is not allowed in PSBTv2");
1562 throw std::ios_base::failure(
"Unknown PSBT version");
1567 while (!
s.empty() && i < input_count) {
1569 inputs.emplace_back(psbt_ver, tx->vin[i].prevout.hash, tx->vin[i].prevout.n, tx->vin[i].nSequence);
1580 throw std::ios_base::failure(
"Non-witness UTXO does not match outpoint hash");
1583 throw std::ios_base::failure(
"Input specifies output index that does not exist");
1587 throw std::ios_base::failure(
"Non-witness UTXO does not match outpoint hash");
1590 throw std::ios_base::failure(
"Input specifies output index that does not exist");
1597 if (
inputs.size() != input_count) {
1598 throw std::ios_base::failure(
"Inputs provided does not match the number of inputs in transaction.");
1603 while (!
s.empty() && i < output_count) {
1605 outputs.emplace_back(psbt_ver, tx->vout[i].nValue, tx->vout[i].scriptPubKey);
1613 if (
outputs.size() != output_count) {
1614 throw std::ios_base::failure(
"Outputs provided does not match the number of outputs in transaction.");
1618 template <
typename Stream>
1685[[nodiscard]] std::optional<PartiallySignedTransaction>
CombinePSBTs(
const std::vector<PartiallySignedTransaction>& psbtxs);
int64_t CAmount
Amount in satoshis (Can be negative)
static const size_t OUTPUT_SIZE
static const 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 const size_t OUTPUT_SIZE
static const 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
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
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)
static constexpr uint8_t TAPROOT_LEAF_MASK
static constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT
@ SCRIPT_VERIFY_STRICTENC
constexpr size_t MUSIG2_PUBNONCE_SIZE
static constexpr TransactionSerParams TX_NO_WITNESS
static constexpr TransactionSerParams TX_WITH_WITNESS
std::shared_ptr< const CTransaction > CTransactionRef
static constexpr uint8_t PSBT_OUT_AMOUNT
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.
void SerializeToVector(Stream &s, const X &... args)
static constexpr uint8_t PSBT_IN_REQUIRED_HEIGHT_LOCKTIME
static constexpr uint8_t PSBT_IN_RIPEMD160
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
static constexpr uint8_t PSBT_IN_HASH256
static constexpr uint8_t PSBT_IN_REQUIRED_TIME_LOCKTIME
static constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX
static constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO
static constexpr uint8_t PSBT_IN_TAP_KEY_SIG
void UnserializeFromVector(Stream &s, X &&... args)
static constexpr uint8_t PSBT_IN_SCRIPTSIG
static constexpr uint8_t PSBT_IN_WITNESSSCRIPT
static 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.
static constexpr uint8_t PSBT_OUT_REDEEMSCRIPT
static constexpr uint8_t PSBT_GLOBAL_VERSION
static constexpr uint8_t PSBT_GLOBAL_TX_VERSION
static constexpr uint8_t PSBT_IN_TAP_LEAF_SCRIPT
static constexpr uint8_t PSBT_OUT_PROPRIETARY
static 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...
static constexpr uint32_t PSBT_HIGHEST_VERSION
static constexpr uint8_t PSBT_SEPARATOR
static constexpr uint8_t PSBT_IN_BIP32_DERIVATION
void DeserializeMuSig2ParticipantPubkeys(Stream &s, SpanReader &skey, std::map< CPubKey, std::vector< CPubKey > > &out, std::string context)
static constexpr uint8_t PSBT_IN_SCRIPTWITNESS
static constexpr uint8_t PSBT_OUT_TAP_TREE
static constexpr uint8_t PSBT_IN_PREVIOUS_TXID
static constexpr uint8_t PSBT_OUT_BIP32_DERIVATION
static 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.
static constexpr uint8_t PSBT_IN_PROPRIETARY
static constexpr uint8_t PSBT_GLOBAL_TX_MODIFIABLE
static 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)
static constexpr uint8_t PSBT_IN_TAP_SCRIPT_SIG
static 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)
static constexpr uint8_t PSBT_IN_TAP_BIP32_DERIVATION
static constexpr uint8_t PSBT_IN_HASH160
static constexpr uint8_t PSBT_IN_REDEEMSCRIPT
static constexpr uint8_t PSBT_OUT_WITNESSSCRIPT
static constexpr uint8_t PSBT_GLOBAL_XPUB
static constexpr uint8_t PSBT_OUT_MUSIG2_PARTICIPANT_PUBKEYS
static constexpr uint8_t PSBT_GLOBAL_OUTPUT_COUNT
static constexpr uint8_t PSBT_OUT_TAP_BIP32_DERIVATION
static constexpr uint8_t PSBT_IN_PARTIAL_SIG
static constexpr uint8_t PSBT_GLOBAL_FALLBACK_LOCKTIME
static constexpr uint8_t PSBT_IN_TAP_INTERNAL_KEY
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.
static constexpr uint8_t PSBT_OUT_TAP_INTERNAL_KEY
static 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)
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.
static 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.
static 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.
static constexpr uint8_t PSBT_GLOBAL_INPUT_COUNT
const std::streamsize MAX_FILE_SIZE_PSBT
static constexpr uint8_t PSBT_IN_WITNESS_UTXO
static constexpr uint8_t PSBT_IN_MUSIG2_PARTIAL_SIG
static constexpr uint8_t PSBT_IN_SHA256
const unsigned int BIP32_EXTKEY_WITH_VERSION_SIZE
static const 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
unsigned char fingerprint[4]
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.