electrum

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

commit 1ebd1baebf50ce7aacd61e6ba6d288d1a0b8d860
parent 8d4a5bd1d7d53015cfcfb96b0d3c8e8e8f7a0e9e
Author: ThomasV <thomasv@electrum.org>
Date:   Wed, 10 Oct 2018 10:29:57 +0200

follow-up 1c8a4bcfa497b117e4511c2f108dbca8a1adb793

Diffstat:
Melectrum/lnbase.py | 33+++++++++++----------------------
1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/electrum/lnbase.py b/electrum/lnbase.py @@ -1042,28 +1042,17 @@ class Peer(PrintError): data = failure_msg.data self.print_error("UPDATE_FAIL_HTLC", repr(code), data) # handle some specific error codes - if code == OnionFailureCode.TEMPORARY_CHANNEL_FAILURE: - channel_update = (258).to_bytes(length=2, byteorder="big") + data[2:] - message_type, payload = decode_msg(channel_update) - self.on_channel_update(payload) - elif code == OnionFailureCode.AMOUNT_BELOW_MINIMUM: - channel_update = (258).to_bytes(length=2, byteorder="big") + data[10:] - message_type, payload = decode_msg(channel_update) - self.on_channel_update(payload) - elif code == OnionFailureCode.FEE_INSUFFICIENT: - channel_update = (258).to_bytes(length=2, byteorder="big") + data[10:] - message_type, payload = decode_msg(channel_update) - self.on_channel_update(payload) - elif code == OnionFailureCode.INCORRECT_CLTV_EXPIRY: - channel_update = (258).to_bytes(length=2, byteorder="big") + data[6:] - message_type, payload = decode_msg(channel_update) - self.on_channel_update(payload) - elif code == OnionFailureCode.EXPIRY_TOO_SOON: - channel_update = (258).to_bytes(length=2, byteorder="big") + data[2:] - message_type, payload = decode_msg(channel_update) - self.on_channel_update(payload) - elif code == OnionFailureCode.CHANNEL_DISABLED: - channel_update = (258).to_bytes(length=2, byteorder="big") + data[4:] + failure_codes = { + OnionFailureCode.TEMPORARY_CHANNEL_FAILURE: 2 + OnionFailureCode.AMOUNT_BELOW_MINIMUM: 10 + OnionFailureCode.FEE_INSUFFICIENT: 10 + OnionFailureCode.INCORRECT_CLTV_EXPIRY: 6 + OnionFailureCode.EXPIRY_TOO_SOON: 2 + OnionFailureCode.CHANNEL_DISABLED: 4 + } + offset = failure_codes.get(code) + if offset: + channel_update = (258).to_bytes(length=2, byteorder="big") + data[offset:] message_type, payload = decode_msg(channel_update) self.on_channel_update(payload) else: