This is where channeld gives us the HTLC id, and also reports if it * failed immediately. */
| 590 | /* This is where channeld gives us the HTLC id, and also reports if it |
| 591 | * failed immediately. */ |
| 592 | static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds UNUSED, |
| 593 | struct htlc_out *hout) |
| 594 | { |
| 595 | u8 *failmsg; |
| 596 | char *failurestr; |
| 597 | struct lightningd *ld = subd->ld; |
| 598 | |
| 599 | if (!fromwire_channeld_offer_htlc_reply(msg, msg, |
| 600 | &hout->key.id, |
| 601 | &failmsg, |
| 602 | &failurestr)) { |
| 603 | channel_internal_error(subd->channel, |
| 604 | "Bad channel_offer_htlc_reply"); |
| 605 | tal_free(hout); |
| 606 | return; |
| 607 | } |
| 608 | |
| 609 | if (tal_count(failmsg)) { |
| 610 | /* BOLT #4: |
| 611 | * The `channel_update` field used to be mandatory in messages |
| 612 | * whose `failure_code` includes the `UPDATE` flag. However, |
| 613 | * because nodes applying an update contained in the onion to |
| 614 | * their gossip data is a massive fingerprinting |
| 615 | * vulnerability, the `channel_update` field is no longer |
| 616 | * mandatory and nodes are expected to transition away from |
| 617 | * including it. Nodes which do not provide a `channel_update` |
| 618 | * are expected to set the `channel_update` `len` field to |
| 619 | * zero. |
| 620 | */ |
| 621 | /* We still append the channel_update (if we have one!) FIXME: provide an option? */ |
| 622 | if (fromwire_peektype(failmsg) & UPDATE) { |
| 623 | const u8 *update = channel_update_for_error(tmpctx, hout->in, hout->key.channel); |
| 624 | towire(&failmsg, update, tal_bytelen(update)); |
| 625 | } |
| 626 | hout->failmsg = tal_steal(hout, failmsg); |
| 627 | if (hout->am_origin) { |
| 628 | char *localfail = tal_fmt(msg, "%s: %s", |
| 629 | onion_wire_name(fromwire_peektype(failmsg)), |
| 630 | failurestr); |
| 631 | payment_failed(ld, |
| 632 | hout->key.channel->log, |
| 633 | &hout->payment_hash, |
| 634 | hout->partid, |
| 635 | hout->groupid, |
| 636 | hout->failonion, |
| 637 | hout->failmsg, |
| 638 | localfail); |
| 639 | } else if (hout->in) { |
| 640 | struct onionreply *failonion; |
| 641 | struct short_channel_id scid; |
| 642 | |
| 643 | failonion = create_onionreply(hout, |
| 644 | hout->in->shared_secret, |
| 645 | hout->failmsg); |
| 646 | fail_in_htlc(hout->in, failonion); |
| 647 | |
| 648 | /* here we haven't called connect_htlc_out(), |
| 649 | * so set htlc field with NULL (db wants it to exist!) */ |
nothing calls this directly
no test coverage detected