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 <rusty@rustcorp.com.au>
Fixes: #5329
This commit is contained in:
Rusty Russell 2022-07-09 12:53:24 +09:30
parent 3a1a7eb93f
commit 312751075c
4 changed files with 11 additions and 10 deletions

View File

@ -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: <https://github.com/ElementsProject/lightning>
[comment]: # ( SHA256STAMP:131410f052b8a1845c8d3c7eb2d48df0fc7638e7d26817f56863815be86d8f1e)
[comment]: # ( SHA256STAMP:c8adfa0a6dcae939c5da919d7996261db8663a871210e33b426c3b40c30d7b29)

View File

@ -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": {}
}
}
},

View File

@ -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));
}

View File

@ -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):