Skip to content

Commit e83e89c

Browse files
committed
fixup! Allow forwarding HTLCs that were constructed for previous config
1 parent 520a26a commit e83e89c

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

lightning/src/ln/channel.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -4578,15 +4578,14 @@ impl<Signer: Sign> Channel<Signer> {
45784578
pub fn htlc_satisfies_config(
45794579
&self, htlc: &msgs::UpdateAddHTLC, amt_to_forward: u64, outgoing_cltv_value: u32,
45804580
) -> Result<(), (&'static str, u16)> {
4581-
let res = self.internal_htlc_satisfies_config(&htlc, amt_to_forward, outgoing_cltv_value, &self.config());
4582-
if res.is_ok() {
4583-
return res;
4584-
}
4585-
if let Some(prev_config) = self.prev_config() {
4586-
self.internal_htlc_satisfies_config(htlc, amt_to_forward, outgoing_cltv_value, &prev_config)
4587-
} else {
4588-
res
4589-
}
4581+
self.internal_htlc_satisfies_config(&htlc, amt_to_forward, outgoing_cltv_value, &self.config())
4582+
.or_else(|err| {
4583+
if let Some(prev_config) = self.prev_config() {
4584+
self.internal_htlc_satisfies_config(htlc, amt_to_forward, outgoing_cltv_value, &prev_config)
4585+
} else {
4586+
Err(err)
4587+
}
4588+
})
45904589
}
45914590

45924591
pub fn get_feerate(&self) -> u32 {

lightning/src/ln/channelmanager.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -2261,7 +2261,15 @@ impl<Signer: Sign, M: Deref, T: Deref, K: Deref, F: Deref, L: Deref> ChannelMana
22612261
break Some((err, code, chan_update_opt));
22622262
}
22632263
chan_update_opt
2264-
} else { None };
2264+
} else {
2265+
if (msg.cltv_expiry as u64) < (*outgoing_cltv_value) as u64 + MIN_CLTV_EXPIRY_DELTA as u64 { // incorrect_cltv_expiry
2266+
break Some((
2267+
"Forwarding node has tampered with the intended HTLC values or origin node has an obsolete cltv_expiry_delta",
2268+
0x1000 | 13, None,
2269+
));
2270+
}
2271+
None
2272+
};
22652273

22662274
let cur_height = self.best_block.read().unwrap().height() + 1;
22672275
// Theoretically, channel counterparty shouldn't send us a HTLC expiring now,

0 commit comments

Comments
 (0)