@@ -2938,7 +2938,7 @@ where
2938
2938
// payment logic has enough time to fail the HTLC backward before our onchain logic triggers a
2939
2939
// channel closure (see HTLC_FAIL_BACK_BUFFER rationale).
2940
2940
let current_height: u32 = self.best_block.read().unwrap().height();
2941
- if (outgoing_cltv_value as u64) <= current_height as u64 + HTLC_FAIL_BACK_BUFFER as u64 + 1 {
2941
+ if (cltv_expiry as u64) <= current_height as u64 + HTLC_FAIL_BACK_BUFFER as u64 + 1 {
2942
2942
let mut err_data = Vec::with_capacity(12);
2943
2943
err_data.extend_from_slice(&amt_msat.to_be_bytes());
2944
2944
err_data.extend_from_slice(¤t_height.to_be_bytes());
@@ -11054,6 +11054,26 @@ mod tests {
11054
11054
sender_intended_amt_msat - extra_fee_msat, 42, None, true, Some(extra_fee_msat)).is_ok());
11055
11055
}
11056
11056
11057
+ #[test]
11058
+ fn test_final_incorrect_cltv(){
11059
+ let chanmon_cfg = create_chanmon_cfgs(1);
11060
+ let node_cfg = create_node_cfgs(1, &chanmon_cfg);
11061
+ let node_chanmgr = create_node_chanmgrs(1, &node_cfg, &[None]);
11062
+ let node = create_network(1, &node_cfg, &node_chanmgr);
11063
+
11064
+ let result = node[0].node.construct_recv_pending_htlc_info(msgs::InboundOnionPayload::Receive {
11065
+ amt_msat: 100,
11066
+ outgoing_cltv_value: 22,
11067
+ payment_metadata: None,
11068
+ keysend_preimage: None,
11069
+ payment_data: Some(msgs::FinalOnionHopData {
11070
+ payment_secret: PaymentSecret([0; 32]), total_msat: 100,
11071
+ }),
11072
+ custom_tlvs: Vec::new(),
11073
+ }, [0; 32], PaymentHash([0; 32]), 100, 23, None, true, None);
11074
+ assert!(!result.is_err());
11075
+ }
11076
+
11057
11077
#[test]
11058
11078
fn test_inbound_anchors_manual_acceptance() {
11059
11079
// Tests that we properly limit inbound channels when we have the manual-channel-acceptance
0 commit comments