electrum

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

commit 2a604b1676680859d5ddb84f132ec39a6c1b5c80
parent c37d08cec9c5c9fbc473151b2b77343cefeae7c9
Author: SomberNight <somber.night@protonmail.com>
Date:   Sat, 12 Oct 2019 00:05:38 +0200

lnonion: get_failure_msg_from_onion_error might raise in python 3.7

this used to work in py3.6 but raises in py3.7 :(
(see https://bugs.python.org/issue34536)

Diffstat:
Melectrum/lnonion.py | 11++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/electrum/lnonion.py b/electrum/lnonion.py @@ -348,7 +348,10 @@ def get_failure_msg_from_onion_error(decrypted_error_packet: bytes) -> OnionRout failure_msg = decrypted_error_packet[34:34+failure_len] # create failure message object failure_code = int.from_bytes(failure_msg[:2], byteorder='big') - failure_code = OnionFailureCode(failure_code) + try: + failure_code = OnionFailureCode(failure_code) + except ValueError: + pass # uknown failure code failure_data = failure_msg[2:] return OnionRoutingFailureMessage(failure_code, failure_data) @@ -387,12 +390,6 @@ class OnionFailureCode(IntEnum): CHANNEL_DISABLED = UPDATE | 20 EXPIRY_TOO_FAR = 21 - @classmethod - def _missing_(cls, value: int) -> int: - # note that for unknown error codes, we return an int, - # not an instance of cls - return value - # don't use these elsewhere, the names are ambiguous without context del BADONION; del PERM; del NODE; del UPDATE