From 41c607f09badb2c3ed58ff6fb17a8ebbef2cdabd Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Wed, 27 Jun 2018 16:53:48 -0700 Subject: [PATCH 1/8] Implement PSBT Structures and un/serialization methods per BIP 174 --- src/pubkey.h | 1 + src/script/sign.cpp | 16 ++ src/script/sign.h | 538 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 555 insertions(+) diff --git a/src/pubkey.h b/src/pubkey.h index bb254547c89..0985273f343 100644 --- a/src/pubkey.h +++ b/src/pubkey.h @@ -107,6 +107,7 @@ public: //! Simple read-only vector-like interface to the pubkey data. unsigned int size() const { return GetLen(vch[0]); } + const unsigned char* data() const { return vch; } const unsigned char* begin() const { return vch; } const unsigned char* end() const { return vch + size(); } const unsigned char& operator[](unsigned int pos) const { return vch[pos]; } diff --git a/src/script/sign.cpp b/src/script/sign.cpp index 60a8a2655d3..afbcb22d189 100644 --- a/src/script/sign.cpp +++ b/src/script/sign.cpp @@ -429,3 +429,19 @@ bool IsSolvable(const SigningProvider& provider, const CScript& script) } return false; } + + +bool PartiallySignedTransaction::IsNull() const +{ + return !tx && inputs.empty() && outputs.empty() && unknown.empty(); +} + +bool PSBTInput::IsNull() const +{ + return !non_witness_utxo && witness_utxo.IsNull() && partial_sigs.empty() && unknown.empty() && hd_keypaths.empty() && redeem_script.empty() && witness_script.empty(); +} + +bool PSBTOutput::IsNull() const +{ + return redeem_script.empty() && witness_script.empty() && hd_keypaths.empty() && unknown.empty(); +} diff --git a/src/script/sign.h b/src/script/sign.h index 3666859641b..d1cf918610d 100644 --- a/src/script/sign.h +++ b/src/script/sign.h @@ -6,7 +6,11 @@ #ifndef BITCOIN_SCRIPT_SIGN_H #define BITCOIN_SCRIPT_SIGN_H +#include +#include +#include #include