Skip to content

Commit aaa5c86

Browse files
committed
f update second check too
1 parent 3538576 commit aaa5c86

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

lightning/src/ln/channel.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ use ln::chan_utils::{CounterpartyCommitmentSecrets, TxCreationKeys, HTLCOutputIn
3232
use ln::chan_utils;
3333
use chain::BestBlock;
3434
use chain::chaininterface::{FeeEstimator,ConfirmationTarget};
35-
use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateStep, HTLC_FAIL_BACK_BUFFER};
35+
use chain::channelmonitor::{ChannelMonitor, ChannelMonitorUpdate, ChannelMonitorUpdateStep, LATENCY_GRACE_PERIOD_BLOCKS};
3636
use chain::transaction::{OutPoint, TransactionData};
3737
use chain::keysinterface::{Sign, KeysInterface};
3838
use util::ser::{Readable, ReadableArgs, Writeable, Writer, VecWriter};
@@ -4107,7 +4107,10 @@ impl<Signer: Sign> Channel<Signer> {
41074107
pub fn best_block_updated<L: Deref>(&mut self, height: u32, highest_header_time: u32, logger: &L)
41084108
-> Result<(Option<msgs::FundingLocked>, Vec<(HTLCSource, PaymentHash)>), msgs::ErrorMessage> where L::Target: Logger {
41094109
let mut timed_out_htlcs = Vec::new();
4110-
let unforwarded_htlc_cltv_limit = height + HTLC_FAIL_BACK_BUFFER;
4110+
// This mirrors the check in ChannelManager::decode_update_add_htlc_onion, refusing to
4111+
// forward an HTLC when our counterparty should almost certainly just fail it for expiring
4112+
// ~now.
4113+
let unforwarded_htlc_cltv_limit = height + LATENCY_GRACE_PERIOD_BLOCKS;
41114114
self.holding_cell_htlc_updates.retain(|htlc_update| {
41124115
match htlc_update {
41134116
&HTLCUpdateAwaitingACK::AddHTLC { ref payment_hash, ref source, ref cltv_expiry, .. } => {

lightning/src/ln/functional_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4056,7 +4056,7 @@ fn do_test_holding_cell_htlc_add_timeouts(forwarded_htlc: bool) {
40564056
check_added_monitors!(nodes[1], 0);
40574057
}
40584058

4059-
connect_blocks(&nodes[1], TEST_FINAL_CLTV - CLTV_CLAIM_BUFFER - LATENCY_GRACE_PERIOD_BLOCKS);
4059+
connect_blocks(&nodes[1], TEST_FINAL_CLTV - LATENCY_GRACE_PERIOD_BLOCKS);
40604060
assert!(nodes[1].node.get_and_clear_pending_msg_events().is_empty());
40614061
assert!(nodes[1].node.get_and_clear_pending_events().is_empty());
40624062
connect_blocks(&nodes[1], 1);

0 commit comments

Comments
 (0)