This is where channeld gives us the HTLC id, and also reports if it * failed immediately. */
| 634 | /* This is where channeld gives us the HTLC id, and also reports if it |
| 635 | * failed immediately. */ |
| 636 | static void rcvd_htlc_reply(struct subd *subd, const u8 *msg, const int *fds UNUSED, |
| 637 | struct htlc_out *hout) |
| 638 | { |
| 639 | u8 *failmsg; |
| 640 | char *failurestr; |
| 641 | struct lightningd *ld = subd->ld; |
| 642 | |
| 643 | if (!fromwire_channeld_offer_htlc_reply(msg, msg, |
| 644 | &hout->key.id, |
| 645 | &failmsg, |
| 646 | &failurestr)) { |
| 647 | channel_internal_error(subd->channel, |
| 648 | "Bad channel_offer_htlc_reply"); |
| 649 | tal_free(hout); |
| 650 | return; |
| 651 | } |
| 652 | |
| 653 | if (tal_count(failmsg)) { |
| 654 | /* BOLT #4: |
| 655 | * The `channel_update` field used to be mandatory in messages |
| 656 | * whose `failure_code` includes the `UPDATE` flag. However, |
| 657 | * because nodes applying an update contained in the onion to |
| 658 | * their gossip data is a massive fingerprinting |
| 659 | * vulnerability, the `channel_update` field is no longer |
| 660 | * mandatory and nodes are expected to transition away from |
| 661 | * including it. Nodes which do not provide a `channel_update` |
| 662 | * are expected to set the `channel_update` `len` field to |
| 663 | * zero. |
| 664 | */ |
| 665 | /* We still append the channel_update (if we have one!) FIXME: provide an option? */ |
| 666 | if (fromwire_peektype(failmsg) & UPDATE) { |
| 667 | const u8 *update = channel_update_for_error(tmpctx, hout->in, hout->key.channel); |
| 668 | towire(&failmsg, update, tal_bytelen(update)); |
| 669 | } |
| 670 | hout->failmsg = tal_steal(hout, failmsg); |
| 671 | if (hout->am_origin) { |
| 672 | char *localfail = tal_fmt(msg, "%s: %s", |
| 673 | onion_wire_name(fromwire_peektype(failmsg)), |
| 674 | failurestr); |
| 675 | payment_failed(ld, |
| 676 | hout->key.channel->log, |
| 677 | &hout->payment_hash, |
| 678 | hout->partid, |
| 679 | hout->groupid, |
| 680 | hout->failonion, |
| 681 | hout->failmsg, |
| 682 | localfail); |
| 683 | } else if (hout->in) { |
| 684 | struct onionreply *failonion; |
| 685 | struct short_channel_id scid; |
| 686 | |
| 687 | failonion = create_onionreply(hout, |
| 688 | hout->in->shared_secret, |
| 689 | hout->failmsg); |
| 690 | fail_in_htlc(hout->in, failonion); |
| 691 | |
| 692 | /* here we haven't called connect_htlc_out(), |
| 693 | * so set htlc field with NULL (db wants it to exist!) */ |
nothing calls this directly
no test coverage detected