-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Description
Background
Payments and Invoices have standard controls for pagination that enable you to specify how many items to receive and what index to start from. Transactions have a different set of pagination controls that enable you to specify a start height and end height.
This makes it challenging to build a UI that has decent pagination of all core activity types (transactions, invoices and payments) since the mechanism to fetch the data varies depending on what data type is being fetched.
For Payments and Invoices I can easily fetch a certain 100 items. But for Transactions there is no way for me to fetch a certain block of 100 items - I don't know wether blocks X through Y contain any transactions at all, so finding the last 100 transactions can only be done through a process of trial and error.
The best I can do with the current api is to choose a particular start and end height to fetch transactions between and then count how many were fetched. If there were less than 100 then try fetching some more. Or, if there were more than 100, truncate the result. With an approach like this, I might need to make thousands of calls to GetTransactions just to find the last 100 transactions since I'd effectively have to keep calling GetTransactions with a lower and lower start and end height all the way back until the start of time.
Your environment
- version of
lnd
: 0.11 - which operating system (
uname -a
on *Nix): all - version of
btcd
,bitcoind
, or other backend: any - any other relevant environment details
Steps to reproduce
Try building a paginator that pages through transactions in batches of 100.
Expected behaviour
I should be able to specifically ask for 100 transactions form a given offset.
Actual behaviour
I have to do a process of trial and error in order to fetch only the last 100 transactions, or transactions 100-200 etc.