-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide ability to paginate transactions similar to invoices and payments #4719
Comments
Need this, very hard to display transactions alongside invoices and payments, as transactions do not support pagination, and transactions use block height for filter instead of dates. |
This is important also to avoid timeout issues, although the workaround of block heights could help? Maybe there is also a documentation aspect to this on how to use block heights most efficiently when normal paging isn't available @saubyk |
I will be working on addressing this issue |
I have researched this issue, including how pagination controls were implemented in the I have a question: would it be necessary to open a pull request in |
Hi @Abdulkbk you're correct that in order to make this efficient for transactions, we'd need to modify |
Do you mean I should be able to use a database cursor to handle this without necessarily making any changes to |
So you can use the database interface used in btcwallet to obtain a database cursor. |
I added a PR #8998 addressing this, in case anyone wants to review :) |
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
lnd
: 0.11uname -a
on *Nix): allbtcd
,bitcoind
, or other backend: anySteps 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.
The text was updated successfully, but these errors were encountered: