lnrpc+lncli: add reverse ordering to GetTransactions - #11126
Conversation
5b52321 to
5201cb4
Compare
🔴 PR Severity: CRITICAL
🔴 Critical (1 file)
🟠 High (3 files)
🟡 Medium (3 files)
🟢 Low (2 files)
AnalysisThis PR adds a However, the change touches To override, add a |
GetTransactions (and lncli listchaintxns) always returned transactions newest first, with no way to reverse the order. RPCTransactionDetails sorts the results by number of confirmations, which overrides the ordering produced by the wallet, so callers could not obtain an oldest-to-newest listing. Add a reverse field to GetTransactionsRequest. When set, the sort is flipped so transactions are returned from oldest to newest (ascending block height), with unconfirmed transactions last. The field defaults to false, so existing callers keep the newest-first behaviour. Fixes lightningnetwork#7316.
Expose the new GetTransactions reverse field through a --reverse flag on the listchaintxns command.
5201cb4 to
94b423b
Compare
Adds a
reversefield toGetTransactionsRequestand a--reverseflag tolncli listchaintxns, so transactions can be listed oldest first. Fixes #7316.Root cause
The wallet does not set the response order.
RPCTransactionDetails(lnrpc/rpc_utils.go) re-sorts by confirmation count, so results are always newest first regardless of howstart_height/end_heightare ordered. #9558 also rejectsstart_height > end_heightat the CLI, so the old swap-the-heights trick is gone. Reversing the slice in the wallet layer does nothing, because this sort runs after it, so the flag goes into the sort.Behaviour
reverseunset: unchanged, newest first.reverseset: oldest to newest, unconfirmed last.Pagination
index_offset/max_transactionsare applied in the wallet layer before this sort, so--reversesets display order, not which page you get. That split predates this change and is out of scope.Testing
TestRPCTransactionDetailsReversecovers both orderings and unconfirmed placement.403,402,401,--reversereturns401,402,403.