diff --git a/src/rpc/server.cpp b/src/rpc/server.cpp index 6373d554d..a16dde687 100644 --- a/src/rpc/server.cpp +++ b/src/rpc/server.cpp @@ -460,6 +460,7 @@ static const CRPCCommand vRPCCommands[] = { "wallet", "walletlock", &walletlock, true }, { "wallet", "walletpassphrasechange", &walletpassphrasechange, true }, { "wallet", "walletpassphrase", &walletpassphrase, true }, + { "wallet", "z_listlockunspent", &z_listlockunspent, false }, { "wallet", "z_listreceivedbyaddress",&z_listreceivedbyaddress,false }, { "wallet", "z_listreceivedaddress", &z_listreceivedaddress, false }, { "wallet", "z_getbalance", &z_getbalance, false }, diff --git a/src/rpc/server.h b/src/rpc/server.h index 9a66fea43..eff98f9c2 100644 --- a/src/rpc/server.h +++ b/src/rpc/server.h @@ -295,6 +295,7 @@ extern UniValue getrawtransaction(const UniValue& params, bool fHelp, const CPub extern UniValue listunspent(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue lockunspent(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue listlockunspent(const UniValue& params, bool fHelp, const CPubKey& mypk); +extern UniValue z_listlockunspent(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue createrawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue decoderawtransaction(const UniValue& params, bool fHelp, const CPubKey& mypk); extern UniValue decodescript(const UniValue& params, bool fHelp, const CPubKey& mypk); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index f6583bd17..e1ff70cfd 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -2645,6 +2645,45 @@ UniValue lockunspent(const UniValue& params, bool fHelp, const CPubKey& mypk) return true; } +UniValue z_listlockunspent(const UniValue& params, bool fHelp, const CPubKey& mypk) +{ + if (!EnsureWalletIsAvailable(fHelp)) + return NullUniValue; + + if (fHelp || params.size() > 0) + throw runtime_error( + "z_listlockunspent\n" + "\nReturns list of temporarily unspendable outputs.\n" + "\nResult:\n" + "[\n" + " {\n" + " \"txid\" : \"transactionid\", (string) The transaction id locked\n" + " \"vout\" : n (numeric) The vout value\n" + " }\n" + " ,...\n" + "]\n" + "\nExamples:\n" + "\nList the locked Sapling notes\n" + + HelpExampleCli("z_listlockunspent", "") + + "\nAs a json rpc call\n" + + HelpExampleRpc("z_listlockunspent", "") + ); + + LOCK2(cs_main, pwalletMain->cs_wallet); + vector ops = pwalletMain->ListLockedSaplingNotes(); + + UniValue ret(UniValue::VARR); + + BOOST_FOREACH(SaplingOutPoint &op, ops) { + UniValue o(UniValue::VOBJ); + + o.push_back(Pair("txid", op.hash.GetHex())); + ret.push_back(o); + } + + return ret; +} + UniValue listlockunspent(const UniValue& params, bool fHelp, const CPubKey& mypk) { if (!EnsureWalletIsAvailable(fHelp))