Skip to content

Commit

Permalink
lightningd: save outgoing information for more forwards.
Browse files Browse the repository at this point in the history
Changelog-Added: JSON-RPC: `listforwards` now shows `out_channel` in more cases: even if it couldn't actually send to it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Fixes: #5329
  • Loading branch information
rustyrussell committed Jun 21, 2022
1 parent 61b7b7f commit dd8b6ba
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 12 deletions.
6 changes: 3 additions & 3 deletions doc/lightning-listforwards.7.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ On success, an object containing **forwards** is returned. It is an array of ob
- **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
- **out_channel** (short_channel_id, optional): the channel that the HTLC was forwarded to
- **out_channel** (short_channel_id, optional): the channel that the HTLC (trying to) forward to
- **payment_hash** (hex, optional): payment hash sought by HTLC (always 64 characters)
- **style** (string, optional): Either a legacy onion format or a modern tlv format (one of "legacy", "tlv")

If **out_channel** is present:
If **out_msat** is present:
- **fee_msat** (msat): the amount this paid in fees
- **out_msat** (msat): the amount we sent out the *out_channel*

Expand Down Expand Up @@ -59,4 +59,4 @@ RESOURCES

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

[comment]: # ( SHA256STAMP:131410f052b8a1845c8d3c7eb2d48df0fc7638e7d26817f56863815be86d8f1e)
[comment]: # ( SHA256STAMP:c8adfa0a6dcae939c5da919d7996261db8663a871210e33b426c3b40c30d7b29)
10 changes: 6 additions & 4 deletions doc/schemas/listforwards.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
},
"out_channel": {
"type": "short_channel_id",
"description": "the channel that the HTLC was forwarded to"
"description": "the channel that the HTLC (trying to) forward to"
},
"payment_hash": {
"type": "hex",
Expand All @@ -66,14 +66,15 @@
{
"if": {
"required": [
"out_channel"
"out_msat"
]
},
"then": {
"additionalProperties": false,
"required": [
"fee_msat",
"out_msat"
"out_msat",
"out_channel"
],
"properties": {
"in_channel": {},
Expand Down Expand Up @@ -116,7 +117,8 @@
"resolved_time": {},
"payment_hash": {},
"failcode": {},
"failreason": {}
"failreason": {},
"out_channel": {}
}
}
},
Expand Down
6 changes: 2 additions & 4 deletions lightningd/peer_htlcs.c
Original file line number Diff line number Diff line change
Expand Up @@ -537,12 +537,10 @@ static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds UNU
hout->failmsg);
fail_in_htlc(hout->in, failonion);

/* here we haven't called connect_htlc_out(),
* so set htlc field with NULL */
wallet_forwarded_payment_add(ld->wallet,
hout->in,
get_onion_style(hout->in),
NULL, NULL,
hout->key.channel->scid, hout,
FORWARD_LOCAL_FAILED,
fromwire_peektype(hout->failmsg));
}
Expand Down Expand Up @@ -702,7 +700,7 @@ static void forward_htlc(struct htlc_in *hin,
local_fail_in_htlc(hin, take(towire_unknown_next_peer(NULL)));
wallet_forwarded_payment_add(hin->key.channel->peer->ld->wallet,
hin, get_onion_style(hin),
next ? next->scid : NULL, NULL,
scid, NULL,
FORWARD_LOCAL_FAILED,
WIRE_UNKNOWN_NEXT_PEER);
return;
Expand Down
1 change: 0 additions & 1 deletion tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -1384,7 +1384,6 @@ def test_forward_stats(node_factory, bitcoind):
assert 'received_time' in stats['forwards'][2] and 'resolved_time' not in stats['forwards'][2]


@pytest.mark.xfail(strict=True)
@pytest.mark.developer("too slow without --dev-fast-gossip")
@pytest.mark.slow_test
def test_forward_local_failed_stats(node_factory, bitcoind, executor):
Expand Down

0 comments on commit dd8b6ba

Please sign in to comment.