Browse Source

Implemented z_listaddresses to return all the zaddr in the wallet.

pull/4/head
Simon 8 years ago
parent
commit
e709997ff2
  1. 1
      src/rpcserver.cpp
  2. 1
      src/rpcserver.h
  3. 32
      src/wallet/rpcwallet.cpp

1
src/rpcserver.cpp

@ -383,6 +383,7 @@ static const CRPCCommand vRPCCommands[] =
{ "wallet", "zcrawreceive", &zc_raw_receive, true },
{ "wallet", "zcsamplejoinsplit", &zc_sample_joinsplit, true },
{ "wallet", "z_getnewaddress", &z_getnewaddress, true },
{ "wallet", "z_listaddresses", &z_listaddresses, true },
{ "wallet", "z_exportkey", &z_exportkey, true },
{ "wallet", "z_importkey", &z_importkey, true },
{ "wallet", "z_exportwallet", &z_exportwallet, true },

1
src/rpcserver.h

@ -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_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_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_importwallet(const json_spirit::Array& params, bool fHelp); // in rpcdump.cpp

32
src/wallet/rpcwallet.cpp

@ -2795,3 +2795,35 @@ Value z_getnewaddress(const Array& params, bool fHelp)
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;
}

Loading…
Cancel
Save