localfail are for handing to the local payer if it's local. */
| 294 | |
| 295 | /* localfail are for handing to the local payer if it's local. */ |
| 296 | static void fail_out_htlc(struct htlc_out *hout, const char *localfail) |
| 297 | { |
| 298 | htlc_out_check(hout, __func__); |
| 299 | assert(hout->failmsg || hout->failonion); |
| 300 | |
| 301 | if (hout->am_origin) { |
| 302 | payment_failed(hout->key.channel->peer->ld, |
| 303 | hout->key.channel->log, |
| 304 | &hout->payment_hash, |
| 305 | hout->partid, |
| 306 | hout->groupid, |
| 307 | hout->failonion, |
| 308 | hout->failmsg, |
| 309 | localfail); |
| 310 | } else if (hout->in) { |
| 311 | const struct onionreply *failonion; |
| 312 | |
| 313 | /* If we have an onion, simply copy it. */ |
| 314 | if (hout->failonion) |
| 315 | failonion = hout->failonion; |
| 316 | /* Otherwise, we need to onionize this local error. */ |
| 317 | else |
| 318 | failonion = create_onionreply(hout, |
| 319 | hout->in->shared_secret, |
| 320 | hout->failmsg); |
| 321 | fail_in_htlc(hout->in, failonion); |
| 322 | } else { |
| 323 | log_broken(hout->key.channel->log, "Neither origin nor in?"); |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | /* BOLT #4: |
| 328 | * |
no test coverage detected