From e55a089bb7073a23830c893f474605f1656b1d08 Mon Sep 17 00:00:00 2001 From: random-zebra Date: Thu, 10 Dec 2020 01:32:55 +0100 Subject: [PATCH 1/2] [RPC] Add nullifiers to listshieldedunspent output --- src/wallet/rpcwallet.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index dc515daafd58..a1a99f703788 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -552,6 +552,7 @@ UniValue listshieldedunspent(const JSONRPCRequest& request) " \"amount\": xxxxx, (numeric) the amount of value in the note\n" " \"memo\": xxxxx, (string) hexademical string representation of memo field\n" " \"change\": true|false, (boolean) true if the address that received the note is also one of the sending addresses\n" + " \"nullifier\": xxxxx, (string) the note's nullifier, hex encoded" " }\n" " ,...\n" "]\n" @@ -639,6 +640,10 @@ UniValue listshieldedunspent(const JSONRPCRequest& request) if (hasSaplingSpendingKey) { obj.pushKV("change", pwalletMain->GetSaplingScriptPubKeyMan()->IsNoteSaplingChange(nullifierSet, entry.address, entry.op)); } + const auto& nd = pwalletMain->mapWallet.at(entry.op.hash).mapSaplingNoteData.at(entry.op); + if (nd.nullifier) { + obj.pushKV("nullifier", nd.nullifier->ToString()); + } results.push_back(obj); } } From e4896771f415254b38bf93529641de77ccacc77b Mon Sep 17 00:00:00 2001 From: random-zebra Date: Thu, 10 Dec 2020 01:42:17 +0100 Subject: [PATCH 2/2] [Tests] Check spent nullifier in sapling_wallet_listreceived --- test/functional/sapling_wallet_listreceived.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/functional/sapling_wallet_listreceived.py b/test/functional/sapling_wallet_listreceived.py index 0f5e3121e68b..afcf6ff97714 100755 --- a/test/functional/sapling_wallet_listreceived.py +++ b/test/functional/sapling_wallet_listreceived.py @@ -120,6 +120,11 @@ def run_test(self): # Now can check that the information is the same assert_equal(r, r2) + # Get the note nullifier + lsu = self.nodes[1].listshieldedunspent(); + assert_equal(len(lsu), 1) + nullifier = lsu[0]["nullifier"] + # Generate some change by sending part of shield_addr1 to shield_addr2 txidPrev = txid shield_addr2 = self.nodes[1].getnewshieldedaddress() @@ -129,6 +134,10 @@ def run_test(self): self.sync_all() self.generate_and_sync(height+4) + # Verify the spent nullifier + tx_json = self.nodes[1].getrawtransaction(txid, True) + assert_equal(nullifier, tx_json["vShieldedSpend"][0]["nullifier"]) + # Decrypted transaction details should be correct pt = self.nodes[1].viewshieldedtransaction(txid) assert_equal(pt['txid'], txid)