Implemented z_listaddresses to return all the zaddr in the wallet.
This commit is contained in:
@@ -383,6 +383,7 @@ static const CRPCCommand vRPCCommands[] =
|
|||||||
{ "wallet", "zcrawreceive", &zc_raw_receive, true },
|
{ "wallet", "zcrawreceive", &zc_raw_receive, true },
|
||||||
{ "wallet", "zcsamplejoinsplit", &zc_sample_joinsplit, true },
|
{ "wallet", "zcsamplejoinsplit", &zc_sample_joinsplit, true },
|
||||||
{ "wallet", "z_getnewaddress", &z_getnewaddress, true },
|
{ "wallet", "z_getnewaddress", &z_getnewaddress, true },
|
||||||
|
{ "wallet", "z_listaddresses", &z_listaddresses, true },
|
||||||
{ "wallet", "z_exportkey", &z_exportkey, true },
|
{ "wallet", "z_exportkey", &z_exportkey, true },
|
||||||
{ "wallet", "z_importkey", &z_importkey, true },
|
{ "wallet", "z_importkey", &z_importkey, true },
|
||||||
{ "wallet", "z_exportwallet", &z_exportwallet, true },
|
{ "wallet", "z_exportwallet", &z_exportwallet, true },
|
||||||
|
|||||||
@@ -246,6 +246,7 @@ extern json_spirit::Value getblocksubsidy(const json_spirit::Array& params, bool
|
|||||||
extern json_spirit::Value z_exportkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp
|
extern json_spirit::Value z_exportkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp
|
||||||
extern json_spirit::Value z_importkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp
|
extern json_spirit::Value z_importkey(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp
|
||||||
extern json_spirit::Value z_getnewaddress(const json_spirit::Array& params, bool fHelp); // in rpcwallet.cpp
|
extern json_spirit::Value z_getnewaddress(const json_spirit::Array& params, bool fHelp); // in rpcwallet.cpp
|
||||||
|
extern json_spirit::Value z_listaddresses(const json_spirit::Array& params, bool fHelp); // in rpcwallet.cpp
|
||||||
extern json_spirit::Value z_exportwallet(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp
|
extern json_spirit::Value z_exportwallet(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp
|
||||||
extern json_spirit::Value z_importwallet(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp
|
extern json_spirit::Value z_importwallet(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp
|
||||||
|
|
||||||
|
|||||||
@@ -2795,3 +2795,35 @@ Value z_getnewaddress(const Array& params, bool fHelp)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Value z_listaddresses(const Array& params, bool fHelp)
|
||||||
|
{
|
||||||
|
if (!EnsureWalletIsAvailable(fHelp))
|
||||||
|
return Value::null;
|
||||||
|
|
||||||
|
if (fHelp || params.size() > 1)
|
||||||
|
throw runtime_error(
|
||||||
|
"z_listaddresses\n"
|
||||||
|
"\nReturns the list of zaddr belonging to the wallet.\n"
|
||||||
|
"\nArguments:\n"
|
||||||
|
"\nResult:\n"
|
||||||
|
"[ (json array of string)\n"
|
||||||
|
" \"zaddr\" (string) a zaddr belonging to the wallet\n"
|
||||||
|
" ,...\n"
|
||||||
|
"]\n"
|
||||||
|
"\nExamples:\n"
|
||||||
|
+ HelpExampleCli("z_listaddresses", "")
|
||||||
|
+ HelpExampleRpc("z_listaddresses", "")
|
||||||
|
);
|
||||||
|
|
||||||
|
LOCK2(cs_main, pwalletMain->cs_wallet);
|
||||||
|
|
||||||
|
Array ret;
|
||||||
|
std::set<libzcash::PaymentAddress> addresses;
|
||||||
|
pwalletMain->GetPaymentAddresses(addresses);
|
||||||
|
for (auto addr : addresses ) {
|
||||||
|
ret.push_back(CZCPaymentAddress(addr).ToString());
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user