Skip to content

Commit

Permalink
listforwards: add created_index and updated_index fields.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
Changelog-Added: JSON-RPC: `listforwards` fields `created_index` (old: `id`) and `updated_index`.
  • Loading branch information
rustyrussell committed Oct 23, 2023
1 parent 5cdfbf9 commit 4cb3791
Show file tree
Hide file tree
Showing 15 changed files with 232 additions and 88 deletions.
31 changes: 30 additions & 1 deletion .msggen.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@
"legacy": 0,
"tlv": 1
},
"ListforwardsIndex": {
"created": 0,
"updated": 1
},
"ListforwardsStatus": {
"failed": 3,
"local_failed": 2,
Expand Down Expand Up @@ -909,6 +913,7 @@
"ListDatastore.datastore[]": 1
},
"ListforwardsForwards": {
"ListForwards.forwards[].created_index": 12,
"ListForwards.forwards[].fee_msat": 7,
"ListForwards.forwards[].in_channel": 1,
"ListForwards.forwards[].in_htlc_id": 10,
Expand All @@ -919,11 +924,15 @@
"ListForwards.forwards[].payment_hash": 6,
"ListForwards.forwards[].received_time": 4,
"ListForwards.forwards[].status": 3,
"ListForwards.forwards[].style": 9
"ListForwards.forwards[].style": 9,
"ListForwards.forwards[].updated_index": 13
},
"ListforwardsRequest": {
"ListForwards.in_channel": 2,
"ListForwards.index": 4,
"ListForwards.limit": 6,
"ListForwards.out_channel": 3,
"ListForwards.start": 5,
"ListForwards.status": 1
},
"ListforwardsResponse": {
Expand Down Expand Up @@ -3498,6 +3507,10 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"ListForwards.forwards[].created_index": {
"added": "v23.11",
"deprecated": false
},
"ListForwards.forwards[].fee_msat": {
"added": "pre-v0.10.1",
"deprecated": false
Expand Down Expand Up @@ -3538,14 +3551,30 @@
"added": "pre-v0.10.1",
"deprecated": false
},
"ListForwards.forwards[].updated_index": {
"added": "v23.11",
"deprecated": false
},
"ListForwards.in_channel": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListForwards.index": {
"added": "v23.11",
"deprecated": false
},
"ListForwards.limit": {
"added": "v23.11",
"deprecated": false
},
"ListForwards.out_channel": {
"added": "pre-v0.10.1",
"deprecated": false
},
"ListForwards.start": {
"added": "v23.11",
"deprecated": false
},
"ListForwards.status": {
"added": "pre-v0.10.1",
"deprecated": false
Expand Down
10 changes: 10 additions & 0 deletions cln-grpc/proto/node.proto

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions cln-grpc/src/convert.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions cln-rpc/src/model.rs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

142 changes: 72 additions & 70 deletions contrib/pyln-grpc-proto/pyln/grpc/node_pb2.py

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions contrib/pyln-testing/pyln/testing/grpc2py.py
Original file line number Diff line number Diff line change
Expand Up @@ -1254,13 +1254,15 @@ def getroute2py(m):

def listforwards_forwards2py(m):
return remove_default({
"created_index": m.created_index, # PrimitiveField in generate_composite
"in_channel": m.in_channel, # PrimitiveField in generate_composite
"in_htlc_id": m.in_htlc_id, # PrimitiveField in generate_composite
"in_msat": amount2msat(m.in_msat), # PrimitiveField in generate_composite
"status": str(m.status), # EnumField in generate_composite
"received_time": m.received_time, # PrimitiveField in generate_composite
"out_channel": m.out_channel, # PrimitiveField in generate_composite
"out_htlc_id": m.out_htlc_id, # PrimitiveField in generate_composite
"updated_index": m.updated_index, # PrimitiveField in generate_composite
"style": str(m.style), # EnumField in generate_composite
"fee_msat": amount2msat(m.fee_msat), # PrimitiveField in generate_composite
"out_msat": amount2msat(m.out_msat), # PrimitiveField in generate_composite
Expand Down
4 changes: 3 additions & 1 deletion doc/lightning-listforwards.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ RETURN VALUE
[comment]: # (GENERATE-FROM-SCHEMA-START)
On success, an object containing **forwards** is returned. It is an array of objects, where each object contains:

- **created\_index** (u64): 1-based index indicating order this forward was created in *(added v23.11)*
- **in\_channel** (short\_channel\_id): the channel that received the HTLC
- **in\_msat** (msat): the value of the incoming HTLC
- **status** (string): still ongoing, completed, failed locally, or failed after forwarding (one of "offered", "settled", "local\_failed", "failed")
- **received\_time** (number): the UNIX timestamp when this was received
- **in\_htlc\_id** (u64, optional): the unique HTLC id the sender gave this (not present if incoming channel was closed before ugprade to v22.11)
- **out\_channel** (short\_channel\_id, optional): the channel that the HTLC (trying to) forward to
- **out\_htlc\_id** (u64, optional): the unique HTLC id we gave this when sending (may be missing even if out\_channel is present, for old forwards before v22.11)
- **updated\_index** (u64, optional): 1-based index indicating order this forward was changed (only present if it has changed since creation) *(added v23.11)*
- **style** (string, optional): Either a legacy onion format or a modern tlv format (one of "legacy", "tlv")

If **out\_msat** is present:
Expand Down Expand Up @@ -64,4 +66,4 @@ RESOURCES

Main web site: <https://github.com/ElementsProject/lightning>

[comment]: # ( SHA256STAMP:fb6b59740d52aee780678850445bdd58803b33c1df02c5794473ee87c23da35b)
[comment]: # ( SHA256STAMP:b08957fa97a9e574ea80570518551577e272552a29b60d5b1620f00bdfdfe225)
23 changes: 23 additions & 0 deletions doc/schemas/listforwards.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,18 @@
"type": "object",
"additionalProperties": true,
"required": [
"created_index",
"in_channel",
"in_msat",
"status",
"received_time"
],
"properties": {
"created_index": {
"added": "v23.11",
"type": "u64",
"description": "1-based index indicating order this forward was created in"
},
"in_channel": {
"type": "short_channel_id",
"description": "the channel that received the HTLC"
Expand Down Expand Up @@ -52,6 +58,11 @@
"type": "u64",
"description": "the unique HTLC id we gave this when sending (may be missing even if out_channel is present, for old forwards before v22.11)"
},
"updated_index": {
"added": "v23.11",
"type": "u64",
"description": "1-based index indicating order this forward was changed (only present if it has changed since creation)"
},
"style": {
"type": "string",
"enum": [
Expand All @@ -76,6 +87,8 @@
"out_channel"
],
"properties": {
"created_index": {},
"updated_index": {},
"in_channel": {},
"in_htlc_id": {},
"in_msatoshi": {},
Expand All @@ -102,6 +115,8 @@
"additionalProperties": false,
"required": [],
"properties": {
"created_index": {},
"updated_index": {},
"in_channel": {},
"in_htlc_id": {},
"in_msatoshi": {},
Expand Down Expand Up @@ -134,6 +149,8 @@
"resolved_time"
],
"properties": {
"created_index": {},
"updated_index": {},
"in_channel": {},
"in_htlc_id": {},
"in_msatoshi": {},
Expand All @@ -158,6 +175,8 @@
"else": {
"additionalProperties": false,
"properties": {
"created_index": {},
"updated_index": {},
"in_channel": {},
"in_htlc_id": {},
"in_msatoshi": {},
Expand Down Expand Up @@ -192,6 +211,8 @@
"additionalProperties": false,
"required": [],
"properties": {
"created_index": {},
"updated_index": {},
"in_channel": {},
"in_htlc_id": {},
"in_msatoshi": {},
Expand Down Expand Up @@ -220,6 +241,8 @@
"additionalProperties": false,
"required": [],
"properties": {
"created_index": {},
"updated_index": {},
"in_channel": {},
"in_htlc_id": {},
"in_msatoshi": {},
Expand Down
4 changes: 4 additions & 0 deletions lightningd/forwards.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ void json_add_forwarding_object(struct json_stream *response,
{
json_object_start(response, fieldname);

json_add_u64(response, "created_index", cur->created_index);
if (cur->updated_index)
json_add_u64(response, "updated_index", cur->updated_index);

/* Only for forward_event */
if (payment_hash)
json_add_sha256(response, "payment_hash", payment_hash);
Expand Down
3 changes: 3 additions & 0 deletions lightningd/forwards.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ enum forward_status {
};

struct forwarding {
u64 created_index;
/* zero means never updated */
u64 updated_index;
/* channel_out is all-zero if unknown. */
struct short_channel_id channel_in, channel_out;
/* htlc_id_out is NULL if unknown. */
Expand Down
Loading

0 comments on commit 4cb3791

Please sign in to comment.