fix #6200: if we cannot parse an onion, send a failure code that has the BADONION bit
This commit is contained in:
@@ -1534,7 +1534,6 @@ class Peer(Logger):
|
|||||||
onion_packet_bytes = bytes.fromhex(onion_packet_hex)
|
onion_packet_bytes = bytes.fromhex(onion_packet_hex)
|
||||||
onion_packet = None
|
onion_packet = None
|
||||||
try:
|
try:
|
||||||
if self.network.config.get('test_fail_malformed_htlc'): raise InvalidOnionPubkey()
|
|
||||||
onion_packet = OnionPacket.from_bytes(onion_packet_bytes)
|
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)
|
processed_onion = process_onion_packet(onion_packet, associated_data=payment_hash, our_onion_private_key=self.privkey)
|
||||||
except UnsupportedOnionPacketVersion:
|
except UnsupportedOnionPacketVersion:
|
||||||
@@ -1545,11 +1544,15 @@ class Peer(Logger):
|
|||||||
error_reason = OnionRoutingFailureMessage(code=OnionFailureCode.INVALID_ONION_HMAC, data=sha256(onion_packet_bytes))
|
error_reason = OnionRoutingFailureMessage(code=OnionFailureCode.INVALID_ONION_HMAC, data=sha256(onion_packet_bytes))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.info(f"error processing onion packet: {e!r}")
|
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:
|
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'):
|
if self.network.config.get('test_fail_htlcs_with_temp_node_failure'):
|
||||||
error_reason = OnionRoutingFailureMessage(code=OnionFailureCode.TEMPORARY_NODE_FAILURE, data=b'')
|
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(
|
preimage, error_reason = self.maybe_fulfill_htlc(
|
||||||
chan=chan,
|
chan=chan,
|
||||||
htlc=htlc,
|
htlc=htlc,
|
||||||
|
|||||||
Reference in New Issue
Block a user