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 */
| 1799 | /* We've had a bug report about not failing incoming HTLCs. This does a sanity |
| 1800 | * check, if we think we've already failed this HTLC */ |
| 1801 | static void check_already_failed(const struct channel *channel, struct htlc_out *hout) |
| 1802 | { |
| 1803 | htlc_out_check(hout, __func__); |
| 1804 | |
| 1805 | if (!hout->in) |
| 1806 | return; |
| 1807 | |
| 1808 | /* in should have been failed/succeeded already */ |
| 1809 | if (hout->in->badonion != 0 |
| 1810 | || hout->in->failonion |
| 1811 | || hout->in->preimage) |
| 1812 | return; |
| 1813 | |
| 1814 | /* Print out what we think this htlc already has (failed/succeeded) */ |
| 1815 | log_broken(channel->log, "HTLC id %"PRIu64" already complete, but ->in not resolved!" |
| 1816 | " failonion = %s, failmsg = %s, preimage = %s", |
| 1817 | hout->key.id, |
| 1818 | hout->failonion ? tal_hex(tmpctx, hout->failonion->contents) : "(null)", |
| 1819 | hout->failmsg ? tal_hex(tmpctx, hout->failmsg) : "(null)", |
| 1820 | hout->preimage ? fmt_preimage(tmpctx, hout->preimage) : "(null)"); |
| 1821 | |
| 1822 | if (hout->preimage) { |
| 1823 | /* Log on both ours and theirs! */ |
| 1824 | log_broken(channel->log, |
| 1825 | "MISSING incoming success for %"PRIu64": succeeding incoming now", |
| 1826 | hout->key.id); |
| 1827 | log_broken(hout->in->key.channel->log, |
| 1828 | "MISSED incoming success for %"PRIu64": succeeding now", |
| 1829 | hout->in->key.id); |
| 1830 | fulfill_htlc(hout->in, hout->preimage); |
| 1831 | } else { |
| 1832 | log_broken(channel->log, |
| 1833 | "MISSING incoming fail for %"PRIu64": failing incoming now", |
| 1834 | hout->key.id); |
| 1835 | log_broken(hout->in->key.channel->log, |
| 1836 | "MISSED incoming fail for %"PRIu64": failing now", |
| 1837 | hout->in->key.id); |
| 1838 | local_fail_in_htlc(hout->in, |
| 1839 | take(towire_permanent_channel_failure(NULL))); |
| 1840 | } |
| 1841 | } |
| 1842 | |
| 1843 | void onchain_failed_our_htlc(const struct channel *channel, |
| 1844 | const struct htlc_stub *htlc, |
no test coverage detected