This is where channeld gives us the HTLC id, and also reports if it * failed immediately. */
| 488 | /* This is where channeld gives us the HTLC id, and also reports if it |
| 489 | * failed immediately. */ |
| 490 | static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds UNUSED, |
| 491 | struct htlc_out *hout) |
| 492 | { |
| 493 | u8 *failmsg; |
| 494 | char *failurestr; |
| 495 | struct lightningd *ld = subd->ld; |
| 496 | |
| 497 | if (!fromwire_channeld_offer_htlc_reply(msg, msg, |
| 498 | &hout->key.id, |
| 499 | &failmsg, |
| 500 | &failurestr)) { |
| 501 | channel_internal_error(subd->channel, |
| 502 | "Bad channel_offer_htlc_reply"); |
| 503 | tal_free(hout); |
| 504 | return; |
| 505 | } |
| 506 | |
| 507 | if (tal_count(failmsg)) { |
| 508 | hout->failmsg = tal_steal(hout, failmsg); |
| 509 | if (hout->am_origin) { |
| 510 | char *localfail = tal_fmt(msg, "%s: %s", |
| 511 | onion_wire_name(fromwire_peektype(failmsg)), |
| 512 | failurestr); |
| 513 | payment_failed(ld, hout, localfail); |
| 514 | |
| 515 | } else if (hout->in) { |
| 516 | struct onionreply *failonion; |
| 517 | |
| 518 | failonion = create_onionreply(hout, |
| 519 | hout->in->shared_secret, |
| 520 | hout->failmsg); |
| 521 | fail_in_htlc(hout->in, failonion); |
| 522 | |
| 523 | /* here we haven't called connect_htlc_out(), |
| 524 | * so set htlc field with NULL (db wants it to exist!) */ |
| 525 | wallet_forwarded_payment_add(ld->wallet, |
| 526 | hout->in, |
| 527 | FORWARD_STYLE_TLV, |
| 528 | channel_scid_or_local_alias(hout->key.channel), NULL, |
| 529 | FORWARD_LOCAL_FAILED, |
| 530 | fromwire_peektype(hout->failmsg)); |
| 531 | } |
| 532 | |
| 533 | /* Prevent hout from being failed twice. */ |
| 534 | tal_del_destructor(hout, destroy_hout_subd_died); |
| 535 | tal_free(hout); |
| 536 | return; |
| 537 | } |
| 538 | |
| 539 | if (find_htlc_out(&subd->ld->htlcs_out, hout->key.channel, hout->key.id) |
| 540 | || hout->key.id == HTLC_INVALID_ID) { |
| 541 | channel_internal_error(subd->channel, |
| 542 | "Bad offer_htlc_reply HTLC id %"PRIu64 |
| 543 | " is a duplicate", |
| 544 | hout->key.id); |
| 545 | tal_free(hout); |
| 546 | return; |
| 547 | } |
nothing calls this directly
no test coverage detected