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 */
| 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 */ |
| 1871 | static 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 | |
| 1913 | void onchain_failed_our_htlc(const struct channel *channel, |
| 1914 | const struct htlc_stub *htlc, |
no test coverage detected