50 std::map<std::vector<uint8_t>, std::vector<uint8_t>>
unknown;
113 std::vector<uint8_t> key;
131 throw std::ios_base::failure(
132 "Duplicate Key, input utxo already provided");
133 }
else if (key.size() != 1) {
134 throw std::ios_base::failure(
135 "utxo key is more than one byte type");
143 throw std::ios_base::failure(
144 "Size of key was not the expected size for the "
145 "type partial signature pubkey");
148 CPubKey pubkey(key.begin() + 1, key.end());
150 throw std::ios_base::failure(
"Invalid pubkey");
153 throw std::ios_base::failure(
154 "Duplicate Key, input partial signature for pubkey "
159 std::vector<uint8_t>
sig;
169 throw std::ios_base::failure(
170 "Duplicate Key, input sighash type already "
172 }
else if (key.size() != 1) {
173 throw std::ios_base::failure(
174 "Sighash type key is more than one byte type");
180 throw std::ios_base::failure(
181 "Duplicate Key, input redeemScript already "
183 }
else if (key.size() != 1) {
184 throw std::ios_base::failure(
185 "Input redeemScript key is more than one byte "
197 throw std::ios_base::failure(
198 "Duplicate Key, input final scriptSig already "
200 }
else if (key.size() != 1) {
201 throw std::ios_base::failure(
202 "Final scriptSig key is more than one byte type");
210 throw std::ios_base::failure(
211 "Duplicate Key, key for unknown value already "
222 throw std::ios_base::failure(
223 "Separator is missing at the end of an input map");
236 std::map<std::vector<uint8_t>, std::vector<uint8_t>>
unknown;
271 std::vector<uint8_t> key;
289 throw std::ios_base::failure(
290 "Duplicate Key, output redeemScript already "
292 }
else if (key.size() != 1) {
293 throw std::ios_base::failure(
294 "Output redeemScript key is more than one byte "
307 throw std::ios_base::failure(
308 "Duplicate Key, key for unknown value already "
321 throw std::ios_base::failure(
322 "Separator is missing at the end of an output map");
335 std::optional<CMutableTransaction>
tx;
338 std::map<std::vector<uint8_t>, std::vector<uint8_t>>
unknown;
396 throw std::ios_base::failure(
"Invalid PSBT magic bytes");
406 std::vector<uint8_t> key;
424 throw std::ios_base::failure(
425 "Duplicate Key, unsigned tx already provided");
426 }
else if (key.size() != 1) {
427 throw std::ios_base::failure(
428 "Global unsigned tx key is more than one byte "
436 if (!
txin.scriptSig.empty()) {
437 throw std::ios_base::failure(
438 "Unsigned tx does not have empty scriptSigs.");
446 throw std::ios_base::failure(
447 "Duplicate Key, key for unknown value already "
459 throw std::ios_base::failure(
460 "Separator is missing at the end of the global map");
465 throw std::ios_base::failure(
466 "No unsigned transcation was provided");
471 while (!s.empty() &&
i < tx->vin.size()) {
479 if (
inputs.size() !=
tx->vin.size()) {
480 throw std::ios_base::failure(
"Inputs provided does not match the "
481 "number of inputs in transaction.");
486 while (!s.empty() &&
i < tx->vout.size()) {
495 throw std::ios_base::failure(
"Outputs provided does not match the "
496 "number of outputs in transaction.");
500 template <
typename Stream>
569 const std::vector<PartiallySignedTransaction> &
psbtxs);
A mutable version of CTransaction.
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())
Serialized script, used inside transaction inputs and outputs.
An input of a transaction.
An output of a transaction.
Signature hash type wrapper class.
uint32_t getRawSigHashType() const
An interface to be implemented by keystores that support signing.
A Span is an object that can refer to a contiguous sequence of objects.
CONSTEXPR_IF_NOT_DEBUG Span< C > first(std::size_t count) const noexcept
bool error(const char *fmt, const Args &...args)
bool SignPSBTInput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index, SigHashType sighash=SigHashType(), SignatureData *out_sigdata=nullptr, bool use_dummy=false)
Signs a PSBTInput, verifying that all provided data matches what is being signed.
static constexpr uint8_t PSBT_IN_UTXO
void UpdatePSBTOutput(const SigningProvider &provider, PartiallySignedTransaction &psbt, int index)
Updates a PSBTOutput with information from provider.
static constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX
static constexpr uint8_t PSBT_IN_SCRIPTSIG
std::string PSBTRoleName(PSBTRole role)
static constexpr uint8_t PSBT_OUT_REDEEMSCRIPT
static constexpr uint8_t PSBT_MAGIC_BYTES[5]
static constexpr uint8_t PSBT_SEPARATOR
static constexpr uint8_t PSBT_IN_BIP32_DERIVATION
static constexpr uint8_t PSBT_OUT_BIP32_DERIVATION
bool DecodeRawPSBT(PartiallySignedTransaction &decoded_psbt, Span< const std::byte > raw_psbt, std::string &error)
Decode a raw (binary blob) PSBT into a PartiallySignedTransaction.
static constexpr uint8_t PSBT_IN_REDEEMSCRIPT
bool DecodeBase64PSBT(PartiallySignedTransaction &decoded_psbt, const std::string &base64_psbt, std::string &error)
Decode a base64ed PSBT into a PartiallySignedTransaction.
static constexpr uint8_t PSBT_IN_PARTIAL_SIG
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_IN_SIGHASH
bool PSBTInputSigned(const PSBTInput &input)
Checks whether a PSBTInput is already signed.
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...
bool FinalizePSBT(PartiallySignedTransaction &psbtx)
Finalizes a PSBT if possible, combining partial signatures.
const std::streamsize MAX_FILE_SIZE_PSBT
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
void UnserializeFromVector(Stream &s, X &...args)
void SerializeToVector(Stream &s, const X &...args)
void SerializeHDKeypaths(Stream &s, const std::map< CPubKey, KeyOriginInfo > &hd_keypaths, uint8_t type)
void DeserializeHDKeypaths(Stream &s, const std::vector< uint8_t > &key, std::map< CPubKey, KeyOriginInfo > &hd_keypaths)
std::pair< CPubKey, std::vector< uint8_t > > SigPair
A structure for PSBTs which contains per output information.
void Merge(const PSBTOutput &output)
void Serialize(Stream &s) const
PSBTOutput(deserialize_type, Stream &s)
std::map< CPubKey, KeyOriginInfo > hd_keypaths
void Unserialize(Stream &s)
std::map< std::vector< uint8_t >, std::vector< uint8_t > > unknown
void FillSignatureData(SignatureData &sigdata) const
void FromSignatureData(const SignatureData &sigdata)
A version of CTransaction with the PSBT format.
bool Merge(const PartiallySignedTransaction &psbt)
Merge psbt into this.
PartiallySignedTransaction()
std::map< std::vector< uint8_t >, std::vector< uint8_t > > unknown
bool GetInputUTXO(CTxOut &utxo, int input_index) const
Finds the UTXO for a given input index.
bool AddOutput(const CTxOut &txout, const PSBTOutput &psbtout)
std::vector< PSBTInput > inputs
std::optional< CMutableTransaction > tx
bool AddInput(const CTxIn &txin, PSBTInput &psbtin)
std::vector< PSBTOutput > outputs
void Serialize(Stream &s) const
PartiallySignedTransaction(deserialize_type, Stream &s)
void Unserialize(Stream &s)
Dummy data type to identify deserializing constructors.