From 3b09db80eaff12af791e28eddb03f3b44957ab5f Mon Sep 17 00:00:00 2001 From: Antoine Riard Date: Fri, 19 Jul 2019 19:36:23 -0400 Subject: [PATCH] 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. --- src/ln/channel.rs | 10 +--------- src/ln/channelmanager.rs | 6 ++++++ src/ln/functional_tests.rs | 4 ++-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/ln/channel.rs b/src/ln/channel.rs index 4d790cfc..4afcbefe 100644 --- a/src/ln/channel.rs +++ b/src/ln/channel.rs @@ -18,7 +18,7 @@ use secp256k1; use ln::msgs; use ln::msgs::{DecodeError, OptionalField, LocalFeatures}; use ln::channelmonitor::ChannelMonitor; -use ln::channelmanager::{PendingHTLCStatus, HTLCSource, HTLCFailReason, HTLCFailureMsg, PendingForwardHTLCInfo, RAACommitmentOrder, PaymentPreimage, PaymentHash}; +use ln::channelmanager::{PendingHTLCStatus, HTLCSource, HTLCFailReason, HTLCFailureMsg, PendingForwardHTLCInfo, RAACommitmentOrder, PaymentPreimage, PaymentHash, BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT}; use ln::chan_utils::{TxCreationKeys,HTLCOutputInCommitment,HTLC_SUCCESS_TX_WEIGHT,HTLC_TIMEOUT_TX_WEIGHT}; use ln::chan_utils; use chain::chaininterface::{FeeEstimator,ConfirmationTarget}; @@ -347,14 +347,6 @@ pub const OUR_MAX_HTLCS: u16 = 50; //TODO /// on ice until the funding transaction gets more confirmations, but the LN protocol doesn't /// really allow for this, so instead we're stuck closing it out at that point. const UNCONF_THRESHOLD: u32 = 6; -/// The amount of time we require our counterparty wait to claim their money (ie time between when -/// we, or our watchtower, must check for them having broadcast a theft transaction). -#[cfg(not(test))] -const BREAKDOWN_TIMEOUT: u16 = 6 * 24 * 7; //TODO? -#[cfg(test)] -pub const BREAKDOWN_TIMEOUT: u16 = 6 * 24 * 7; //TODO? -/// The amount of time we're willing to wait to claim money back to us -const MAX_LOCAL_BREAKDOWN_TIMEOUT: u16 = 6 * 24 * 14; /// Exposing these two constants for use in test in ChannelMonitor pub const COMMITMENT_TX_BASE_WEIGHT: u64 = 724; pub const COMMITMENT_TX_WEIGHT_PER_HTLC: u64 = 172; diff --git a/src/ln/channelmanager.rs b/src/ln/channelmanager.rs index d48dcea4..10c5ce0a 100644 --- a/src/ln/channelmanager.rs +++ b/src/ln/channelmanager.rs @@ -341,6 +341,12 @@ pub struct ChannelManager { logger: Arc, } +/// The amount of time we require our counterparty wait to claim their money (ie time between when +/// we, or our watchtower, must check for them having broadcast a theft transaction). +pub(crate) const BREAKDOWN_TIMEOUT: u16 = 6 * 24; +/// The amount of time we're willing to wait to claim money back to us +pub(crate) const MAX_LOCAL_BREAKDOWN_TIMEOUT: u16 = 6 * 24 * 7; + /// The minimum number of blocks between an inbound HTLC's CLTV and the corresponding outbound /// HTLC's CLTV. This should always be a few blocks greater than channelmonitor::CLTV_CLAIM_BUFFER, /// ie the node we forwarded the payment on to should always have enough room to reliably time out diff --git a/src/ln/functional_tests.rs b/src/ln/functional_tests.rs index 4c6cde82..2c44b701 100644 --- a/src/ln/functional_tests.rs +++ b/src/ln/functional_tests.rs @@ -5,8 +5,8 @@ use chain::transaction::OutPoint; use chain::chaininterface::{ChainListener, ChainWatchInterface}; use chain::keysinterface::{KeysInterface, SpendableOutputDescriptor}; -use ln::channel::{COMMITMENT_TX_BASE_WEIGHT, COMMITMENT_TX_WEIGHT_PER_HTLC, BREAKDOWN_TIMEOUT}; -use ln::channelmanager::{ChannelManager,ChannelManagerReadArgs,HTLCForwardInfo,RAACommitmentOrder, PaymentPreimage, PaymentHash}; +use ln::channel::{COMMITMENT_TX_BASE_WEIGHT, COMMITMENT_TX_WEIGHT_PER_HTLC}; +use ln::channelmanager::{ChannelManager,ChannelManagerReadArgs,HTLCForwardInfo,RAACommitmentOrder, PaymentPreimage, PaymentHash, BREAKDOWN_TIMEOUT}; use ln::channelmonitor::{ChannelMonitor, CLTV_CLAIM_BUFFER, LATENCY_GRACE_PERIOD_BLOCKS, ManyChannelMonitor, ANTI_REORG_DELAY}; use ln::channel::{ACCEPTED_HTLC_SCRIPT_WEIGHT, OFFERED_HTLC_SCRIPT_WEIGHT}; use ln::onion_utils; -- 2.30.2