| 1931 | } |
| 1932 | |
| 1933 | static void handle_peer_fail_htlc(struct peer *peer, const u8 *msg) |
| 1934 | { |
| 1935 | struct channel_id channel_id; |
| 1936 | u64 id; |
| 1937 | enum channel_remove_err e; |
| 1938 | u8 *reason; |
| 1939 | struct htlc *htlc; |
| 1940 | struct failed_htlc *f; |
| 1941 | |
| 1942 | /* reason is not an onionreply because spec doesn't know about that */ |
| 1943 | if (!fromwire_update_fail_htlc(msg, msg, |
| 1944 | &channel_id, &id, &reason)) { |
| 1945 | peer_failed_warn(peer->pps, &peer->channel_id, |
| 1946 | "Bad update_fail_htlc %s", tal_hex(msg, msg)); |
| 1947 | } |
| 1948 | |
| 1949 | e = channel_fail_htlc(peer->channel, LOCAL, id, &htlc); |
| 1950 | switch (e) { |
| 1951 | case CHANNEL_ERR_REMOVE_OK: { |
| 1952 | htlc->failed = f = tal(htlc, struct failed_htlc); |
| 1953 | f->id = id; |
| 1954 | f->sha256_of_onion = NULL; |
| 1955 | f->onion = new_onionreply(f, take(reason)); |
| 1956 | start_commit_timer(peer); |
| 1957 | return; |
| 1958 | } |
| 1959 | case CHANNEL_ERR_NO_SUCH_ID: |
| 1960 | case CHANNEL_ERR_ALREADY_FULFILLED: |
| 1961 | case CHANNEL_ERR_HTLC_UNCOMMITTED: |
| 1962 | case CHANNEL_ERR_HTLC_NOT_IRREVOCABLE: |
| 1963 | case CHANNEL_ERR_BAD_PREIMAGE: |
| 1964 | peer_failed_warn(peer->pps, &peer->channel_id, |
| 1965 | "Bad update_fail_htlc: failed to remove %" |
| 1966 | PRIu64 " error %s", id, |
| 1967 | channel_remove_err_name(e)); |
| 1968 | } |
| 1969 | abort(); |
| 1970 | } |
| 1971 | |
| 1972 | static void handle_peer_fail_malformed_htlc(struct peer *peer, const u8 *msg) |
| 1973 | { |
no test coverage detected