simplify maybe_fulfill_htlc
- move some checks in two helper methods:
- invariant checks are performed in check_accepted_htlc
- mpp checks are performed in check_mpp_is waiting
- in order to avoid passing local_height to check_accepted_htlc,
the height in the error message is added by create_onion_error.
This commit is contained in:
@@ -391,12 +391,16 @@ class OnionRoutingFailure(Exception):
|
||||
|
||||
|
||||
def construct_onion_error(
|
||||
reason: OnionRoutingFailure,
|
||||
error: OnionRoutingFailure,
|
||||
their_public_key: bytes,
|
||||
our_onion_private_key: bytes,
|
||||
local_height: int
|
||||
) -> bytes:
|
||||
# add local height
|
||||
if error.code == OnionFailureCode.INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS:
|
||||
error.data += local_height.to_bytes(4, byteorder="big")
|
||||
# create payload
|
||||
failure_msg = reason.to_bytes()
|
||||
failure_msg = error.to_bytes()
|
||||
failure_len = len(failure_msg)
|
||||
pad_len = 256 - failure_len
|
||||
assert pad_len >= 0
|
||||
|
||||
Reference in New Issue
Block a user