Skip to content

Commit c49ccbb

Browse files
committed
lightningd: support index/start/end pagination for listhtlcs.
Changelog-Added: JSON-RPC: `listhtlcs` support `index`, `start` and `end` parameters for pagination support. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
1 parent 62666b2 commit c49ccbb

File tree

13 files changed

+318
-89
lines changed

13 files changed

+318
-89
lines changed

.msggen.json

+31-2
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@
221221
"SENT_REMOVE_HTLC": 15,
222222
"SENT_REMOVE_REVOCATION": 7
223223
},
224+
"ListhtlcsIndex": {
225+
"created": 0,
226+
"updated": 1
227+
},
224228
"ListinvoicesIndex": {
225229
"created": 0,
226230
"updated": 1
@@ -2544,15 +2548,20 @@
25442548
},
25452549
"ListhtlcsHtlcs": {
25462550
"ListHtlcs.htlcs[].amount_msat": 4,
2551+
"ListHtlcs.htlcs[].created_index": 8,
25472552
"ListHtlcs.htlcs[].direction": 5,
25482553
"ListHtlcs.htlcs[].expiry": 3,
25492554
"ListHtlcs.htlcs[].id": 2,
25502555
"ListHtlcs.htlcs[].payment_hash": 6,
25512556
"ListHtlcs.htlcs[].short_channel_id": 1,
2552-
"ListHtlcs.htlcs[].state": 7
2557+
"ListHtlcs.htlcs[].state": 7,
2558+
"ListHtlcs.htlcs[].updated_index": 9
25532559
},
25542560
"ListhtlcsRequest": {
2555-
"ListHtlcs.id": 1
2561+
"ListHtlcs.id": 1,
2562+
"ListHtlcs.index": 2,
2563+
"ListHtlcs.limit": 4,
2564+
"ListHtlcs.start": 3
25562565
},
25572566
"ListhtlcsResponse": {
25582567
"ListHtlcs.htlcs[]": 1
@@ -9539,6 +9548,10 @@
95399548
"added": "pre-v0.10.1",
95409549
"deprecated": null
95419550
},
9551+
"ListHtlcs.htlcs[].created_index": {
9552+
"added": "v25.05",
9553+
"deprecated": null
9554+
},
95429555
"ListHtlcs.htlcs[].direction": {
95439556
"added": "pre-v0.10.1",
95449557
"deprecated": null
@@ -9563,10 +9576,26 @@
95639576
"added": "pre-v0.10.1",
95649577
"deprecated": null
95659578
},
9579+
"ListHtlcs.htlcs[].updated_index": {
9580+
"added": "v25.05",
9581+
"deprecated": null
9582+
},
95669583
"ListHtlcs.id": {
95679584
"added": "pre-v0.10.1",
95689585
"deprecated": null
95699586
},
9587+
"ListHtlcs.index": {
9588+
"added": "v25.05",
9589+
"deprecated": null
9590+
},
9591+
"ListHtlcs.limit": {
9592+
"added": "v25.05",
9593+
"deprecated": null
9594+
},
9595+
"ListHtlcs.start": {
9596+
"added": "v25.05",
9597+
"deprecated": null
9598+
},
95709599
"ListInvoiceRequests": {
95719600
"added": "pre-v0.10.1",
95729601
"deprecated": null

cln-grpc/proto/node.proto

+10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-grpc/src/convert.rs

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

cln-rpc/src/model.rs

+40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/msggen/msggen/schema.json

+58-37
Original file line numberDiff line numberDiff line change
@@ -21534,6 +21534,32 @@
2153421534
"description": [
2153521535
"A short channel id (e.g. 1x2x3) or full 64-byte hex channel id, it will only list htlcs for that channel (which must be known)."
2153621536
]
21537+
},
21538+
"index": {
21539+
"type": "string",
21540+
"added": "v25.05",
21541+
"enum": [
21542+
"created",
21543+
"updated"
21544+
],
21545+
"description": [
21546+
"This controls the ordering of results."
21547+
],
21548+
"default": "`created`"
21549+
},
21550+
"start": {
21551+
"type": "u64",
21552+
"added": "v25.05",
21553+
"description": [
21554+
"If `index` is specified, `start` may be specified to start from that value, which is generally returned from lightning-wait(7)."
21555+
]
21556+
},
21557+
"limit": {
21558+
"type": "u32",
21559+
"added": "v25.05",
21560+
"description": [
21561+
"If `index` is specified, `limit` can be used to specify the maximum number of entries to return."
21562+
]
2153721563
}
2153821564
}
2153921565
},
@@ -21549,6 +21575,7 @@
2154921575
"type": "object",
2155021576
"additionalProperties": false,
2155121577
"required": [
21578+
"created_index",
2155221579
"short_channel_id",
2155321580
"id",
2155421581
"expiry",
@@ -21564,6 +21591,20 @@
2156421591
"The channel that contains/contained the HTLC."
2156521592
]
2156621593
},
21594+
"created_index": {
21595+
"added": "v25.05",
21596+
"type": "u64",
21597+
"description": [
21598+
"1-based index indicating order this htlc was created in."
21599+
]
21600+
},
21601+
"updated_index": {
21602+
"added": "v25.05",
21603+
"type": "u64",
21604+
"description": [
21605+
"1-based index indicating order this htlc was changed (only present if it has changed since creation)."
21606+
]
21607+
},
2156721608
"id": {
2156821609
"type": "u64",
2156921610
"description": [
@@ -21652,6 +21693,8 @@
2165221693
"response": {
2165321694
"htlcs": [
2165421695
{
21696+
"created_index": 1,
21697+
"updated_index": 9,
2165521698
"short_channel_id": "109x1x1",
2165621699
"id": 0,
2165721700
"expiry": 126,
@@ -21661,6 +21704,8 @@
2166121704
"state": "RCVD_REMOVE_ACK_REVOCATION"
2166221705
},
2166321706
{
21707+
"created_index": 2,
21708+
"updated_index": 18,
2166421709
"short_channel_id": "109x1x1",
2166521710
"id": 1,
2166621711
"expiry": 136,
@@ -21670,6 +21715,8 @@
2167021715
"state": "RCVD_REMOVE_ACK_REVOCATION"
2167121716
},
2167221717
{
21718+
"created_index": 3,
21719+
"updated_index": 27,
2167321720
"short_channel_id": "109x1x1",
2167421721
"id": 2,
2167521722
"expiry": 149,
@@ -21679,6 +21726,8 @@
2167921726
"state": "RCVD_REMOVE_ACK_REVOCATION"
2168021727
},
2168121728
{
21729+
"created_index": 4,
21730+
"updated_index": 36,
2168221731
"short_channel_id": "109x1x1",
2168321732
"id": 3,
2168421733
"expiry": 155,
@@ -21688,6 +21737,8 @@
2168821737
"state": "RCVD_REMOVE_ACK_REVOCATION"
2168921738
},
2169021739
{
21740+
"created_index": 5,
21741+
"updated_index": 44,
2169121742
"short_channel_id": "109x1x1",
2169221743
"id": 4,
2169321744
"expiry": 152,
@@ -21703,54 +21754,24 @@
2170321754
"request": {
2170421755
"id": "example:listhtlcs#2",
2170521756
"method": "listhtlcs",
21706-
"params": {}
21757+
"params": {
21758+
"index": "created",
21759+
"start": 4,
21760+
"limit": 1
21761+
}
2170721762
},
2170821763
"response": {
2170921764
"htlcs": [
2171021765
{
21711-
"short_channel_id": "109x1x1",
21712-
"id": 0,
21713-
"expiry": 126,
21714-
"direction": "out",
21715-
"amount_msat": 500000000,
21716-
"payment_hash": "paymenthashdelpay10101010101010101010101010101010101010101010101",
21717-
"state": "RCVD_REMOVE_ACK_REVOCATION"
21718-
},
21719-
{
21720-
"short_channel_id": "109x1x1",
21721-
"id": 1,
21722-
"expiry": 136,
21723-
"direction": "out",
21724-
"amount_msat": 10001,
21725-
"payment_hash": "paymenthashinvl0310031003100310031003100310031003100310031003100",
21726-
"state": "RCVD_REMOVE_ACK_REVOCATION"
21727-
},
21728-
{
21729-
"short_channel_id": "109x1x1",
21730-
"id": 2,
21731-
"expiry": 149,
21732-
"direction": "out",
21733-
"amount_msat": 10001,
21734-
"payment_hash": "paymenthashkey01k101k101k101k101k101k101k101k101k101k101k101k101",
21735-
"state": "RCVD_REMOVE_ACK_REVOCATION"
21736-
},
21737-
{
21766+
"created_index": 4,
21767+
"updated_index": 36,
2173821768
"short_channel_id": "109x1x1",
2173921769
"id": 3,
2174021770
"expiry": 155,
2174121771
"direction": "out",
2174221772
"amount_msat": 10000202,
2174321773
"payment_hash": "paymenthashkey02k201k201k201k201k201k201k201k201k201k201k201k201",
2174421774
"state": "RCVD_REMOVE_ACK_REVOCATION"
21745-
},
21746-
{
21747-
"short_channel_id": "109x1x1",
21748-
"id": 4,
21749-
"expiry": 152,
21750-
"direction": "out",
21751-
"amount_msat": 10001,
21752-
"payment_hash": "paymenthashkey03k301k301k301k301k301k301k301k301k301k301k301k301",
21753-
"state": "RCVD_REMOVE_ACK_REVOCATION"
2175421775
}
2175521776
]
2175621777
}

contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

+7-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

contrib/pyln-testing/pyln/testing/grpc2py.py

+2
Original file line numberDiff line numberDiff line change
@@ -1715,10 +1715,12 @@ def listhtlcs_htlcs2py(m):
17151715
"direction": str(m.direction), # EnumField in generate_composite
17161716
"state": str(m.state), # EnumField in generate_composite
17171717
"amount_msat": amount2msat(m.amount_msat), # PrimitiveField in generate_composite
1718+
"created_index": m.created_index, # PrimitiveField in generate_composite
17181719
"expiry": m.expiry, # PrimitiveField in generate_composite
17191720
"id": m.id, # PrimitiveField in generate_composite
17201721
"payment_hash": hexlify(m.payment_hash), # PrimitiveField in generate_composite
17211722
"short_channel_id": m.short_channel_id, # PrimitiveField in generate_composite
1723+
"updated_index": m.updated_index, # PrimitiveField in generate_composite
17221724
})
17231725

17241726

0 commit comments

Comments
 (0)