Skip to content

Commit 3b09db8

Browse files
author
Antoine Riard
committed
Move BREAKDOWN_TIMEOUT/MAX_LOCAL_BREAKDOWN_TIMEOUT in ChannelManager
Let these values being used as default ones in UserConfig. Also, reduce them to something more reasonable, for BREAKDOWN_TIMEOUT from 1 week to 1 day, for MAX_LOCAL_BREAKDOWN_TIMEOUT from 2 weeks to 1.
1 parent 3f409a8 commit 3b09db8

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

src/ln/channel.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use secp256k1;
1818
use ln::msgs;
1919
use ln::msgs::{DecodeError, OptionalField, LocalFeatures};
2020
use ln::channelmonitor::ChannelMonitor;
21-
use ln::channelmanager::{PendingHTLCStatus, HTLCSource, HTLCFailReason, HTLCFailureMsg, PendingForwardHTLCInfo, RAACommitmentOrder, PaymentPreimage, PaymentHash};
21+
use ln::channelmanager::{PendingHTLCStatus, HTLCSource, HTLCFailReason, HTLCFailureMsg, PendingForwardHTLCInfo, RAACommitmentOrder, PaymentPreimage, PaymentHash, BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT};
2222
use ln::chan_utils::{TxCreationKeys,HTLCOutputInCommitment,HTLC_SUCCESS_TX_WEIGHT,HTLC_TIMEOUT_TX_WEIGHT};
2323
use ln::chan_utils;
2424
use chain::chaininterface::{FeeEstimator,ConfirmationTarget};
@@ -347,14 +347,6 @@ pub const OUR_MAX_HTLCS: u16 = 50; //TODO
347347
/// on ice until the funding transaction gets more confirmations, but the LN protocol doesn't
348348
/// really allow for this, so instead we're stuck closing it out at that point.
349349
const UNCONF_THRESHOLD: u32 = 6;
350-
/// The amount of time we require our counterparty wait to claim their money (ie time between when
351-
/// we, or our watchtower, must check for them having broadcast a theft transaction).
352-
#[cfg(not(test))]
353-
const BREAKDOWN_TIMEOUT: u16 = 6 * 24 * 7; //TODO?
354-
#[cfg(test)]
355-
pub const BREAKDOWN_TIMEOUT: u16 = 6 * 24 * 7; //TODO?
356-
/// The amount of time we're willing to wait to claim money back to us
357-
const MAX_LOCAL_BREAKDOWN_TIMEOUT: u16 = 6 * 24 * 14;
358350
/// Exposing these two constants for use in test in ChannelMonitor
359351
pub const COMMITMENT_TX_BASE_WEIGHT: u64 = 724;
360352
pub const COMMITMENT_TX_WEIGHT_PER_HTLC: u64 = 172;

src/ln/channelmanager.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,12 @@ pub struct ChannelManager {
341341
logger: Arc<Logger>,
342342
}
343343

344+
/// The amount of time we require our counterparty wait to claim their money (ie time between when
345+
/// we, or our watchtower, must check for them having broadcast a theft transaction).
346+
pub(crate) const BREAKDOWN_TIMEOUT: u16 = 6 * 24;
347+
/// The amount of time we're willing to wait to claim money back to us
348+
pub(crate) const MAX_LOCAL_BREAKDOWN_TIMEOUT: u16 = 6 * 24 * 7;
349+
344350
/// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound
345351
/// HTLC's CLTV. This should always be a few blocks greater than channelmonitor::CLTV_CLAIM_BUFFER,
346352
/// ie the node we forwarded the payment on to should always have enough room to reliably time out

src/ln/functional_tests.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
use chain::transaction::OutPoint;
66
use chain::chaininterface::{ChainListener, ChainWatchInterface};
77
use chain::keysinterface::{KeysInterface, SpendableOutputDescriptor};
8-
use ln::channel::{COMMITMENT_TX_BASE_WEIGHT, COMMITMENT_TX_WEIGHT_PER_HTLC, BREAKDOWN_TIMEOUT};
9-
use ln::channelmanager::{ChannelManager,ChannelManagerReadArgs,HTLCForwardInfo,RAACommitmentOrder, PaymentPreimage, PaymentHash};
8+
use ln::channel::{COMMITMENT_TX_BASE_WEIGHT, COMMITMENT_TX_WEIGHT_PER_HTLC};
9+
use ln::channelmanager::{ChannelManager,ChannelManagerReadArgs,HTLCForwardInfo,RAACommitmentOrder, PaymentPreimage, PaymentHash, BREAKDOWN_TIMEOUT};
1010
use ln::channelmonitor::{ChannelMonitor, CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS, ManyChannelMonitor, ANTI_REORG_DELAY};
1111
use ln::channel::{ACCEPTED_HTLC_SCRIPT_WEIGHT, OFFERED_HTLC_SCRIPT_WEIGHT};
1212
use ln::onion_utils;

0 commit comments

Comments
 (0)