diff --git a/src/gtest/test_joinsplit.cpp b/src/gtest/test_joinsplit.cpp index e89a7206f..dfde47c69 100644 --- a/src/gtest/test_joinsplit.cpp +++ b/src/gtest/test_joinsplit.cpp @@ -548,7 +548,7 @@ TEST(joinsplit, note_plaintexts) ASSERT_TRUE(decrypted_note.r == note.r); ASSERT_TRUE(decrypted_note.value() == note.value()); - ASSERT_TRUE(decrypted.memo == note_pt.memo); + ASSERT_TRUE(decrypted.memo() == note_pt.memo()); // Check serialization of note plaintext CDataStream ss(SER_DISK, PROTOCOL_VERSION); @@ -557,7 +557,7 @@ TEST(joinsplit, note_plaintexts) ss >> note_pt2; ASSERT_EQ(note_pt.value(), note.value()); ASSERT_EQ(note_pt.value(), note_pt2.value()); - ASSERT_EQ(note_pt.memo, note_pt2.memo); + ASSERT_EQ(note_pt.memo(), note_pt2.memo()); ASSERT_EQ(note_pt.rho, note_pt2.rho); ASSERT_EQ(note_pt.r, note_pt2.r); } diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index 4fc6708bc..567fb7248 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -885,7 +885,7 @@ bool AsyncRPCOperation_sendmany::find_unspent_notes() { for (CSproutNotePlaintextEntry & entry : entries) { z_inputs_.push_back(SendManyInputJSOP(entry.jsop, entry.plaintext.note(frompaymentaddress_), CAmount(entry.plaintext.value()))); - std::string data(entry.plaintext.memo.begin(), entry.plaintext.memo.end()); + std::string data(entry.plaintext.memo().begin(), entry.plaintext.memo().end()); LogPrint("zrpcunsafe", "%s: found unspent note (txid=%s, vjoinsplit=%d, ciphertext=%d, amount=%s, memo=%s)\n", getId(), entry.jsop.hash.ToString().substr(0, 10), diff --git a/src/wallet/rpcdisclosure.cpp b/src/wallet/rpcdisclosure.cpp index e9644be44..d4f87ab39 100644 --- a/src/wallet/rpcdisclosure.cpp +++ b/src/wallet/rpcdisclosure.cpp @@ -277,7 +277,7 @@ UniValue z_validatepaymentdisclosure(const UniValue& params, bool fHelp) SproutNotePlaintext npt; ssPlain >> npt; - string memoHexString = HexStr(npt.memo.data(), npt.memo.data() + npt.memo.size()); + string memoHexString = HexStr(npt.memo().data(), npt.memo().data() + npt.memo().size()); o.push_back(Pair("memo", memoHexString)); o.push_back(Pair("value", ValueFromAmount(npt.value()))); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 7c7021732..3a670e8a7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2550,7 +2550,7 @@ UniValue z_listunspent(const UniValue& params, bool fHelp) obj.push_back(Pair("spendable", pwalletMain->HaveSpendingKey(entry.address))); obj.push_back(Pair("address", CZCPaymentAddress(entry.address).ToString())); obj.push_back(Pair("amount", ValueFromAmount(CAmount(entry.plaintext.value())))); - std::string data(entry.plaintext.memo.begin(), entry.plaintext.memo.end()); + std::string data(entry.plaintext.memo().begin(), entry.plaintext.memo().end()); obj.push_back(Pair("memo", HexStr(data))); results.push_back(obj); } @@ -3241,7 +3241,7 @@ UniValue z_listreceivedbyaddress(const UniValue& params, bool fHelp) UniValue obj(UniValue::VOBJ); obj.push_back(Pair("txid",entry.jsop.hash.ToString())); obj.push_back(Pair("amount", ValueFromAmount(CAmount(entry.plaintext.value())))); - std::string data(entry.plaintext.memo.begin(), entry.plaintext.memo.end()); + std::string data(entry.plaintext.memo().begin(), entry.plaintext.memo().end()); obj.push_back(Pair("memo", HexStr(data))); // (txid, jsindex, jsoutindex) is needed to globally identify a note obj.push_back(Pair("jsindex", entry.jsop.js)); diff --git a/src/zcash/Note.cpp b/src/zcash/Note.cpp index 6dc82be4c..407925e15 100644 --- a/src/zcash/Note.cpp +++ b/src/zcash/Note.cpp @@ -40,9 +40,8 @@ uint256 SproutNote::nullifier(const SpendingKey& a_sk) const { SproutNotePlaintext::SproutNotePlaintext( const SproutNote& note, - boost::array memo) : memo(memo) + boost::array memo) : BaseNotePlaintext(note, memo) { - value_ = note.value(); rho = note.rho; r = note.r; } diff --git a/src/zcash/Note.hpp b/src/zcash/Note.hpp index 481db5e4b..8254717bb 100644 --- a/src/zcash/Note.hpp +++ b/src/zcash/Note.hpp @@ -41,18 +41,21 @@ public: class BaseNotePlaintext { protected: uint64_t value_ = 0; + boost::array memo_; public: BaseNotePlaintext() {} + BaseNotePlaintext(const BaseNote& note, boost::array memo) + : value_(note.value()), memo_(memo) {} virtual ~BaseNotePlaintext() {} inline uint64_t value() const { return value_; } + inline boost::array memo() const { return memo_; } }; class SproutNotePlaintext : public BaseNotePlaintext { public: uint256 rho; uint256 r; - boost::array memo; SproutNotePlaintext() {} @@ -76,7 +79,7 @@ public: READWRITE(value_); READWRITE(rho); READWRITE(r); - READWRITE(memo); + READWRITE(memo_); } static SproutNotePlaintext decrypt(const ZCNoteDecryption& decryptor,