| 259 | } |
| 260 | |
| 261 | static void fail_in_htlc(struct htlc_in *hin, |
| 262 | const struct onionreply *failonion TAKES) |
| 263 | { |
| 264 | struct failed_htlc *failed_htlc; |
| 265 | assert(!hin->preimage); |
| 266 | |
| 267 | hin->failonion = dup_onionreply(hin, failonion); |
| 268 | |
| 269 | /* We update state now to signal it's in progress, for persistence. */ |
| 270 | htlc_in_update_state(hin->key.channel, hin, SENT_REMOVE_HTLC); |
| 271 | htlc_in_check(hin, __func__); |
| 272 | |
| 273 | failed_htlc = mk_failed_htlc(tmpctx, hin, hin->failonion); |
| 274 | |
| 275 | bool we_filled = false; |
| 276 | wallet_htlc_update(hin->key.channel->peer->ld->wallet, |
| 277 | hin->dbid, hin->hstate, |
| 278 | hin->preimage, |
| 279 | max_unsigned(hin->key.channel->next_index[LOCAL], |
| 280 | hin->key.channel->next_index[REMOTE]), |
| 281 | hin->badonion, |
| 282 | hin->failonion, NULL, &we_filled, |
| 283 | hin->key.id, |
| 284 | hin->key.channel, |
| 285 | REMOTE, |
| 286 | &hin->payment_hash, |
| 287 | hin->cltv_expiry, |
| 288 | hin->msat); |
| 289 | |
| 290 | tell_channeld_htlc_failed(hin, failed_htlc); |
| 291 | } |
| 292 | |
| 293 | /* Immediately fail HTLC with a BADONION code */ |
| 294 | static void local_fail_in_htlc_badonion(struct htlc_in *hin, |
no test coverage detected