Implemented z_listaddresses to return all the zaddr in the wallet.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user