MCPcopy Create free account
hub / github.com/ElementsProject/lightning / check_already_failed

Function check_already_failed

lightningd/peer_htlcs.c:1827–1867  ·  view source on GitHub ↗

We've had a bug report about not failing incoming HTLCs. This does a sanity * check, if we think we've already failed this HTLC */

Source from the content-addressed store, hash-verified

1825/* We've had a bug report about not failing incoming HTLCs. This does a sanity
1826 * check, if we think we've already failed this HTLC */
1827static void check_already_failed(const struct channel *channel, struct htlc_out *hout)
1828{
1829 htlc_out_check(hout, __func__);
1830
1831 if (!hout->in)
1832 return;
1833
1834 /* in should have been failed/succeeded already */
1835 if (hout->in->badonion != 0
1836 || hout->in->failonion
1837 || hout->in->preimage)
1838 return;
1839
1840 /* Print out what we think this htlc already has (failed/succeeded) */
1841 log_broken(channel->log, "HTLC id %"PRIu64" already complete, but ->in not resolved!"
1842 " failonion = %s, failmsg = %s, preimage = %s",
1843 hout->key.id,
1844 hout->failonion ? tal_hex(tmpctx, hout->failonion->contents) : "(null)",
1845 hout->failmsg ? tal_hex(tmpctx, hout->failmsg) : "(null)",
1846 hout->preimage ? fmt_preimage(tmpctx, hout->preimage) : "(null)");
1847
1848 if (hout->preimage) {
1849 /* Log on both ours and theirs! */
1850 log_broken(channel->log,
1851 "MISSING incoming success for %"PRIu64": succeeding incoming now",
1852 hout->key.id);
1853 log_broken(hout->in->key.channel->log,
1854 "MISSED incoming success for %"PRIu64": succeeding now",
1855 hout->in->key.id);
1856 fulfill_htlc(hout->in, hout->preimage);
1857 } else {
1858 log_broken(channel->log,
1859 "MISSING incoming fail for %"PRIu64": failing incoming now",
1860 hout->key.id);
1861 log_broken(hout->in->key.channel->log,
1862 "MISSED incoming fail for %"PRIu64": failing now",
1863 hout->in->key.id);
1864 local_fail_in_htlc(hout->in,
1865 take(towire_permanent_channel_failure(NULL)));
1866 }
1867}
1868
1869void onchain_failed_our_htlc(const struct channel *channel,
1870 const struct htlc_stub *htlc,

Callers 1

onchain_failed_our_htlcFunction · 0.85

Calls 5

htlc_out_checkFunction · 0.85
tal_hexFunction · 0.85
fmt_preimageFunction · 0.85
fulfill_htlcFunction · 0.70
local_fail_in_htlcFunction · 0.70

Tested by

no test coverage detected