Skip to content

Commit

Permalink
Add get_address_history rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
fireduck64 committed Nov 26, 2020
1 parent 4beebf0 commit c4170e8
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 4 deletions.
12 changes: 8 additions & 4 deletions RELEASE-NOTES.md
@@ -1,13 +1,17 @@
## 1.7.1
## dev

* Added History panel to iceleaf GUI
* Added SubscribeAddressUpdates gRPC api to node to monitor addresses
* Added MonitorTool to use SubscribeAddressUpdates to monitor addresses
* Update seed nodes
* Add remote address to Shackleton explorer logs
* Switch Shackleton web handling over to new web framework
* Added explorer APIs zone and /api/total_coins
* Lower max history replies
* Add get_address_history rpc

## 1.7.1

* Added History panel to iceleaf GUI
* Added SubscribeAddressUpdates gRPC api to node to monitor addresses
* Added MonitorTool to use SubscribeAddressUpdates to monitor addresses

## 1.7.0

Expand Down
57 changes: 57 additions & 0 deletions client/src/RpcServerHandler.java
Expand Up @@ -39,6 +39,7 @@ public void registerHandlers(JsonRpcServer json_server)
json_server.register(new GetBlockHandler());
json_server.register(new GetXpubAddressHandler());
json_server.register(new GetAddressBalanceHandler());
json_server.register(new GetAddressHistoryHandler());
json_server.register(new GetFBOListHandler());
json_server.register(new GetIDListHandler());

Expand Down Expand Up @@ -237,6 +238,62 @@ protected JSONObject processRequest(JSONRPC2Request req, MessageContext ctx)

}

public class GetAddressHistoryHandler extends JsonRequestHandler
{
public String[] handledRequests()
{
return new String[]{"get_address_history"};
}

@Override
protected JSONObject processRequest(JSONRPC2Request req, MessageContext ctx)
throws Exception
{
String address = RpcUtil.requireString(req, "address");
AddressSpecHash hash = new AddressSpecHash(address, client.getParams());
JSONObject reply = new JSONObject();

HistoryList hl = client.getStub().getAddressHistory(
RequestAddress.newBuilder().setAddressSpecHash(hash.getBytes()).build());

JSONArray tx_list = new JSONArray();

for(HistoryEntry he : hl.getEntriesList())
{
JSONObject e = new JSONObject();

ByteString tx_hash = he.getTxHash();

e.put("tx_hash", new ChainHash(tx_hash).toString());
e.put("block_height", he.getBlockHeight());

tx_list.add(e);

}

TransactionHashList ml = client.getStub().getMempoolTransactionList(
RequestAddress.newBuilder().setAddressSpecHash(hash.getBytes()).build());

for(ByteString tx_hash : ml.getTxHashesList())
{
JSONObject e = new JSONObject();

e.put("tx_hash", new ChainHash(tx_hash).toString());
e.put("mempool", true);

tx_list.add(e);


}

reply.put("tx_list", tx_list);

return reply;
}

}



public class GetXpubAddressHandler extends JsonRequestHandler
{
Expand Down

0 comments on commit c4170e8

Please sign in to comment.