From 5078839d69fd61842984509d425f27b1a8153915 Mon Sep 17 00:00:00 2001 From: Erik Zhang Date: Fri, 26 Jan 2018 14:55:00 +0800 Subject: [PATCH] add RPC command `listaddress` (#103) --- neo-cli/Network/RPC/RpcServerWithWallet.cs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/neo-cli/Network/RPC/RpcServerWithWallet.cs b/neo-cli/Network/RPC/RpcServerWithWallet.cs index f95a14786..e6a2de9b6 100644 --- a/neo-cli/Network/RPC/RpcServerWithWallet.cs +++ b/neo-cli/Network/RPC/RpcServerWithWallet.cs @@ -41,6 +41,19 @@ protected override JObject Process(string method, JArray _params) json["confirmed"] = coins.Where(p => p.State.HasFlag(CoinState.Confirmed)).Sum(p => p.Output.Value).ToString(); return json; } + case "listaddress": + if (Program.Wallet == null) + throw new RpcException(-400, "Access denied."); + else + return Program.Wallet.GetAccounts().Select(p => + { + JObject account = new JObject(); + account["address"] = p.Address; + account["haskey"] = p.HasKey; + account["label"] = p.Label; + account["watchonly"] = p.WatchOnly; + return account; + }).ToArray(); case "sendfrom": if (Program.Wallet == null) throw new RpcException(-400, "Access denied");