| 2689 | } |
| 2690 | |
| 2691 | static void handle_peer_fail_htlc(struct peer *peer, const u8 *msg) |
| 2692 | { |
| 2693 | struct channel_id channel_id; |
| 2694 | u64 id; |
| 2695 | enum channel_remove_err e; |
| 2696 | u8 *reason; |
| 2697 | struct htlc *htlc; |
| 2698 | struct failed_htlc *f; |
| 2699 | |
| 2700 | /* reason is not an onionreply because spec doesn't know about that */ |
| 2701 | if (!fromwire_update_fail_htlc(msg, msg, |
| 2702 | &channel_id, &id, &reason)) { |
| 2703 | peer_failed_warn(peer->pps, &peer->channel_id, |
| 2704 | "Bad update_fail_htlc %s", tal_hex(msg, msg)); |
| 2705 | } |
| 2706 | |
| 2707 | e = channel_fail_htlc(peer->channel, LOCAL, id, &htlc); |
| 2708 | switch (e) { |
| 2709 | case CHANNEL_ERR_REMOVE_OK: { |
| 2710 | htlc->failed = f = tal(htlc, struct failed_htlc); |
| 2711 | f->id = id; |
| 2712 | f->sha256_of_onion = NULL; |
| 2713 | f->onion = new_onionreply(f, take(reason)); |
| 2714 | start_commit_timer(peer); |
| 2715 | return; |
| 2716 | } |
| 2717 | case CHANNEL_ERR_NO_SUCH_ID: |
| 2718 | case CHANNEL_ERR_ALREADY_FULFILLED: |
| 2719 | case CHANNEL_ERR_HTLC_UNCOMMITTED: |
| 2720 | case CHANNEL_ERR_HTLC_NOT_IRREVOCABLE: |
| 2721 | case CHANNEL_ERR_BAD_PREIMAGE: |
| 2722 | peer_failed_warn(peer->pps, &peer->channel_id, |
| 2723 | "Bad update_fail_htlc: failed to remove %" |
| 2724 | PRIu64 " error %s", id, |
| 2725 | channel_remove_err_name(e)); |
| 2726 | } |
| 2727 | abort(); |
| 2728 | } |
| 2729 | |
| 2730 | static void handle_peer_fail_malformed_htlc(struct peer *peer, const u8 *msg) |
| 2731 | { |
no test coverage detected