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

Function check_already_failed

lightningd/peer_htlcs.c:1871–1911  ·  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

1869/* We've had a bug report about not failing incoming HTLCs. This does a sanity
1870 * check, if we think we've already failed this HTLC */
1871static void check_already_failed(const struct channel *channel, struct htlc_out *hout)
1872{
1873 htlc_out_check(hout, __func__);
1874
1875 if (!hout->in)
1876 return;
1877
1878 /* in should have been failed/succeeded already */
1879 if (hout->in->badonion != 0
1880 || hout->in->failonion
1881 || hout->in->preimage)
1882 return;
1883
1884 /* Print out what we think this htlc already has (failed/succeeded) */
1885 log_broken(channel->log, "HTLC id %"PRIu64" already complete, but ->in not resolved!"
1886 " failonion = %s, failmsg = %s, preimage = %s",
1887 hout->key.id,
1888 hout->failonion ? tal_hex(tmpctx, hout->failonion->contents) : "(null)",
1889 hout->failmsg ? tal_hex(tmpctx, hout->failmsg) : "(null)",
1890 hout->preimage ? fmt_preimage(tmpctx, hout->preimage) : "(null)");
1891
1892 if (hout->preimage) {
1893 /* Log on both ours and theirs! */
1894 log_broken(channel->log,
1895 "MISSING incoming success for %"PRIu64": succeeding incoming now",
1896 hout->key.id);
1897 log_broken(hout->in->key.channel->log,
1898 "MISSED incoming success for %"PRIu64": succeeding now",
1899 hout->in->key.id);
1900 fulfill_htlc(hout->in, hout->preimage);
1901 } else {
1902 log_broken(channel->log,
1903 "MISSING incoming fail for %"PRIu64": failing incoming now",
1904 hout->key.id);
1905 log_broken(hout->in->key.channel->log,
1906 "MISSED incoming fail for %"PRIu64": failing now",
1907 hout->in->key.id);
1908 local_fail_in_htlc(hout->in,
1909 take(towire_permanent_channel_failure(NULL)));
1910 }
1911}
1912
1913void onchain_failed_our_htlc(const struct channel *channel,
1914 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