def handle_error_code_from_failed_htlc(self, *, route: LNPaymentRoute, sender_idx: int, failure_msg: OnionRoutingFailure, amount: int) -> None:
    (code, data) = (failure_msg.code, failure_msg.data)
    failure_codes = {OnionFailureCode.TEMPORARY_CHANNEL_FAILURE: 0, OnionFailureCode.AMOUNT_BELOW_MINIMUM: 8, OnionFailureCode.FEE_INSUFFICIENT: 8, OnionFailureCode.INCORRECT_CLTV_EXPIRY: 4, OnionFailureCode.EXPIRY_TOO_SOON: 0, OnionFailureCode.CHANNEL_DISABLED: 2}
    if (sender_idx is None):
        raise PaymentFailure(failure_msg.code_name())
    try:
        fallback_channel = route[(sender_idx + 1)].short_channel_id
    except IndexError:
        raise PaymentFailure(f'payment destination reported error: {failure_msg.code_name()}') from None
    if (code in failure_codes):
        offset = failure_codes[code]
        channel_update_len = int.from_bytes(data[offset:(offset + 2)], byteorder='big')
        channel_update_as_received = data[(offset + 2):((offset + 2) + channel_update_len)]
        payload = self._decode_channel_update_msg(channel_update_as_received)
        if (payload is None):
            self.logger.info(f'could not decode channel_update for failed htlc: {channel_update_as_received.hex()}')
            self.network.path_finder.liquidity_hints.add_to_blacklist(fallback_channel)
        else:
            (blacklist, update) = self._handle_chanupd_from_failed_htlc(payload, route=route, sender_idx=sender_idx)
            if (code == OnionFailureCode.TEMPORARY_CHANNEL_FAILURE):
                self.network.path_finder.update_liquidity_hints(route, amount, failing_channel=ShortChannelID(payload['short_channel_id']))
            elif blacklist:
                self.network.path_finder.liquidity_hints.add_to_blacklist(payload['short_channel_id'])
            if (not (blacklist or update)):
                raise PaymentFailure(failure_msg.code_name())
    else:
        self.network.path_finder.liquidity_hints.add_to_blacklist(fallback_channel)
def handle_error_code_from_failed_htlc(self, *, route: LNPaymentRoute, sender_idx: int, failure_msg: OnionRoutingFailure, amount: int) -> None:
    (code, data) = (failure_msg.code, failure_msg.data)
    failure_codes = {OnionFailureCode.TEMPORARY_CHANNEL_FAILURE: 0, OnionFailureCode.AMOUNT_BELOW_MINIMUM: 8, OnionFailureCode.FEE_INSUFFICIENT: 8, OnionFailureCode.INCORRECT_CLTV_EXPIRY: 4, OnionFailureCode.EXPIRY_TOO_SOON: 0, OnionFailureCode.CHANNEL_DISABLED: 2}
    if (sender_idx is None):
        raise PaymentFailure(failure_msg.code_name())
    try:
        fallback_channel = route[(sender_idx + 1)].short_channel_id
    except IndexError:
        raise PaymentFailure(f'payment destination reported error: {failure_msg.code_name()}') from None
    if (code in failure_codes):
        offset = failure_codes[code]
        channel_update_len = int.from_bytes(data[offset:(offset + 2)], byteorder='big')
        channel_update_as_received = data[(offset + 2):((offset + 2) + channel_update_len)]
        payload = self._decode_channel_update_msg(channel_update_as_received)
        if (payload is None):
            self.logger.info(f'could not decode channel_update for failed htlc: {channel_update_as_received.hex()}')
            self.network.path_finder.liquidity_hints.add_to_blacklist(fallback_channel)
        else:
            (blacklist, update) = self._handle_chanupd_from_failed_htlc(payload, route=route, sender_idx=sender_idx)
            if (code == OnionFailureCode.TEMPORARY_CHANNEL_FAILURE):
                self.network.path_finder.update_liquidity_hints(route, amount, failing_channel=ShortChannelID(payload['short_channel_id']))
            elif blacklist:
                self.network.path_finder.liquidity_hints.add_to_blacklist(payload['short_channel_id'])
            if (not (blacklist or update)):
                raise PaymentFailure(failure_msg.code_name())
    else:
        self.network.path_finder.liquidity_hints.add_to_blacklist(fallback_channel)