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)
This commit is contained in:
@@ -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]
|
failure_msg = decrypted_error_packet[34:34+failure_len]
|
||||||
# create failure message object
|
# create failure message object
|
||||||
failure_code = int.from_bytes(failure_msg[:2], byteorder='big')
|
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:]
|
failure_data = failure_msg[2:]
|
||||||
return OnionRoutingFailureMessage(failure_code, failure_data)
|
return OnionRoutingFailureMessage(failure_code, failure_data)
|
||||||
|
|
||||||
@@ -387,12 +390,6 @@ class OnionFailureCode(IntEnum):
|
|||||||
CHANNEL_DISABLED = UPDATE | 20
|
CHANNEL_DISABLED = UPDATE | 20
|
||||||
EXPIRY_TOO_FAR = 21
|
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
|
# don't use these elsewhere, the names are ambiguous without context
|
||||||
del BADONION; del PERM; del NODE; del UPDATE
|
del BADONION; del PERM; del NODE; del UPDATE
|
||||||
|
|||||||
Reference in New Issue
Block a user