electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 2571669a32e62af08f759ca8c826a9095289e6ef
parent 47b3c49b2563da70112acd2773671fb621f23326
Author: ThomasV <thomasv@electrum.org>
Date:   Fri,  5 Jun 2020 12:31:04 +0200

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

Diffstat:
Melectrum/lnpeer.py | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/electrum/lnpeer.py b/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,