diff --git a/src/RpcServer/RpcServer.SmartContract.cs b/src/RpcServer/RpcServer.SmartContract.cs index 639288656..d9e2311a8 100644 --- a/src/RpcServer/RpcServer.SmartContract.cs +++ b/src/RpcServer/RpcServer.SmartContract.cs @@ -9,6 +9,10 @@ using System; using System.IO; using System.Linq; +using Neo.IO; +using Neo.Ledger; +using Neo.SmartContract.Native; +using Neo.Wallets; namespace Neo.Plugins { @@ -92,5 +96,27 @@ private JObject InvokeScript(JArray _params) CheckWitnessHashes checkWitnessHashes = _params.Count >= 2 ? new CheckWitnessHashes(((JArray)_params[1]).Select(u => UInt160.Parse(u.AsString())).ToArray()) : null; return GetInvokeResult(script, checkWitnessHashes); } + + [RpcMethod] + private JObject GetUnclaimedGas(JArray _params) + { + string address = _params[0].AsString(); + JObject json = new JObject(); + UInt160 script_hash; + try + { + script_hash = address.ToScriptHash(); + } + catch + { + script_hash = null; + } + if (script_hash == null) + throw new RpcException(-100, "Invalid address"); + SnapshotView snapshot = Blockchain.Singleton.GetSnapshot(); + json["unclaimed"] = NativeContract.NEO.UnclaimedGas(snapshot, script_hash, snapshot.Height + 1).ToString(); + json["address"] = script_hash.ToAddress(); + return json; + } } } diff --git a/src/RpcServer/RpcServer.Wallet.cs b/src/RpcServer/RpcServer.Wallet.cs index 0a47622ef..da087cdf7 100644 --- a/src/RpcServer/RpcServer.Wallet.cs +++ b/src/RpcServer/RpcServer.Wallet.cs @@ -48,7 +48,7 @@ private JObject DumpPrivKey(JArray _params) } [RpcMethod] - private JObject GetBalance(JArray _params) + private JObject GetWalletBalance(JArray _params) { CheckWallet(); UInt160 asset_id = UInt160.Parse(_params[0].AsString()); @@ -68,7 +68,7 @@ private JObject GetNewAddress(JArray _params) } [RpcMethod] - private JObject GetUnclaimedGas(JArray _params) + private JObject GetWalletUnclaimedGas(JArray _params) { CheckWallet(); BigInteger gas = BigInteger.Zero;