Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 480
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
27b132181fb07d5e9ae6b935ffdeFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
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", | ||
| ||
| 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.
Uh oh!There was an error while loading. Please reload this page. | ||
| 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.
Uh oh!
There was an error while loading. Please reload this page.