From 00ed92343d883f8a68b9271174f08d85dac1001a Mon Sep 17 00:00:00 2001 From: Eirik Ogilvie-Wigley Date: Tue, 17 Jul 2018 11:47:08 -0600 Subject: [PATCH] Add out point for sapling note data --- src/primitives/transaction.cpp | 5 +++++ src/primitives/transaction.h | 30 +++++++++++++++++++++++------- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/src/primitives/transaction.cpp b/src/primitives/transaction.cpp index a93364220..79adf290e 100644 --- a/src/primitives/transaction.cpp +++ b/src/primitives/transaction.cpp @@ -149,6 +149,11 @@ std::string COutPoint::ToString() const return strprintf("COutPoint(%s, %u)", hash.ToString().substr(0,10), n); } +std::string SaplingOutPoint::ToString() const +{ + return strprintf("SaplingOutPoint(%s, %u)", hash.ToString().substr(0, 10), n); +} + CTxIn::CTxIn(COutPoint prevoutIn, CScript scriptSigIn, uint32_t nSequenceIn) { prevout = prevoutIn; diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 4295dea9f..6ce15a94b 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -309,15 +309,14 @@ public: } }; -/** An outpoint - a combination of a transaction hash and an index n into its vout */ -class COutPoint +class BaseOutPoint { public: uint256 hash; uint32_t n; - COutPoint() { SetNull(); } - COutPoint(uint256 hashIn, uint32_t nIn) { hash = hashIn; n = nIn; } + BaseOutPoint() { SetNull(); } + BaseOutPoint(uint256 hashIn, uint32_t nIn) { hash = hashIn; n = nIn; } ADD_SERIALIZE_METHODS; @@ -330,21 +329,38 @@ public: void SetNull() { hash.SetNull(); n = (uint32_t) -1; } bool IsNull() const { return (hash.IsNull() && n == (uint32_t) -1); } - friend bool operator<(const COutPoint& a, const COutPoint& b) + friend bool operator<(const BaseOutPoint& a, const BaseOutPoint& b) { return (a.hash < b.hash || (a.hash == b.hash && a.n < b.n)); } - friend bool operator==(const COutPoint& a, const COutPoint& b) + friend bool operator==(const BaseOutPoint& a, const BaseOutPoint& b) { return (a.hash == b.hash && a.n == b.n); } - friend bool operator!=(const COutPoint& a, const COutPoint& b) + friend bool operator!=(const BaseOutPoint& a, const BaseOutPoint& b) { return !(a == b); } +}; +/** An outpoint - a combination of a transaction hash and an index n into its vout */ +class COutPoint : public BaseOutPoint +{ +public: + COutPoint() : BaseOutPoint() {}; + COutPoint(uint256 hashIn, uint32_t nIn) : BaseOutPoint(hashIn, nIn) {}; + std::string ToString() const; +}; + +/** An outpoint - a combination of a transaction hash and an index n into its sapling + * output description (vShieldedOutput) */ +class SaplingOutPoint : public BaseOutPoint +{ +public: + SaplingOutPoint() : BaseOutPoint() {}; + SaplingOutPoint(uint256 hashIn, uint32_t nIn) : BaseOutPoint(hashIn, nIn) {}; std::string ToString() const; };