Skip to content

Commit bf4253f

Browse files
rustyrussellendothermicdev
authored andcommitted
lightningd: don't spam logs on dangling outgoing HTLCs.
We pre-close incoming under some circumstances, so this does happen (it didn't when this code was written). Don't walk all the HTLCs complaining about them in this case, and don't freak out. Changelog-Fixed: lightningd: incorrect spamming of log and potential crash on testnet case of duplicate HTLCs and slow closing. Signed-off-by: Rusty Russell <[email protected]> Fixes: #8176
1 parent 07669a0 commit bf4253f

File tree

1 file changed

+0
-36
lines changed

1 file changed

+0
-36
lines changed

lightningd/peer_htlcs.c

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1704,41 +1704,6 @@ static void check_already_failed(const struct channel *channel, struct htlc_out
17041704
}
17051705
}
17061706

1707-
/* This case searches harder to see if there are any incoming HTLCs */
1708-
static void fail_dangling_htlc_in(struct lightningd *ld,
1709-
const struct sha256 *payment_hash)
1710-
{
1711-
struct htlc_in *hin;
1712-
struct htlc_in_map_iter ini;
1713-
1714-
for (hin = htlc_in_map_first(ld->htlcs_in, &ini);
1715-
hin;
1716-
hin = htlc_in_map_next(ld->htlcs_in, &ini)) {
1717-
if (!sha256_eq(&hin->payment_hash, payment_hash))
1718-
continue;
1719-
if (hin->badonion) {
1720-
log_broken(hin->key.channel->log,
1721-
"htlc %"PRIu64" already failed with badonion",
1722-
hin->key.id);
1723-
} else if (hin->preimage) {
1724-
log_broken(hin->key.channel->log,
1725-
"htlc %"PRIu64" already succeeded with preimage",
1726-
hin->key.id);
1727-
} else if (hin->failonion) {
1728-
log_broken(hin->key.channel->log,
1729-
"htlc %"PRIu64" already failed with failonion %s",
1730-
hin->key.id,
1731-
tal_hex(tmpctx, hin->failonion->contents));
1732-
} else {
1733-
log_broken(hin->key.channel->log,
1734-
"htlc %"PRIu64" has matching hash: failing",
1735-
hin->key.id);
1736-
local_fail_in_htlc(hin,
1737-
take(towire_permanent_channel_failure(NULL)));
1738-
}
1739-
}
1740-
}
1741-
17421707
void onchain_failed_our_htlc(const struct channel *channel,
17431708
const struct htlc_stub *htlc,
17441709
const char *why,
@@ -1841,7 +1806,6 @@ void onchain_failed_our_htlc(const struct channel *channel,
18411806
/* Immediate corruption sanity check if this happens */
18421807
htable_check(&ld->htlcs_out->raw, "onchain_failed_our_htlc out");
18431808
htable_check(&ld->htlcs_in->raw, "onchain_failed_our_htlc in");
1844-
fail_dangling_htlc_in(ld, &hout->payment_hash);
18451809
}
18461810
}
18471811

0 commit comments

Comments
 (0)