|
|
@ -1242,6 +1242,33 @@ class LNWallet(LNWorker): |
|
|
|
self.logger.info(f'could not decode channel_update for failed htlc: {channel_update_as_received.hex()}') |
|
|
|
blacklist = True |
|
|
|
else: |
|
|
|
blacklist, update = self._handle_chanupd_from_failed_htlc( |
|
|
|
payload, route=route, sender_idx=sender_idx) |
|
|
|
else: |
|
|
|
blacklist = True |
|
|
|
|
|
|
|
if blacklist: |
|
|
|
# blacklist channel after reporter node |
|
|
|
# TODO this should depend on the error (even more granularity) |
|
|
|
# also, we need finer blacklisting (directed edges; nodes) |
|
|
|
if sender_idx is None: |
|
|
|
raise PaymentFailure(failure_msg.code_name()) |
|
|
|
try: |
|
|
|
short_chan_id = route[sender_idx + 1].short_channel_id |
|
|
|
except IndexError: |
|
|
|
raise PaymentFailure('payment destination reported error') |
|
|
|
# TODO: for MPP we need to save the amount for which |
|
|
|
# we saw temporary channel failure |
|
|
|
self.logger.info(f'blacklisting channel {short_chan_id}') |
|
|
|
self.network.channel_blacklist.add(short_chan_id) |
|
|
|
|
|
|
|
# we should not continue if we did not blacklist or update anything |
|
|
|
if not (blacklist or update): |
|
|
|
raise PaymentFailure(failure_msg.code_name()) |
|
|
|
|
|
|
|
def _handle_chanupd_from_failed_htlc(self, payload, *, route, sender_idx) -> Tuple[bool, bool]: |
|
|
|
blacklist = False |
|
|
|
update = False |
|
|
|
r = self.channel_db.add_channel_update(payload) |
|
|
|
short_channel_id = ShortChannelID(payload['short_channel_id']) |
|
|
|
if r == UpdateStatus.GOOD: |
|
|
@ -1264,27 +1291,7 @@ class LNWallet(LNWorker): |
|
|
|
blacklist = True |
|
|
|
elif r == UpdateStatus.UNCHANGED: |
|
|
|
blacklist = True |
|
|
|
else: |
|
|
|
blacklist = True |
|
|
|
|
|
|
|
if blacklist: |
|
|
|
# blacklist channel after reporter node |
|
|
|
# TODO this should depend on the error (even more granularity) |
|
|
|
# also, we need finer blacklisting (directed edges; nodes) |
|
|
|
if sender_idx is None: |
|
|
|
raise PaymentFailure(failure_msg.code_name()) |
|
|
|
try: |
|
|
|
short_chan_id = route[sender_idx + 1].short_channel_id |
|
|
|
except IndexError: |
|
|
|
raise PaymentFailure('payment destination reported error') |
|
|
|
# TODO: for MPP we need to save the amount for which |
|
|
|
# we saw temporary channel failure |
|
|
|
self.logger.info(f'blacklisting channel {short_chan_id}') |
|
|
|
self.network.channel_blacklist.add(short_chan_id) |
|
|
|
|
|
|
|
# we should not continue if we did not blacklist or update anything |
|
|
|
if not (blacklist or update): |
|
|
|
raise PaymentFailure(failure_msg.code_name()) |
|
|
|
return blacklist, update |
|
|
|
|
|
|
|
@classmethod |
|
|
|
def _decode_channel_update_msg(cls, chan_upd_msg: bytes) -> Optional[Dict[str, Any]]: |
|
|
|