db: correctly migrate forwards for closed incoming channels.

We have to allow them (as otherwise `fees_collected_msat` in getinfo breaks),
but it means that actually, in_htlc_id might be missing in listforwards
(also, out_htlc_id might be missing, which we didn't catch before).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Fixes: #5628
This commit is contained in:
Rusty Russell
2022-09-27 09:13:35 +09:30
parent 9023bd9334
commit cafa1a8c65
11 changed files with 55 additions and 47 deletions

View File

@@ -2844,7 +2844,11 @@ void json_add_forwarding_object(struct json_stream *response,
if (payment_hash)
json_add_sha256(response, "payment_hash", payment_hash);
json_add_short_channel_id(response, "in_channel", &cur->channel_in);
json_add_u64(response, "in_htlc_id", cur->htlc_id_in);
#ifdef COMPAT_V0121
if (cur->htlc_id_in != HTLC_INVALID_ID)
#endif
json_add_u64(response, "in_htlc_id", cur->htlc_id_in);
/* This can be unknown if we failed before channel lookup */
if (cur->channel_out.u64 != 0) {