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

Function handle_peer_fail_htlc

channeld/channeld.c:2691–2728  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2689}
2690
2691static 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
2730static void handle_peer_fail_malformed_htlc(struct peer *peer, const u8 *msg)
2731{

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