Browse Source

Move memo member varible from SproutNotePlaintext to BaseNotePlaintext.

Add memo() accessor to BaseNotePlaintext.
pull/4/head
Simon 6 years ago
parent
commit
debf6af9f8
  1. 4
      src/gtest/test_joinsplit.cpp
  2. 2
      src/wallet/asyncrpcoperation_sendmany.cpp
  3. 2
      src/wallet/rpcdisclosure.cpp
  4. 4
      src/wallet/rpcwallet.cpp
  5. 3
      src/zcash/Note.cpp
  6. 7
      src/zcash/Note.hpp

4
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);
}

2
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),

2
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())));

4
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));

3
src/zcash/Note.cpp

@ -40,9 +40,8 @@ uint256 SproutNote::nullifier(const SpendingKey& a_sk) const {
SproutNotePlaintext::SproutNotePlaintext(
const SproutNote& note,
boost::array<unsigned char, ZC_MEMO_SIZE> memo) : memo(memo)
boost::array<unsigned char, ZC_MEMO_SIZE> memo) : BaseNotePlaintext(note, memo)
{
value_ = note.value();
rho = note.rho;
r = note.r;
}

7
src/zcash/Note.hpp

@ -41,18 +41,21 @@ public:
class BaseNotePlaintext {
protected:
uint64_t value_ = 0;
boost::array<unsigned char, ZC_MEMO_SIZE> memo_;
public:
BaseNotePlaintext() {}
BaseNotePlaintext(const BaseNote& note, boost::array<unsigned char, ZC_MEMO_SIZE> memo)
: value_(note.value()), memo_(memo) {}
virtual ~BaseNotePlaintext() {}
inline uint64_t value() const { return value_; }
inline boost::array<unsigned char, ZC_MEMO_SIZE> memo() const { return memo_; }
};
class SproutNotePlaintext : public BaseNotePlaintext {
public:
uint256 rho;
uint256 r;
boost::array<unsigned char, ZC_MEMO_SIZE> memo;
SproutNotePlaintext() {}
@ -76,7 +79,7 @@ public:
READWRITE(value_);
READWRITE(rho);
READWRITE(r);
READWRITE(memo);
READWRITE(memo_);
}
static SproutNotePlaintext decrypt(const ZCNoteDecryption& decryptor,

Loading…
Cancel
Save