Skip to content

Commit

Permalink
RPC call gettransactionheight (neo-project#541)
Browse files Browse the repository at this point in the history
* getrawtransactionheight

Nowadays two calls are need to get a transaction height, `getrawtransaction` with `verbose` and then use the `blockhash`.
Other option is to use `confirmations`, but it can be misleading.

* Minnor fix

* Shargon's tip

* modified
  • Loading branch information
vncoelho authored and rodoufu committed Mar 3, 2019
1 parent c14fb84 commit ed01f3e
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions neo/Network/RPC/RpcServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,13 @@ private JObject Process(string method, JArray _params)
}) ?? new StorageItem();
return item.Value?.ToHexString();
}
case "gettransactionheight":
{
UInt256 hash = UInt256.Parse(_params[0].AsString());
uint? height = Blockchain.Singleton.Store.GetTransactions().TryGet(hash)?.BlockIndex;
if (height.HasValue) return height.Value;
throw new RpcException(-100, "Unknown transaction");
}
case "gettxout":
{
UInt256 hash = UInt256.Parse(_params[0].AsString());
Expand Down

0 comments on commit ed01f3e

Please sign in to comment.