wait forwards: add in_htlc_id

Without this, we have no unique identifier for which forward happened.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell 2023-10-28 13:42:18 +10:30
parent 0317348479
commit af971fd025
6 changed files with 28 additions and 3 deletions

View File

@ -14,6 +14,7 @@
static u64 forward_index_inc(struct lightningd *ld,
enum forward_status status,
struct short_channel_id in_channel,
u64 in_htlc_id,
const struct amount_msat *in_amount,
const struct short_channel_id *out_channel,
enum wait_index idx)
@ -21,6 +22,7 @@ static u64 forward_index_inc(struct lightningd *ld,
return wait_index_increment(ld, WAIT_SUBSYSTEM_FORWARD, idx,
"status", forward_status_name(status),
"in_channel", short_channel_id_to_str(tmpctx, &in_channel),
"=in_htlc_id", tal_fmt(tmpctx, "%"PRIu64, in_htlc_id),
"=in_msat", in_amount ? tal_fmt(tmpctx, "%"PRIu64, in_amount->millisatoshis) : NULL, /* Raw: JSON output */
"out_channel", out_channel ? short_channel_id_to_str(tmpctx, out_channel): NULL,
NULL);
@ -29,10 +31,12 @@ static u64 forward_index_inc(struct lightningd *ld,
void forward_index_deleted(struct lightningd *ld,
enum forward_status status,
struct short_channel_id in_channel,
u64 in_htlc_id,
const struct amount_msat *in_amount,
const struct short_channel_id *out_channel)
{
forward_index_inc(ld, status, in_channel, in_amount, out_channel,
forward_index_inc(ld, status, in_channel, in_htlc_id,
in_amount, out_channel,
WAIT_INDEX_DELETED);
}
@ -40,20 +44,24 @@ void forward_index_deleted(struct lightningd *ld,
u64 forward_index_created(struct lightningd *ld,
enum forward_status status,
struct short_channel_id in_channel,
u64 in_htlc_id,
struct amount_msat in_amount,
const struct short_channel_id *out_channel)
{
return forward_index_inc(ld, status, in_channel, &in_amount, out_channel,
return forward_index_inc(ld, status, in_channel, in_htlc_id,
&in_amount, out_channel,
WAIT_INDEX_CREATED);
}
u64 forward_index_update_status(struct lightningd *ld,
enum forward_status status,
struct short_channel_id in_channel,
u64 in_htlc_id,
struct amount_msat in_amount,
const struct short_channel_id *out_channel)
{
return forward_index_inc(ld, status, in_channel, &in_amount, out_channel,
return forward_index_inc(ld, status, in_channel, in_htlc_id,
&in_amount, out_channel,
WAIT_INDEX_UPDATED);
}

View File

@ -95,16 +95,19 @@ static inline const char *forward_style_name(enum forward_style style)
void forward_index_deleted(struct lightningd *ld,
enum forward_status status,
struct short_channel_id in_channel,
u64 in_htlc_id,
const struct amount_msat *in_amount,
const struct short_channel_id *out_channel);
u64 forward_index_created(struct lightningd *ld,
enum forward_status status,
struct short_channel_id in_channel,
u64 in_htlc_id,
struct amount_msat in_amount,
const struct short_channel_id *out_channel);
u64 forward_index_update_status(struct lightningd *ld,
enum forward_status status,
struct short_channel_id in_channel,
u64 in_htlc_id,
struct amount_msat in_amount,
const struct short_channel_id *out_channel);
#endif /* LIGHTNING_LIGHTNINGD_FORWARDS_H */

View File

@ -3013,6 +3013,7 @@ def test_listforwards_wait(node_factory, executor):
assert waitres == {'subsystem': 'forwards',
'created': 1,
'details': {'in_channel': scid12,
'in_htlc_id': 0,
'in_msat': Millisatoshi(amt1 + 1),
'out_channel': scid23,
'status': 'offered'}}
@ -3020,6 +3021,7 @@ def test_listforwards_wait(node_factory, executor):
assert waitres == {'subsystem': 'forwards',
'updated': 1,
'details': {'in_channel': scid12,
'in_htlc_id': 0,
'in_msat': Millisatoshi(amt1 + 1),
'out_channel': scid23,
'status': 'settled'}}
@ -3040,6 +3042,7 @@ def test_listforwards_wait(node_factory, executor):
assert waitres == {'subsystem': 'forwards',
'created': 2,
'details': {'in_channel': scid12,
'in_htlc_id': 1,
'in_msat': Millisatoshi(amt2 + 1),
'out_channel': scid23,
'status': 'offered'}}
@ -3047,6 +3050,7 @@ def test_listforwards_wait(node_factory, executor):
assert waitres == {'subsystem': 'forwards',
'updated': 2,
'details': {'in_channel': scid12,
'in_htlc_id': 1,
'in_msat': Millisatoshi(amt2 + 1),
'out_channel': scid23,
'status': 'failed'}}
@ -3071,6 +3075,7 @@ def test_listforwards_wait(node_factory, executor):
assert waitres == {'subsystem': 'forwards',
'deleted': 1,
'details': {'in_channel': scid12,
'in_htlc_id': 1,
'status': 'failed'}}

View File

@ -56,6 +56,7 @@ struct peer *find_peer_by_dbid(struct lightningd *ld UNNEEDED, u64 dbid UNNEEDED
u64 forward_index_created(struct lightningd *ld UNNEEDED,
enum forward_status status UNNEEDED,
struct short_channel_id in_channel UNNEEDED,
u64 in_htlc_id UNNEEDED,
struct amount_msat in_amount UNNEEDED,
const struct short_channel_id *out_channel UNNEEDED)
{ fprintf(stderr, "forward_index_created called!\n"); abort(); }
@ -63,6 +64,7 @@ u64 forward_index_created(struct lightningd *ld UNNEEDED,
void forward_index_deleted(struct lightningd *ld UNNEEDED,
enum forward_status status UNNEEDED,
struct short_channel_id in_channel UNNEEDED,
u64 in_htlc_id UNNEEDED,
const struct amount_msat *in_amount UNNEEDED,
const struct short_channel_id *out_channel UNNEEDED)
{ fprintf(stderr, "forward_index_deleted called!\n"); abort(); }
@ -70,6 +72,7 @@ void forward_index_deleted(struct lightningd *ld UNNEEDED,
u64 forward_index_update_status(struct lightningd *ld UNNEEDED,
enum forward_status status UNNEEDED,
struct short_channel_id in_channel UNNEEDED,
u64 in_htlc_id UNNEEDED,
struct amount_msat in_amount UNNEEDED,
const struct short_channel_id *out_channel UNNEEDED)
{ fprintf(stderr, "forward_index_update_status called!\n"); abort(); }

View File

@ -204,6 +204,7 @@ void force_peer_disconnect(struct lightningd *ld UNNEEDED,
u64 forward_index_created(struct lightningd *ld UNNEEDED,
enum forward_status status UNNEEDED,
struct short_channel_id in_channel UNNEEDED,
u64 in_htlc_id UNNEEDED,
struct amount_msat in_amount UNNEEDED,
const struct short_channel_id *out_channel UNNEEDED)
{ fprintf(stderr, "forward_index_created called!\n"); abort(); }
@ -211,6 +212,7 @@ u64 forward_index_created(struct lightningd *ld UNNEEDED,
void forward_index_deleted(struct lightningd *ld UNNEEDED,
enum forward_status status UNNEEDED,
struct short_channel_id in_channel UNNEEDED,
u64 in_htlc_id UNNEEDED,
const struct amount_msat *in_amount UNNEEDED,
const struct short_channel_id *out_channel UNNEEDED)
{ fprintf(stderr, "forward_index_deleted called!\n"); abort(); }
@ -218,6 +220,7 @@ void forward_index_deleted(struct lightningd *ld UNNEEDED,
u64 forward_index_update_status(struct lightningd *ld UNNEEDED,
enum forward_status status UNNEEDED,
struct short_channel_id in_channel UNNEEDED,
u64 in_htlc_id UNNEEDED,
struct amount_msat in_amount UNNEEDED,
const struct short_channel_id *out_channel UNNEEDED)
{ fprintf(stderr, "forward_index_update_status called!\n"); abort(); }

View File

@ -4713,6 +4713,7 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in,
forward_index_update_status(w->ld,
state,
*channel_scid_or_local_alias(in->key.channel),
in->key.id,
in->msat,
out ? channel_scid_or_local_alias(out->key.channel) : NULL);
id = 0;
@ -4738,6 +4739,7 @@ void wallet_forwarded_payment_add(struct wallet *w, const struct htlc_in *in,
id = forward_index_created(w->ld,
state,
*channel_scid_or_local_alias(in->key.channel),
in->key.id,
in->msat,
out ? channel_scid_or_local_alias(out->key.channel) : NULL);
@ -5127,6 +5129,7 @@ bool wallet_forward_delete(struct wallet *w,
forward_index_deleted(w->ld,
state,
*chan_in,
htlc_id ? *htlc_id : HTLC_INVALID_ID,
NULL, NULL);
}