Changeset View
Changeset View
Standalone View
Standalone View
src/psbt.h
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Lines | struct PSBTInput { | ||||
std::map<CKeyID, SigPair> partial_sigs; | std::map<CKeyID, SigPair> partial_sigs; | ||||
std::map<std::vector<uint8_t>, std::vector<uint8_t>> unknown; | std::map<std::vector<uint8_t>, std::vector<uint8_t>> unknown; | ||||
SigHashType sighash_type = SigHashType(0); | SigHashType sighash_type = SigHashType(0); | ||||
bool IsNull() const; | bool IsNull() const; | ||||
void FillSignatureData(SignatureData &sigdata) const; | void FillSignatureData(SignatureData &sigdata) const; | ||||
void FromSignatureData(const SignatureData &sigdata); | void FromSignatureData(const SignatureData &sigdata); | ||||
void Merge(const PSBTInput &input); | void Merge(const PSBTInput &input); | ||||
bool IsSane() const; | |||||
PSBTInput() {} | PSBTInput() {} | ||||
template <typename Stream> inline void Serialize(Stream &s) const { | template <typename Stream> inline void Serialize(Stream &s) const { | ||||
// Write the utxo | // Write the utxo | ||||
if (!utxo.IsNull()) { | if (!utxo.IsNull()) { | ||||
SerializeToVector(s, PSBT_IN_UTXO); | SerializeToVector(s, PSBT_IN_UTXO); | ||||
SerializeToVector(s, utxo); | SerializeToVector(s, utxo); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 169 Lines • ▼ Show 20 Lines | struct PSBTOutput { | ||||
CScript redeem_script; | CScript redeem_script; | ||||
std::map<CPubKey, KeyOriginInfo> hd_keypaths; | std::map<CPubKey, KeyOriginInfo> hd_keypaths; | ||||
std::map<std::vector<uint8_t>, std::vector<uint8_t>> unknown; | std::map<std::vector<uint8_t>, std::vector<uint8_t>> unknown; | ||||
bool IsNull() const; | bool IsNull() const; | ||||
void FillSignatureData(SignatureData &sigdata) const; | void FillSignatureData(SignatureData &sigdata) const; | ||||
void FromSignatureData(const SignatureData &sigdata); | void FromSignatureData(const SignatureData &sigdata); | ||||
void Merge(const PSBTOutput &output); | void Merge(const PSBTOutput &output); | ||||
bool IsSane() const; | |||||
PSBTOutput() {} | PSBTOutput() {} | ||||
template <typename Stream> inline void Serialize(Stream &s) const { | template <typename Stream> inline void Serialize(Stream &s) const { | ||||
// Write the redeem script | // Write the redeem script | ||||
if (!redeem_script.empty()) { | if (!redeem_script.empty()) { | ||||
SerializeToVector(s, PSBT_OUT_REDEEMSCRIPT); | SerializeToVector(s, PSBT_OUT_REDEEMSCRIPT); | ||||
s << redeem_script; | s << redeem_script; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 90 Lines • ▼ Show 20 Lines | struct PartiallySignedTransaction { | ||||
bool IsNull() const; | bool IsNull() const; | ||||
/** | /** | ||||
* Merge psbt into this. The two psbts must have the same underlying | * Merge psbt into this. The two psbts must have the same underlying | ||||
* CTransaction (i.e. the same actual Bitcoin transaction.) Returns true if | * CTransaction (i.e. the same actual Bitcoin transaction.) Returns true if | ||||
* the merge succeeded, false otherwise. | * the merge succeeded, false otherwise. | ||||
*/ | */ | ||||
NODISCARD bool Merge(const PartiallySignedTransaction &psbt); | NODISCARD bool Merge(const PartiallySignedTransaction &psbt); | ||||
bool IsSane() const; | |||||
bool AddInput(const CTxIn &txin, PSBTInput &psbtin); | bool AddInput(const CTxIn &txin, PSBTInput &psbtin); | ||||
bool AddOutput(const CTxOut &txout, const PSBTOutput &psbtout); | bool AddOutput(const CTxOut &txout, const PSBTOutput &psbtout); | ||||
PartiallySignedTransaction() {} | PartiallySignedTransaction() {} | ||||
explicit PartiallySignedTransaction(const CMutableTransaction &txIn); | explicit PartiallySignedTransaction(const CMutableTransaction &txIn); | ||||
/** | /** | ||||
* Finds the UTXO for a given input index | * Finds the UTXO for a given input index | ||||
* | * | ||||
* @param[out] utxo The UTXO of the input if found | * @param[out] utxo The UTXO of the input if found | ||||
▲ Show 20 Lines • Show All 137 Lines • ▼ Show 20 Lines | template <typename Stream> inline void Unserialize(Stream &s) { | ||||
++i; | ++i; | ||||
} | } | ||||
// Make sure that the number of outputs matches the number of outputs in | // Make sure that the number of outputs matches the number of outputs in | ||||
// the transaction | // the transaction | ||||
if (outputs.size() != tx->vout.size()) { | if (outputs.size() != tx->vout.size()) { | ||||
throw std::ios_base::failure("Outputs provided does not match the " | throw std::ios_base::failure("Outputs provided does not match the " | ||||
"number of outputs in transaction."); | "number of outputs in transaction."); | ||||
} | } | ||||
// Sanity check | |||||
if (!IsSane()) { | |||||
throw std::ios_base::failure("PSBT is not sane."); | |||||
} | |||||
} | } | ||||
template <typename Stream> | template <typename Stream> | ||||
PartiallySignedTransaction(deserialize_type, Stream &s) { | PartiallySignedTransaction(deserialize_type, Stream &s) { | ||||
Unserialize(s); | Unserialize(s); | ||||
} | } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines |