From e9d86a43ad8b1ab83b324e9a7a64c43a61337501 Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Wed, 27 Jun 2018 16:58:01 -0700 Subject: Methods for interacting with PSBT structs Added methods which move data to/from SignaturData objects to PSBTInput and PSBTOutput objects. Added sanity checks for PSBTs as a whole which are done immediately after deserialization. Added Merge methods to merge a PSBT into another one. --- src/script/sign.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/script/sign.h') diff --git a/src/script/sign.h b/src/script/sign.h index 5384f97539..ab2153e3b9 100644 --- a/src/script/sign.h +++ b/src/script/sign.h @@ -187,6 +187,10 @@ struct PSBTInput int sighash_type = 0; bool IsNull() const; + void FillSignatureData(SignatureData& sigdata) const; + void FromSignatureData(const SignatureData& sigdata); + void Merge(const PSBTInput& input); + bool IsSane() const; PSBTInput() {} template @@ -375,6 +379,10 @@ struct PSBTOutput std::map, std::vector> unknown; bool IsNull() const; + void FillSignatureData(SignatureData& sigdata) const; + void FromSignatureData(const SignatureData& sigdata); + void Merge(const PSBTOutput& output); + bool IsSane() const; PSBTOutput() {} template @@ -472,6 +480,8 @@ struct PartiallySignedTransaction std::map, std::vector> unknown; bool IsNull() const; + void Merge(const PartiallySignedTransaction& psbt); + bool IsSane() const; PartiallySignedTransaction() {} PartiallySignedTransaction(const PartiallySignedTransaction& psbt_in) : tx(psbt_in.tx), inputs(psbt_in.inputs), outputs(psbt_in.outputs), unknown(psbt_in.unknown) {} @@ -605,6 +615,10 @@ struct PartiallySignedTransaction if (outputs.size() != tx->vout.size()) { throw std::ios_base::failure("Outputs provided does not match the number of outputs in transaction."); } + // Sanity check + if (!IsSane()) { + throw std::ios_base::failure("PSBT is not sane."); + } } template -- cgit v1.2.3