Skip to content

Commit 70e2fd0

Browse files
committed
Add paginated payment listing API
Return payment history in reverse creation order one page at a time. Keep ordering metadata in memory, support opaque tokens in language bindings, and deprecate the unpaginated filtering API. This commit was created with assistance from OpenAI Codex.
1 parent 08efb3a commit 70e2fd0

12 files changed

Lines changed: 593 additions & 132 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
succeeds, allowing restored wallets to rediscover funds sent to previously-unknown addresses.
2121
- `Config::anchor_channels_config` is no longer optional, hence anchor channels can no longer be
2222
disabled. We still negotiate legacy channels if the peer does not support anchor channels.
23+
- `Node::list_payments` now retrieves payments page-by-page, ordered from most recently created to
24+
least recently created, instead of returning all payments at once. This is a breaking API change,
25+
and `Node::list_payments_with_filter` is now deprecated. Invalid pagination tokens return the new
26+
`Error::InvalidPageToken` variant. Generic KV store migrations do not preserve creation-order
27+
metadata and may change the order of existing payments (#959).
2328

2429
## Bug Fixes and Improvements
2530
- Building a fresh node against a Bitcoin Core RPC or REST chain source that fails to return the

bindings/kotlin/ldk-node-jvm/lib/src/test/kotlin/org/lightningdevkit/ldknode/LibraryTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -301,8 +301,9 @@ class LibraryTest {
301301
assert(paymentReceivedEvent is Event.PaymentReceived)
302302
node2.eventHandled()
303303

304-
assert(node1.listPayments().size == 3)
305-
assert(node2.listPayments().size == 2)
304+
assert(node1.listPayments(null).payments.size == 3)
305+
assert(node2.listPayments(null).payments.size == 2)
306+
assert(PageToken("1").toString() == "1")
306307

307308
node2.closeChannel(userChannelId, nodeId1)
308309

bindings/ldk_node.udl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,8 @@ interface Node {
151151
[Throws=NodeError]
152152
void remove_payment([ByRef]PaymentId payment_id);
153153
BalanceDetails list_balances();
154-
sequence<PaymentDetails> list_payments();
154+
[Throws=NodeError]
155+
PaymentDetailsPage list_payments(PageToken? page_token);
155156
sequence<PeerDetails> list_peers();
156157
sequence<ChannelDetails> list_channels();
157158
NetworkGraph network_graph();
@@ -235,6 +236,7 @@ enum NodeError {
235236
"InvalidDateTime",
236237
"InvalidFeeRate",
237238
"InvalidScriptPubKey",
239+
"InvalidPageToken",
238240
"DuplicatePayment",
239241
"UnsupportedCurrency",
240242
"InsufficientFunds",
@@ -277,6 +279,10 @@ enum PaymentFailureReason {
277279

278280
typedef dictionary PaymentDetails;
279281

282+
typedef dictionary PaymentDetailsPage;
283+
284+
typedef interface PageToken;
285+
280286
[Remote]
281287
dictionary RouteParametersConfig {
282288
u64? max_total_routing_fee_msat;

0 commit comments

Comments
 (0)