ergoplatform / ergoplatform/ergo

Blockchain API: Endpoint to get changes of unspent boxes for an address

Open
#2,000 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Scala
Stars
520
Forks
201
Avg merge
3d 21h
Merged PRs (30d)
9

Description

**Motivation**
Right now, lightweight clients can fetch unspent boxes for an address by using the blockchain API. For different reasons, it would be beneficial if the set of unspent boxes is stored on client-side: Information about boxes wouldn't need to be fetched every time it is needed, users could get warnings for old boxes or too many boxes, clients could implement better strategies to choose boxes to spent.
However, since addresses can have a lot of unspent boxes, it is not reasonable to fetch the complete set of unspent boxes each time a user wants to refresh (which can be every minute if the user is waiting for an incoming transaction). Instead, an endpoint returning the set of changes since a block height is needed.

**Endpoint description**
The endpoint should be designed as follows:

POST
Parameters:
Address - body
sinceHeight - query

The returned json should be like follows:
```
{
newBoxes: [List of Boxes],
spentBoxes: [List of IDs]
}
```

For spent boxes, the list of IDs spent since height "sinceHeight" is enough for clients to know. The exact box information is not needed.
New boxes should list the new boxes included in blockchain since "sinceHeight", but not spent yet. The list should have the same format as the `/blockchain/box/unspent/byAddress` endpoint. It is important that the inclusionHeight is used as a comparison, not the creationHeight which can be misleading.

Hint:
Calling this endpoint with sinceHeight 0 will always give the complete list of unspent boxes and an empty list of spent boxes.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.