localfail are for handing to the local payer if it's local. */
| 338 | |
| 339 | /* localfail are for handing to the local payer if it's local. */ |
| 340 | static void fail_out_htlc(struct htlc_out *hout, const char *localfail) |
| 341 | { |
| 342 | htlc_out_check(hout, __func__); |
| 343 | assert(hout->failmsg || hout->failonion); |
| 344 | |
| 345 | if (hout->am_origin) { |
| 346 | payment_failed(hout->key.channel->peer->ld, |
| 347 | hout->key.channel->log, |
| 348 | &hout->payment_hash, |
| 349 | hout->partid, |
| 350 | hout->groupid, |
| 351 | hout->failonion, |
| 352 | hout->failmsg, |
| 353 | localfail); |
| 354 | } else if (hout->in) { |
| 355 | const struct onionreply *failonion; |
| 356 | |
| 357 | /* If we have an onion, simply copy it. */ |
| 358 | if (hout->failonion) |
| 359 | failonion = hout->failonion; |
| 360 | /* Otherwise, we need to onionize this local error. */ |
| 361 | else |
| 362 | failonion = create_onionreply(hout, |
| 363 | hout->in->shared_secret, |
| 364 | hout->failmsg); |
| 365 | fail_in_htlc(hout->in, failonion); |
| 366 | } else { |
| 367 | log_broken(hout->key.channel->log, "Neither origin nor in?"); |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | /* BOLT #4: |
| 372 | * |
no test coverage detected