1
0

lnpeer: use INVALID_ONION_VERSION for unparsable onions

Use the `OnionFailureCode.INVALID_ONION_VERSION` (BADONION | PERM | 4)
code when sending back `update_fail_malformed_htlc` as just sending a plain
`BADONION` is not explicitly mentioned as correct in the spec.
This commit is contained in:
f321x
2025-11-26 13:42:20 +01:00
parent 1fd5458b0e
commit 16ed7e666c
2 changed files with 10 additions and 4 deletions

View File

@@ -577,7 +577,14 @@ class OnionRoutingFailure(Exception):
return error_bytes
class OnionParsingError(OnionRoutingFailure): pass
class OnionParsingError(OnionRoutingFailure):
"""
Onion parsing error will cause a htlc to get failed with update_fail_malformed_htlc.
Using INVALID_ONION_VERSION as there is no unspecific BADONION failure code defined in the spec
for the case we just cannot parse the onion.
"""
def __init__(self, data: bytes):
OnionRoutingFailure.__init__(self, code=OnionFailureCode.INVALID_ONION_VERSION, data=data)
def construct_onion_error(