Browse Source

fix #6200: if we cannot parse an onion, send a failure code that has the BADONION bit

master
ThomasV 5 years ago
parent
commit
2571669a32
  1. 9
      electrum/lnpeer.py

9
electrum/lnpeer.py

@ -1534,7 +1534,6 @@ class Peer(Logger):
onion_packet_bytes = bytes.fromhex(onion_packet_hex)
onion_packet = None
try:
if self.network.config.get('test_fail_malformed_htlc'): raise InvalidOnionPubkey()
onion_packet = OnionPacket.from_bytes(onion_packet_bytes)
processed_onion = process_onion_packet(onion_packet, associated_data=payment_hash, our_onion_private_key=self.privkey)
except UnsupportedOnionPacketVersion:
@ -1545,11 +1544,15 @@ class Peer(Logger):
error_reason = OnionRoutingFailureMessage(code=OnionFailureCode.INVALID_ONION_HMAC, data=sha256(onion_packet_bytes))
except Exception as e:
self.logger.info(f"error processing onion packet: {e!r}")
error_reason = OnionRoutingFailureMessage(code=OnionFailureCode.TEMPORARY_NODE_FAILURE, data=b'')
error_reason = OnionRoutingFailureMessage(code=OnionFailureCode.INVALID_ONION_VERSION, data=sha256(onion_packet_bytes))
else:
if self.network.config.get('test_fail_malformed_htlc'):
error_reason = OnionRoutingFailureMessage(code=OnionFailureCode.INVALID_ONION_VERSION, data=sha256(onion_packet_bytes))
if self.network.config.get('test_fail_htlcs_with_temp_node_failure'):
error_reason = OnionRoutingFailureMessage(code=OnionFailureCode.TEMPORARY_NODE_FAILURE, data=b'')
elif processed_onion.are_we_final:
if not error_reason:
if processed_onion.are_we_final:
preimage, error_reason = self.maybe_fulfill_htlc(
chan=chan,
htlc=htlc,

Loading…
Cancel
Save