From 84eb65c7bb485e82a5370117eb2abfdd4ce32a4e Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Wed, 21 Oct 2020 15:52:43 +0200 Subject: [PATCH] add memo as hex and str to z_listreceivedaddress --- src/wallet/rpchushwallet.cpp | 11 +++++++++++ src/wallet/rpcwallet.cpp | 2 ++ 2 files changed, 13 insertions(+) diff --git a/src/wallet/rpchushwallet.cpp b/src/wallet/rpchushwallet.cpp index 41f9ecf35..064a28cb7 100644 --- a/src/wallet/rpchushwallet.cpp +++ b/src/wallet/rpchushwallet.cpp @@ -202,8 +202,19 @@ void zsTxReceivedToJSON(const CWalletTx& wtx, UniValue& received, CAmount& total if (pt) { auto note = pt.get(); + auto pt_unwrapped = pt.get(); + auto memo = pt_unwrapped.memo(); obj.push_back(Pair("address",EncodePaymentAddress(addr))); obj.push_back(Pair("amount", ValueFromAmount(CAmount(note.value())))); + obj.push_back(Pair("memo", HexStr(memo))); + + if (memo[0] <= 0xf4) { + auto end = std::find_if(memo.rbegin(), memo.rend(), [](unsigned char v) { return v != 0; }); + std::string memoStr(memo.begin(), end.base()); + if (utf8::is_valid(memoStr)) { + obj.push_back(Pair("memoStr", memoStr)); + } + } obj.push_back(Pair("shieldedOutputIndex",i)); //Check Change Status diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index ca6b54ffe..f98abe2a1 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3401,6 +3401,8 @@ UniValue z_listreceivedaddress(const UniValue& params, bool fHelp,const CPubKey& " \"saplingReceived\": [{ An Array of utxos/notes received for sapling addresses\n" " \"address\": \"zeroaddress\", (string) Shielded address (z-address)\n" " \"amount\": x.xxxx, (numeric) Value of output being received " + CURRENCY_UNIT + ", positive for receives\n" + " \"memo\": xxxxx, (string) hexademical string representation of memo field\n" + " \"memoStr\" : \"memo\", (string) Only returned if memo contains valid UTF-8 text.\n" " \"sheildedOutputIndex\": n, (numeric) The index of the ShieledOutput\n" " \"change\": true/false (string) The note is change. This can result from sending funds\n" " to the same address they came from, or incomplete useage\n"