diff --git a/lightningd/forwards.c b/lightningd/forwards.c index c62e8aa7d03f..690651c32777 100644 --- a/lightningd/forwards.c +++ b/lightningd/forwards.c @@ -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); } diff --git a/lightningd/forwards.h b/lightningd/forwards.h index 1f478c00187c..e1cb04786630 100644 --- a/lightningd/forwards.h +++ b/lightningd/forwards.h @@ -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 */ diff --git a/tests/test_misc.py b/tests/test_misc.py index ef409f51986f..33e02d83e987 100644 --- a/tests/test_misc.py +++ b/tests/test_misc.py @@ -2997,6 +2997,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'}} @@ -3004,6 +3005,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'}} @@ -3024,6 +3026,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'}} @@ -3031,6 +3034,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'}} @@ -3055,6 +3059,7 @@ def test_listforwards_wait(node_factory, executor): assert waitres == {'subsystem': 'forwards', 'deleted': 1, 'details': {'in_channel': scid12, + 'in_htlc_id': 1, 'status': 'failed'}} diff --git a/wallet/test/run-db.c b/wallet/test/run-db.c index ce0a223f1e1a..34aea12d81e0 100644 --- a/wallet/test/run-db.c +++ b/wallet/test/run-db.c @@ -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(); } diff --git a/wallet/test/run-wallet.c b/wallet/test/run-wallet.c index f303912a649a..4349bcd41a20 100644 --- a/wallet/test/run-wallet.c +++ b/wallet/test/run-wallet.c @@ -182,6 +182,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(); } @@ -189,6 +190,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(); } @@ -196,6 +198,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(); } diff --git a/wallet/wallet.c b/wallet/wallet.c index f129f52d7f30..11ba3f2e1ca4 100644 --- a/wallet/wallet.c +++ b/wallet/wallet.c @@ -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); }