@@ -1411,12 +1411,10 @@ def handle_error_code_from_failed_htlc(
1411
1411
OnionFailureCode .CHANNEL_DISABLED : 2 ,
1412
1412
}
1413
1413
1414
- # determine a fallback channel to blacklist if we don't get the erring
1415
- # channel via the payload
1416
1414
if sender_idx is None :
1417
1415
raise PaymentFailure (failure_msg .code_name ())
1418
1416
try :
1419
- fallback_channel = route [sender_idx + 1 ].short_channel_id
1417
+ failing_channel = route [sender_idx + 1 ].short_channel_id
1420
1418
except IndexError :
1421
1419
raise PaymentFailure (f'payment destination reported error: { failure_msg .code_name ()} ' ) from None
1422
1420
@@ -1427,33 +1425,32 @@ def handle_error_code_from_failed_htlc(
1427
1425
channel_update_len = int .from_bytes (data [offset :offset + 2 ], byteorder = "big" )
1428
1426
channel_update_as_received = data [offset + 2 : offset + 2 + channel_update_len ]
1429
1427
payload = self ._decode_channel_update_msg (channel_update_as_received )
1430
-
1431
1428
if payload is None :
1432
1429
self .logger .info (f'could not decode channel_update for failed htlc: '
1433
1430
f'{ channel_update_as_received .hex ()} ' )
1434
- self .network .path_finder .liquidity_hints .add_to_blacklist (fallback_channel )
1431
+ blacklist = True
1432
+ elif payload .get ('short_channel_id' ) != failing_channel :
1433
+ self .logger .info (f'short_channel_id in channel_update does not match our route' )
1434
+ blacklist = True
1435
1435
else :
1436
1436
# apply the channel update or get blacklisted
1437
1437
blacklist , update = self ._handle_chanupd_from_failed_htlc (
1438
1438
payload , route = route , sender_idx = sender_idx )
1439
-
1440
1439
# we interpret a temporary channel failure as a liquidity issue
1441
1440
# in the channel and update our liquidity hints accordingly
1442
1441
if code == OnionFailureCode .TEMPORARY_CHANNEL_FAILURE :
1443
1442
self .network .path_finder .update_liquidity_hints (
1444
1443
route ,
1445
1444
amount ,
1446
- failing_channel = ShortChannelID (payload ['short_channel_id' ]))
1447
- elif blacklist :
1448
- self .network .path_finder .liquidity_hints .add_to_blacklist (
1449
- payload ['short_channel_id' ])
1450
-
1445
+ failing_channel = ShortChannelID (failing_channel ))
1451
1446
# if we can't decide on some action, we are stuck
1452
1447
if not (blacklist or update ):
1453
1448
raise PaymentFailure (failure_msg .code_name ())
1454
1449
# for errors that do not include a channel update
1455
1450
else :
1456
- self .network .path_finder .liquidity_hints .add_to_blacklist (fallback_channel )
1451
+ blacklist = True
1452
+ if blacklist :
1453
+ self .network .path_finder .liquidity_hints .add_to_blacklist (failing_channel )
1457
1454
1458
1455
def _handle_chanupd_from_failed_htlc (self , payload , * , route , sender_idx ) -> Tuple [bool , bool ]:
1459
1456
blacklist = False
0 commit comments