diff options
author | Andrew Chow <achow101-github@achow101.com> | 2018-06-27 16:58:01 -0700 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2018-07-13 14:27:31 -0700 |
commit | e9d86a43ad8b1ab83b324e9a7a64c43a61337501 (patch) | |
tree | 40a105b868ba62d9b7861d6e80e8c38371107930 /src/script/sign.h | |
parent | 12bcc64f277f642ece03c25653e726f2276f0d51 (diff) |
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.
Diffstat (limited to 'src/script/sign.h')
-rw-r--r-- | src/script/sign.h | 14 |
1 files changed, 14 insertions, 0 deletions
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 <typename Stream> @@ -375,6 +379,10 @@ struct PSBTOutput std::map<std::vector<unsigned char>, std::vector<unsigned char>> unknown; bool IsNull() const; + void FillSignatureData(SignatureData& sigdata) const; + void FromSignatureData(const SignatureData& sigdata); + void Merge(const PSBTOutput& output); + bool IsSane() const; PSBTOutput() {} template <typename Stream> @@ -472,6 +480,8 @@ struct PartiallySignedTransaction std::map<std::vector<unsigned char>, std::vector<unsigned char>> 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 <typename Stream> |