getumbrel / umbrel-middleware

RESTful Bitcoin and Lightning API for Umbrel
MIT License
21 stars 11 forks source link

Paginated blocks (array) endpoint #16

Closed mayankchhabra closed 4 years ago

mayankchhabra commented 4 years ago

Issue Fetching new blocks on the dashboard is currently very taxing. It first needs to fetch the block height, then fetch the corresponding block hash, then the block info, and then keep doing it for block height - 1 until the required number of blocks are fetched. This is ok for a small number of blocks, but far from optimal for a large number of blocks.

Solution A new endpoint that takes in a "from block height" and "to block height" parameter and returns the array of blocks.

GET v1/bitcoind/info/blocks?from=<from block height>&to=<to block height>

Result:

[...blocks]