Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create generic getunclaimedgas and rename wallet ones #243

Merged
merged 2 commits into from
May 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/RpcServer/RpcServer.SmartContract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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;
}
vncoelho marked this conversation as resolved.
Show resolved Hide resolved
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();
vncoelho marked this conversation as resolved.
Show resolved Hide resolved
json["address"] = script_hash.ToAddress();
return json;
}
}
}
4 changes: 2 additions & 2 deletions src/RpcServer/RpcServer.Wallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand All @@ -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;
Expand Down