MCPcopy Create free account
hub / github.com/ElementsProject/lightning / handle_peer_fail_htlc

Function handle_peer_fail_htlc

channeld/channeld.c:1933–1970  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1931}
1932
1933static 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
1972static void handle_peer_fail_malformed_htlc(struct peer *peer, const u8 *msg)
1973{

Callers 1

peer_inFunction · 0.85

Calls 7

peer_failed_warnFunction · 0.85
tal_hexFunction · 0.85
channel_fail_htlcFunction · 0.85
start_commit_timerFunction · 0.85
channel_remove_err_nameFunction · 0.85
abortFunction · 0.85
new_onionreplyFunction · 0.50

Tested by

no test coverage detected