| 138 | } |
| 139 | |
| 140 | static void fail_in_htlc(struct htlc_in *hin, |
| 141 | const struct onionreply *failonion TAKES) |
| 142 | { |
| 143 | struct failed_htlc *failed_htlc; |
| 144 | assert(!hin->preimage); |
| 145 | |
| 146 | hin->failonion = dup_onionreply(hin, failonion); |
| 147 | |
| 148 | /* We update state now to signal it's in progress, for persistence. */ |
| 149 | htlc_in_update_state(hin->key.channel, hin, SENT_REMOVE_HTLC); |
| 150 | htlc_in_check(hin, __func__); |
| 151 | |
| 152 | #if EXPERIMENTAL_FEATURES |
| 153 | /* In a blinded path, all failures become invalid_onion_blinding */ |
| 154 | if (hin->blinding) { |
| 155 | failed_htlc = mk_failed_htlc_badonion(tmpctx, hin, |
| 156 | WIRE_INVALID_ONION_BLINDING); |
| 157 | } else |
| 158 | #endif |
| 159 | failed_htlc = mk_failed_htlc(tmpctx, hin, hin->failonion); |
| 160 | |
| 161 | bool we_filled = false; |
| 162 | wallet_htlc_update(hin->key.channel->peer->ld->wallet, |
| 163 | hin->dbid, hin->hstate, |
| 164 | hin->preimage, |
| 165 | max_unsigned(hin->key.channel->next_index[LOCAL], |
| 166 | hin->key.channel->next_index[REMOTE]), |
| 167 | hin->badonion, |
| 168 | hin->failonion, NULL, &we_filled); |
| 169 | |
| 170 | tell_channeld_htlc_failed(hin, failed_htlc); |
| 171 | } |
| 172 | |
| 173 | /* Immediately fail HTLC with a BADONION code */ |
| 174 | static void local_fail_in_htlc_badonion(struct htlc_in *hin, |
no test coverage detected