From 312751075c0ef069e771698852d650dab3d09dda Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Sat, 9 Jul 2022 12:53:24 +0930 Subject: [PATCH] lightningd: save outgoing information for more forwards. There's one case where we can present more infomation, so do that, and fix documentation. 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 Fixes: #5329 --- doc/lightning-listforwards.7.md | 6 +++--- doc/schemas/listforwards.schema.json | 10 ++++++---- lightningd/peer_htlcs.c | 4 ++-- tests/test_pay.py | 1 - 4 files changed, 11 insertions(+), 10 deletions(-) diff --git a/doc/lightning-listforwards.7.md b/doc/lightning-listforwards.7.md index 88edf2872..0af6cf491 100644 --- a/doc/lightning-listforwards.7.md +++ b/doc/lightning-listforwards.7.md @@ -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* @@ -59,4 +59,4 @@ RESOURCES Main web site: -[comment]: # ( SHA256STAMP:131410f052b8a1845c8d3c7eb2d48df0fc7638e7d26817f56863815be86d8f1e) +[comment]: # ( SHA256STAMP:c8adfa0a6dcae939c5da919d7996261db8663a871210e33b426c3b40c30d7b29) diff --git a/doc/schemas/listforwards.schema.json b/doc/schemas/listforwards.schema.json index 2f0042c46..7702a9f7e 100644 --- a/doc/schemas/listforwards.schema.json +++ b/doc/schemas/listforwards.schema.json @@ -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", @@ -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": {}, @@ -116,7 +117,8 @@ "resolved_time": {}, "payment_hash": {}, "failcode": {}, - "failreason": {} + "failreason": {}, + "out_channel": {} } } }, diff --git a/lightningd/peer_htlcs.c b/lightningd/peer_htlcs.c index f747af9ea..be84af86d 100644 --- a/lightningd/peer_htlcs.c +++ b/lightningd/peer_htlcs.c @@ -538,11 +538,11 @@ static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds UNU fail_in_htlc(hout->in, failonion); /* here we haven't called connect_htlc_out(), - * so set htlc field with NULL */ + * so set htlc field with NULL (db wants it to exist!) */ wallet_forwarded_payment_add(ld->wallet, hout->in, get_onion_style(hout->in), - NULL, NULL, + channel_scid_or_local_alias(hout->key.channel), NULL, FORWARD_LOCAL_FAILED, fromwire_peektype(hout->failmsg)); } diff --git a/tests/test_pay.py b/tests/test_pay.py index 5ee21e31f..a3c21a4f3 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -1383,7 +1383,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):