If we want to know if this HTLC is missing, return depth. */
| 63 | |
| 64 | /* If we want to know if this HTLC is missing, return depth. */ |
| 65 | static bool tell_if_missing(const struct channel *channel, |
| 66 | struct htlc_stub *stub, |
| 67 | bool *tell_immediate) |
| 68 | { |
| 69 | struct htlc_out *hout; |
| 70 | |
| 71 | /* Keep valgrind happy. */ |
| 72 | *tell_immediate = false; |
| 73 | |
| 74 | /* Don't care about incoming HTLCs, just ones we offered. */ |
| 75 | if (stub->owner == REMOTE) |
| 76 | return false; |
| 77 | |
| 78 | /* Might not be a current HTLC. */ |
| 79 | hout = find_htlc_out(&channel->peer->ld->htlcs_out, channel, stub->id); |
| 80 | if (!hout) |
| 81 | return false; |
| 82 | |
| 83 | /* BOLT #5: |
| 84 | * |
| 85 | * - for any committed HTLC that does NOT have an output in this |
| 86 | * commitment transaction: |
| 87 | * - once the commitment transaction has reached reasonable depth: |
| 88 | * - MUST fail the corresponding incoming HTLC (if any). |
| 89 | * - if no *valid* commitment transaction contains an output |
| 90 | * corresponding to the HTLC. |
| 91 | * - MAY fail the corresponding incoming HTLC sooner. |
| 92 | */ |
| 93 | if (hout->hstate >= RCVD_ADD_REVOCATION |
| 94 | && hout->hstate < SENT_REMOVE_REVOCATION) |
| 95 | *tell_immediate = true; |
| 96 | |
| 97 | log_debug(channel->log, |
| 98 | "We want to know if htlc %"PRIu64" is missing (%s)", |
| 99 | hout->key.id, *tell_immediate ? "immediate" : "later"); |
| 100 | return true; |
| 101 | } |
| 102 | |
| 103 | static void handle_onchain_init_reply(struct channel *channel, const u8 *msg) |
| 104 | { |
no test coverage detected