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 */
| 1528 | /* We've had a bug report about not failing incoming HTLCs. This does a sanity |
| 1529 | * check, if we think we've already failed this HTLC */ |
| 1530 | static void check_already_failed(const struct channel *channel, struct htlc_out *hout) |
| 1531 | { |
| 1532 | htlc_out_check(hout, __func__); |
| 1533 | |
| 1534 | if (!hout->in) |
| 1535 | return; |
| 1536 | |
| 1537 | /* in should have been failed/succeeded already */ |
| 1538 | if (hout->in->badonion != 0 |
| 1539 | || hout->in->failonion |
| 1540 | || hout->in->preimage) |
| 1541 | return; |
| 1542 | |
| 1543 | /* Print out what we think this htlc already has (failed/succeeded) */ |
| 1544 | log_broken(channel->log, "HTLC id %"PRIu64" already complete, but ->in not resolved!" |
| 1545 | " failonion = %s, failmsg = %s, preimage = %s", |
| 1546 | hout->key.id, |
| 1547 | hout->failonion ? tal_hex(tmpctx, hout->failonion->contents) : "(null)", |
| 1548 | hout->failmsg ? tal_hex(tmpctx, hout->failmsg) : "(null)", |
| 1549 | hout->preimage ? type_to_string(tmpctx, struct preimage, hout->preimage) : "(null)"); |
| 1550 | |
| 1551 | if (hout->preimage) { |
| 1552 | /* Log on both ours and theirs! */ |
| 1553 | log_broken(channel->log, |
| 1554 | "MISSING incoming success for %"PRIu64": succeeding incoming now", |
| 1555 | hout->key.id); |
| 1556 | log_broken(hout->in->key.channel->log, |
| 1557 | "MISSED incoming success for %"PRIu64": succeeding now", |
| 1558 | hout->in->key.id); |
| 1559 | fulfill_htlc(hout->in, hout->preimage); |
| 1560 | } else { |
| 1561 | log_broken(channel->log, |
| 1562 | "MISSING incoming fail for %"PRIu64": failing incoming now", |
| 1563 | hout->key.id); |
| 1564 | log_broken(hout->in->key.channel->log, |
| 1565 | "MISSED incoming fail for %"PRIu64": failing now", |
| 1566 | hout->in->key.id); |
| 1567 | local_fail_in_htlc(hout->in, |
| 1568 | take(towire_permanent_channel_failure(NULL))); |
| 1569 | } |
| 1570 | } |
| 1571 | |
| 1572 | /* This case searches harder to see if there are any incoming HTLCs */ |
| 1573 | static void fail_dangling_htlc_in(struct lightningd *ld, |
no test coverage detected