Create class hierarchy for SproutNotePlaintext.
BaseNotePlaintext contains member variable for common attribute, value.
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user