-
Notifications
You must be signed in to change notification settings - Fork 406
Use LocalHTLCFailureReason in Onion Processing #3744
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
27b1321
81fb07d
5e9ae6b
935ffde
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -453,11 +453,11 @@ where | |
}), | ||
}; | ||
|
||
if let Err((err_msg, reason)) = check_incoming_htlc_cltv( | ||
if let Err(reason) = check_incoming_htlc_cltv( | ||
cur_height, outgoing_cltv_value, msg.cltv_expiry, | ||
) { | ||
return Err(InboundHTLCErr { | ||
msg: err_msg, | ||
msg: "incoming cltv check failed", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just a note here for review: this I think that this is okay because There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems legit 👍 Thanks for the diligence! |
||
reason, | ||
err_data: Vec::new(), | ||
}); | ||
|
@@ -601,19 +601,18 @@ where | |
|
||
pub(super) fn check_incoming_htlc_cltv( | ||
cur_height: u32, outgoing_cltv_value: u32, cltv_expiry: u32 | ||
) -> Result<(), (&'static str, LocalHTLCFailureReason)> { | ||
) -> Result<(), LocalHTLCFailureReason> { | ||
carlaKC marked this conversation as resolved.
Show resolved
Hide resolved
|
||
if (cltv_expiry as u64) < (outgoing_cltv_value) as u64 + MIN_CLTV_EXPIRY_DELTA as u64 { | ||
return Err(("Forwarding node has tampered with the intended HTLC values or origin node has an obsolete cltv_expiry_delta", | ||
LocalHTLCFailureReason::IncorrectCLTVExpiry)); | ||
return Err(LocalHTLCFailureReason::IncorrectCLTVExpiry); | ||
} | ||
// Theoretically, channel counterparty shouldn't send us a HTLC expiring now, | ||
// but we want to be robust wrt to counterparty packet sanitization (see | ||
// HTLC_FAIL_BACK_BUFFER rationale). | ||
if cltv_expiry <= cur_height + HTLC_FAIL_BACK_BUFFER as u32 { | ||
return Err(("CLTV expiry is too close", LocalHTLCFailureReason::CLTVExpiryTooSoon)); | ||
return Err(LocalHTLCFailureReason::CLTVExpiryTooSoon); | ||
} | ||
if cltv_expiry > cur_height + CLTV_FAR_FAR_AWAY as u32 { | ||
return Err(("CLTV expiry is too far in the future", LocalHTLCFailureReason::CLTVExpiryTooFar)); | ||
return Err(LocalHTLCFailureReason::CLTVExpiryTooFar); | ||
} | ||
// If the HTLC expires ~now, don't bother trying to forward it to our | ||
// counterparty. They should fail it anyway, but we don't want to bother with | ||
|
@@ -624,7 +623,7 @@ pub(super) fn check_incoming_htlc_cltv( | |
// but there is no need to do that, and since we're a bit conservative with our | ||
// risk threshold it just results in failing to forward payments. | ||
if (outgoing_cltv_value) as u64 <= (cur_height + LATENCY_GRACE_PERIOD_BLOCKS) as u64 { | ||
return Err(("Outgoing CLTV value is too soon", LocalHTLCFailureReason::OutgoingCLTVTooSoon)); | ||
return Err(LocalHTLCFailureReason::OutgoingCLTVTooSoon); | ||
} | ||
|
||
Ok(()) | ||
|
Uh oh!
There was an error while loading. Please reload this page.