Create class hierarchy for SproutNotePlaintext.

BaseNotePlaintext contains member variable for common attribute, value.
This commit is contained in:
Simon
2018-04-26 14:05:36 -07:00
parent 5020a93631
commit d266f40393
7 changed files with 41 additions and 16 deletions

View File

@@ -42,14 +42,14 @@ SproutNotePlaintext::SproutNotePlaintext(
const SproutNote& note,
boost::array<unsigned char, ZC_MEMO_SIZE> memo) : memo(memo)
{
value = note.value();
value_ = note.value();
rho = note.rho;
r = note.r;
}
SproutNote SproutNotePlaintext::note(const PaymentAddress& addr) const
{
return SproutNote(addr.a_pk, value, rho, r);
return SproutNote(addr.a_pk, value_, rho, r);
}
SproutNotePlaintext SproutNotePlaintext::decrypt(const ZCNoteDecryption& decryptor,

View File

@@ -38,9 +38,18 @@ public:
uint256 nullifier(const SpendingKey& a_sk) const;
};
class SproutNotePlaintext {
class BaseNotePlaintext {
protected:
uint64_t value_ = 0;
public:
BaseNotePlaintext() {}
virtual ~BaseNotePlaintext() {}
inline uint64_t value() const { return value_; }
};
class SproutNotePlaintext : public BaseNotePlaintext {
public:
uint64_t value = 0;
uint256 rho;
uint256 r;
boost::array<unsigned char, ZC_MEMO_SIZE> memo;
@@ -51,6 +60,8 @@ public:
SproutNote note(const PaymentAddress& addr) const;
virtual ~SproutNotePlaintext() {}
ADD_SERIALIZE_METHODS;
template <typename Stream, typename Operation>
@@ -62,7 +73,7 @@ public:
throw std::ios_base::failure("lead byte of SproutNotePlaintext is not recognized");
}
READWRITE(value);
READWRITE(value_);
READWRITE(rho);
READWRITE(r);
READWRITE(memo);