If we want to know if this HTLC is missing, return depth. */
| 87 | |
| 88 | /* If we want to know if this HTLC is missing, return depth. */ |
| 89 | static bool tell_if_missing(const struct channel *channel, |
| 90 | struct htlc_stub *stub, |
| 91 | bool *tell_immediate) |
| 92 | { |
| 93 | struct htlc_out *hout; |
| 94 | |
| 95 | /* Keep valgrind happy. */ |
| 96 | *tell_immediate = false; |
| 97 | |
| 98 | /* Don't care about incoming HTLCs, just ones we offered. */ |
| 99 | if (stub->owner == REMOTE) |
| 100 | return false; |
| 101 | |
| 102 | /* Might not be a current HTLC. */ |
| 103 | hout = find_htlc_out(channel->peer->ld->htlcs_out, channel, stub->id); |
| 104 | if (!hout) |
| 105 | return false; |
| 106 | |
| 107 | /* BOLT #5: |
| 108 | * |
| 109 | * - for any committed HTLC that does NOT have an output in this |
| 110 | * commitment transaction: |
| 111 | * - if the payment preimage is known: |
| 112 | * - MUST fulfill the corresponding incoming HTLC (if any). |
| 113 | * - otherwise: |
| 114 | * - once the commitment transaction has reached reasonable depth: |
| 115 | * - MUST fail the corresponding incoming HTLC (if any). |
| 116 | * - if no *valid* commitment transaction contains an output |
| 117 | * corresponding to the HTLC: |
| 118 | * - MAY fail the corresponding incoming HTLC sooner. |
| 119 | */ |
| 120 | if (hout->hstate >= RCVD_ADD_REVOCATION |
| 121 | && hout->hstate < SENT_REMOVE_REVOCATION) |
| 122 | *tell_immediate = true; |
| 123 | |
| 124 | log_debug(channel->log, |
| 125 | "We want to know if htlc %"PRIu64" is missing (%s)", |
| 126 | hout->key.id, *tell_immediate ? "immediate" : "later"); |
| 127 | return true; |
| 128 | } |
| 129 | |
| 130 | static void handle_onchain_init_reply(struct channel *channel, const u8 *msg) |
| 131 | { |
no test coverage detected