localfail are for handing to the local payer if it's local. */
| 215 | |
| 216 | /* localfail are for handing to the local payer if it's local. */ |
| 217 | static void fail_out_htlc(struct htlc_out *hout, const char *localfail) |
| 218 | { |
| 219 | htlc_out_check(hout, __func__); |
| 220 | assert(hout->failmsg || hout->failonion); |
| 221 | |
| 222 | if (hout->am_origin) { |
| 223 | payment_failed(hout->key.channel->peer->ld, hout, localfail); |
| 224 | } else if (hout->in) { |
| 225 | const struct onionreply *failonion; |
| 226 | |
| 227 | /* If we have an onion, simply copy it. */ |
| 228 | if (hout->failonion) |
| 229 | failonion = hout->failonion; |
| 230 | /* Otherwise, we need to onionize this local error. */ |
| 231 | else |
| 232 | failonion = create_onionreply(hout, |
| 233 | hout->in->shared_secret, |
| 234 | hout->failmsg); |
| 235 | fail_in_htlc(hout->in, failonion); |
| 236 | } else { |
| 237 | log_broken(hout->key.channel->log, "Neither origin nor in?"); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | /* BOLT #4: |
| 242 | * |
no test coverage detected