Skip to content

Commit 60bf1fe

Browse files
authored
Merge pull request #355 from ariard/2019-07-fix-csv-delay-check-remote-htlc
Fix bug in check_spend_remote_htlc and let csv delays being user configurable
2 parents 19a0f84 + e78c25b commit 60bf1fe

File tree

5 files changed

+123
-24
lines changed

5 files changed

+123
-24
lines changed

src/ln/channel.rs

Lines changed: 22 additions & 18 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};
@@ -317,7 +317,7 @@ pub(super) struct Channel {
317317
their_htlc_minimum_msat: u64,
318318
our_htlc_minimum_msat: u64,
319319
their_to_self_delay: u16,
320-
//implied by BREAKDOWN_TIMEOUT: our_to_self_delay: u16,
320+
our_to_self_delay: u16,
321321
#[cfg(test)]
322322
pub their_max_accepted_htlcs: u16,
323323
#[cfg(not(test))]
@@ -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;
@@ -421,6 +413,9 @@ impl Channel {
421413
if push_msat > channel_value_satoshis * 1000 {
422414
return Err(APIError::APIMisuseError{err: "push value > channel value"});
423415
}
416+
if config.own_channel_config.our_to_self_delay < BREAKDOWN_TIMEOUT {
417+
return Err(APIError::APIMisuseError{err: "Configured with an unreasonable our_to_self_delay putting user funds at risks"});
418+
}
424419

425420

426421
let background_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
@@ -432,7 +427,7 @@ impl Channel {
432427

433428
let secp_ctx = Secp256k1::new();
434429
let channel_monitor = ChannelMonitor::new(&chan_keys.revocation_base_key, &chan_keys.delayed_payment_base_key,
435-
&chan_keys.htlc_base_key, &chan_keys.payment_base_key, &keys_provider.get_shutdown_pubkey(), BREAKDOWN_TIMEOUT,
430+
&chan_keys.htlc_base_key, &chan_keys.payment_base_key, &keys_provider.get_shutdown_pubkey(), config.own_channel_config.our_to_self_delay,
436431
keys_provider.get_destination_script(), logger.clone());
437432

438433
Ok(Channel {
@@ -489,6 +484,7 @@ impl Channel {
489484
their_htlc_minimum_msat: 0,
490485
our_htlc_minimum_msat: Channel::derive_our_htlc_minimum_msat(feerate),
491486
their_to_self_delay: 0,
487+
our_to_self_delay: config.own_channel_config.our_to_self_delay,
492488
their_max_accepted_htlcs: 0,
493489
minimum_depth: 0, // Filled in in accept_channel
494490

@@ -526,6 +522,10 @@ impl Channel {
526522
let chan_keys = keys_provider.get_channel_keys(true);
527523
let mut local_config = (*config).channel_options.clone();
528524

525+
if config.own_channel_config.our_to_self_delay < BREAKDOWN_TIMEOUT {
526+
return Err(ChannelError::Close("Configured with an unreasonable our_to_self_delay putting user funds at risks"));
527+
}
528+
529529
// Check sanity of message fields:
530530
if msg.funding_satoshis >= MAX_FUNDING_SATOSHIS {
531531
return Err(ChannelError::Close("funding value > 2^24"));
@@ -547,7 +547,7 @@ impl Channel {
547547
}
548548
Channel::check_remote_fee(fee_estimator, msg.feerate_per_kw)?;
549549

550-
if msg.to_self_delay > MAX_LOCAL_BREAKDOWN_TIMEOUT {
550+
if msg.to_self_delay > config.peer_channel_config_limits.their_to_self_delay || msg.to_self_delay > MAX_LOCAL_BREAKDOWN_TIMEOUT {
551551
return Err(ChannelError::Close("They wanted our payments to be delayed by a needlessly long period"));
552552
}
553553
if msg.max_accepted_htlcs < 1 {
@@ -620,7 +620,7 @@ impl Channel {
620620

621621
let secp_ctx = Secp256k1::new();
622622
let mut channel_monitor = ChannelMonitor::new(&chan_keys.revocation_base_key, &chan_keys.delayed_payment_base_key,
623-
&chan_keys.htlc_base_key, &chan_keys.payment_base_key, &keys_provider.get_shutdown_pubkey(), BREAKDOWN_TIMEOUT,
623+
&chan_keys.htlc_base_key, &chan_keys.payment_base_key, &keys_provider.get_shutdown_pubkey(), config.own_channel_config.our_to_self_delay,
624624
keys_provider.get_destination_script(), logger.clone());
625625
channel_monitor.set_their_base_keys(&msg.htlc_basepoint, &msg.delayed_payment_basepoint);
626626
channel_monitor.set_their_to_self_delay(msg.to_self_delay);
@@ -700,6 +700,7 @@ impl Channel {
700700
their_htlc_minimum_msat: msg.htlc_minimum_msat,
701701
our_htlc_minimum_msat: Channel::derive_our_htlc_minimum_msat(msg.feerate_per_kw as u64),
702702
their_to_self_delay: msg.to_self_delay,
703+
our_to_self_delay: config.own_channel_config.our_to_self_delay,
703704
their_max_accepted_htlcs: msg.max_accepted_htlcs,
704705
minimum_depth: config.own_channel_config.minimum_depth,
705706

@@ -935,7 +936,7 @@ impl Channel {
935936
log_trace!(self, " ...including {} output with value {}", if local { "to_local" } else { "to_remote" }, value_to_a);
936937
txouts.push((TxOut {
937938
script_pubkey: chan_utils::get_revokeable_redeemscript(&keys.revocation_key,
938-
if local { self.their_to_self_delay } else { BREAKDOWN_TIMEOUT },
939+
if local { self.their_to_self_delay } else { self.our_to_self_delay },
939940
&keys.a_delayed_payment_key).to_v0_p2wsh(),
940941
value: value_to_a as u64
941942
}, None));
@@ -1134,7 +1135,7 @@ impl Channel {
11341135
/// @local is used only to convert relevant internal structures which refer to remote vs local
11351136
/// to decide value of outputs and direction of HTLCs.
11361137
fn build_htlc_transaction(&self, prev_hash: &Sha256dHash, htlc: &HTLCOutputInCommitment, local: bool, keys: &TxCreationKeys, feerate_per_kw: u64) -> Transaction {
1137-
chan_utils::build_htlc_transaction(prev_hash, feerate_per_kw, if local { self.their_to_self_delay } else { BREAKDOWN_TIMEOUT }, htlc, &keys.a_delayed_payment_key, &keys.revocation_key)
1138+
chan_utils::build_htlc_transaction(prev_hash, feerate_per_kw, if local { self.their_to_self_delay } else { self.our_to_self_delay }, htlc, &keys.a_delayed_payment_key, &keys.revocation_key)
11381139
}
11391140

11401141
fn create_htlc_tx_signature(&self, tx: &Transaction, htlc: &HTLCOutputInCommitment, keys: &TxCreationKeys) -> Result<(Script, Signature, bool), ChannelError> {
@@ -1388,7 +1389,7 @@ impl Channel {
13881389
if msg.htlc_minimum_msat >= (self.channel_value_satoshis - msg.channel_reserve_satoshis) * 1000 {
13891390
return Err(ChannelError::Close("Minimum htlc value is full channel value"));
13901391
}
1391-
if msg.to_self_delay > MAX_LOCAL_BREAKDOWN_TIMEOUT {
1392+
if msg.to_self_delay > config.peer_channel_config_limits.their_to_self_delay || msg.to_self_delay > MAX_LOCAL_BREAKDOWN_TIMEOUT {
13921393
return Err(ChannelError::Close("They wanted our payments to be delayed by a needlessly long period"));
13931394
}
13941395
if msg.max_accepted_htlcs < 1 {
@@ -3072,7 +3073,7 @@ impl Channel {
30723073
channel_reserve_satoshis: Channel::get_our_channel_reserve_satoshis(self.channel_value_satoshis),
30733074
htlc_minimum_msat: self.our_htlc_minimum_msat,
30743075
feerate_per_kw: fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background) as u32,
3075-
to_self_delay: BREAKDOWN_TIMEOUT,
3076+
to_self_delay: self.our_to_self_delay,
30763077
max_accepted_htlcs: OUR_MAX_HTLCS,
30773078
funding_pubkey: PublicKey::from_secret_key(&self.secp_ctx, &self.local_keys.funding_key),
30783079
revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, &self.local_keys.revocation_base_key),
@@ -3105,7 +3106,7 @@ impl Channel {
31053106
channel_reserve_satoshis: Channel::get_our_channel_reserve_satoshis(self.channel_value_satoshis),
31063107
htlc_minimum_msat: self.our_htlc_minimum_msat,
31073108
minimum_depth: self.minimum_depth,
3108-
to_self_delay: BREAKDOWN_TIMEOUT,
3109+
to_self_delay: self.our_to_self_delay,
31093110
max_accepted_htlcs: OUR_MAX_HTLCS,
31103111
funding_pubkey: PublicKey::from_secret_key(&self.secp_ctx, &self.local_keys.funding_key),
31113112
revocation_basepoint: PublicKey::from_secret_key(&self.secp_ctx, &self.local_keys.revocation_base_key),
@@ -3754,6 +3755,7 @@ impl Writeable for Channel {
37543755
self.their_htlc_minimum_msat.write(writer)?;
37553756
self.our_htlc_minimum_msat.write(writer)?;
37563757
self.their_to_self_delay.write(writer)?;
3758+
self.our_to_self_delay.write(writer)?;
37573759
self.their_max_accepted_htlcs.write(writer)?;
37583760
self.minimum_depth.write(writer)?;
37593761

@@ -3915,6 +3917,7 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
39153917
let their_htlc_minimum_msat = Readable::read(reader)?;
39163918
let our_htlc_minimum_msat = Readable::read(reader)?;
39173919
let their_to_self_delay = Readable::read(reader)?;
3920+
let our_to_self_delay = Readable::read(reader)?;
39183921
let their_max_accepted_htlcs = Readable::read(reader)?;
39193922
let minimum_depth = Readable::read(reader)?;
39203923

@@ -3992,6 +3995,7 @@ impl<R : ::std::io::Read> ReadableArgs<R, Arc<Logger>> for Channel {
39923995
their_htlc_minimum_msat,
39933996
our_htlc_minimum_msat,
39943997
their_to_self_delay,
3998+
our_to_self_delay,
39953999
their_max_accepted_htlcs,
39964000
minimum_depth,
39974001

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/channelmonitor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1768,7 +1768,7 @@ impl ChannelMonitor {
17681768
None => return (None, None),
17691769
Some(their_delayed_payment_base_key) => ignore_error!(chan_utils::derive_public_key(&self.secp_ctx, &per_commitment_point, &their_delayed_payment_base_key)),
17701770
};
1771-
let redeemscript = chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.their_to_self_delay.unwrap(), &delayed_key);
1771+
let redeemscript = chan_utils::get_revokeable_redeemscript(&revocation_pubkey, self.our_to_self_delay, &delayed_key);
17721772
let revokeable_p2wsh = redeemscript.to_v0_p2wsh();
17731773
let htlc_txid = tx.txid(); //TODO: This is gonna be a performance bottleneck for watchtowers!
17741774

src/ln/functional_tests.rs

Lines changed: 71 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
55
use chain::transaction::OutPoint;
66
use chain::chaininterface::{ChainListener, ChainWatchInterface};
7-
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};
7+
use chain::keysinterface::{KeysInterface, SpendableOutputDescriptor, KeysManager};
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};
11-
use ln::channel::{ACCEPTED_HTLC_SCRIPT_WEIGHT, OFFERED_HTLC_SCRIPT_WEIGHT};
11+
use ln::channel::{ACCEPTED_HTLC_SCRIPT_WEIGHT, OFFERED_HTLC_SCRIPT_WEIGHT, Channel, ChannelError};
1212
use ln::onion_utils;
1313
use ln::router::{Route, RouteHop};
1414
use ln::msgs;
@@ -1727,7 +1727,15 @@ fn channel_monitor_network_test() {
17271727
fn test_justice_tx() {
17281728
// Test justice txn built on revoked HTLC-Success tx, against both sides
17291729

1730-
let nodes = create_network(2, &[None, None]);
1730+
let mut alice_config = UserConfig::new();
1731+
alice_config.channel_options.announced_channel = true;
1732+
alice_config.peer_channel_config_limits.force_announced_channel_preference = false;
1733+
alice_config.own_channel_config.our_to_self_delay = 6 * 24 * 5;
1734+
let mut bob_config = UserConfig::new();
1735+
bob_config.channel_options.announced_channel = true;
1736+
bob_config.peer_channel_config_limits.force_announced_channel_preference = false;
1737+
bob_config.own_channel_config.our_to_self_delay = 6 * 24 * 3;
1738+
let nodes = create_network(2, &[Some(alice_config), Some(bob_config)]);
17311739
// Create some new channels:
17321740
let chan_5 = create_announced_chan_between_nodes(&nodes, 0, 1, LocalFeatures::new(), LocalFeatures::new());
17331741

@@ -5879,3 +5887,61 @@ fn test_upfront_shutdown_script() {
58795887
_ => panic!("Unexpected event"),
58805888
}
58815889
}
5890+
5891+
#[test]
5892+
fn test_user_configurable_csv_delay() {
5893+
// We test our channel constructors yield errors when we pass them absurd csv delay
5894+
5895+
let mut low_our_to_self_config = UserConfig::new();
5896+
low_our_to_self_config.own_channel_config.our_to_self_delay = 6;
5897+
let mut high_their_to_self_config = UserConfig::new();
5898+
high_their_to_self_config.peer_channel_config_limits.their_to_self_delay = 100;
5899+
let nodes = create_network(2, &[Some(high_their_to_self_config.clone()), None]);
5900+
5901+
// We test config.our_to_self > BREAKDOWN_TIMEOUT is enforced in Channel::new_outbound()
5902+
let keys_manager: Arc<KeysInterface> = Arc::new(KeysManager::new(&nodes[0].node_seed, Network::Testnet, Arc::new(test_utils::TestLogger::new()), 10, 20));
5903+
if let Err(error) = Channel::new_outbound(&test_utils::TestFeeEstimator { sat_per_kw: 253 }, &keys_manager, nodes[1].node.get_our_node_id(), 1000000, 1000000, 0, Arc::new(test_utils::TestLogger::new()), &low_our_to_self_config) {
5904+
match error {
5905+
APIError::APIMisuseError { err } => { assert_eq!(err, "Configured with an unreasonable our_to_self_delay putting user funds at risks"); },
5906+
_ => panic!("Unexpected event"),
5907+
}
5908+
} else { assert!(false) }
5909+
5910+
// We test config.our_to_self > BREAKDOWN_TIMEOUT is enforced in Channel::new_from_req()
5911+
nodes[1].node.create_channel(nodes[0].node.get_our_node_id(), 1000000, 1000000, 42).unwrap();
5912+
let mut open_channel = get_event_msg!(nodes[1], MessageSendEvent::SendOpenChannel, nodes[0].node.get_our_node_id());
5913+
open_channel.to_self_delay = 200;
5914+
if let Err(error) = Channel::new_from_req(&test_utils::TestFeeEstimator { sat_per_kw: 253 }, &keys_manager, nodes[1].node.get_our_node_id(), LocalFeatures::new(), &open_channel, 0, Arc::new(test_utils::TestLogger::new()), &low_our_to_self_config) {
5915+
match error {
5916+
ChannelError::Close(err) => { assert_eq!(err, "Configured with an unreasonable our_to_self_delay putting user funds at risks"); },
5917+
_ => panic!("Unexpected event"),
5918+
}
5919+
} else { assert!(false); }
5920+
5921+
// We test msg.to_self_delay <= config.their_to_self_delay is enforced in Chanel::accept_channel()
5922+
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 1000000, 1000000, 42).unwrap();
5923+
nodes[1].node.handle_open_channel(&nodes[0].node.get_our_node_id(), LocalFeatures::new(), &get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id())).unwrap();
5924+
let mut accept_channel = get_event_msg!(nodes[1], MessageSendEvent::SendAcceptChannel, nodes[0].node.get_our_node_id());
5925+
accept_channel.to_self_delay = 200;
5926+
if let Err(error) = nodes[0].node.handle_accept_channel(&nodes[1].node.get_our_node_id(), LocalFeatures::new(), &accept_channel) {
5927+
if let Some(error) = error.action {
5928+
match error {
5929+
ErrorAction::SendErrorMessage { msg } => {
5930+
assert_eq!(msg.data,"They wanted our payments to be delayed by a needlessly long period");
5931+
},
5932+
_ => { assert!(false); }
5933+
}
5934+
} else { assert!(false); }
5935+
} else { assert!(false); }
5936+
5937+
// We test msg.to_self_delay <= config.their_to_self_delay is enforced in Channel::new_from_req()
5938+
nodes[1].node.create_channel(nodes[0].node.get_our_node_id(), 1000000, 1000000, 42).unwrap();
5939+
let mut open_channel = get_event_msg!(nodes[1], MessageSendEvent::SendOpenChannel, nodes[0].node.get_our_node_id());
5940+
open_channel.to_self_delay = 200;
5941+
if let Err(error) = Channel::new_from_req(&test_utils::TestFeeEstimator { sat_per_kw: 253 }, &keys_manager, nodes[1].node.get_our_node_id(), LocalFeatures::new(), &open_channel, 0, Arc::new(test_utils::TestLogger::new()), &high_their_to_self_config) {
5942+
match error {
5943+
ChannelError::Close(err) => { assert_eq!(err, "They wanted our payments to be delayed by a needlessly long period"); },
5944+
_ => panic!("Unexpected event"),
5945+
}
5946+
} else { assert!(false); }
5947+
}

src/util/config.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
//! Various user-configurable channel limits and settings which ChannelManager
22
//! applies for you.
33
4+
use ln::channelmanager::{BREAKDOWN_TIMEOUT, MAX_LOCAL_BREAKDOWN_TIMEOUT};
5+
46
/// Top-level config which holds ChannelHandshakeLimits and ChannelConfig.
57
#[derive(Clone, Debug)]
68
pub struct UserConfig {
@@ -30,13 +32,26 @@ pub struct ChannelHandshakeConfig {
3032
/// Applied only for inbound channels (see ChannelHandshakeLimits::max_minimum_depth for the
3133
/// equivalent limit applied to outbound channels).
3234
pub minimum_depth: u32,
35+
/// Set to the amount of time we require our counterparty to wait to claim their money.
36+
///
37+
/// It's one of the main parameter of our security model. We (or one of our watchtowers) MUST
38+
/// be online to check for peer having broadcast a revoked transaction to steal our funds
39+
/// at least once every our_to_self_delay blocks.
40+
/// Default is BREAKDOWN_TIMEOUT, we enforce it as a minimum at channel opening so you can
41+
/// tweak config to ask for more security, not less.
42+
///
43+
/// Meanwhile, asking for a too high delay, we bother peer to freeze funds for nothing in
44+
/// case of an honest unilateral channel close, which implicitly decrease the economic value of
45+
/// our channel.
46+
pub our_to_self_delay: u16,
3347
}
3448

3549
impl ChannelHandshakeConfig {
3650
/// Provides sane defaults for `ChannelHandshakeConfig`
3751
pub fn new() -> ChannelHandshakeConfig {
3852
ChannelHandshakeConfig {
3953
minimum_depth: 6,
54+
our_to_self_delay: BREAKDOWN_TIMEOUT,
4055
}
4156
}
4257
}
@@ -88,6 +103,13 @@ pub struct ChannelHandshakeLimits {
88103
/// Defaults to true to make the default that no announced channels are possible (which is
89104
/// appropriate for any nodes which are not online very reliably).
90105
pub force_announced_channel_preference: bool,
106+
/// Set to the amount of time we're willing to wait to claim money back to us.
107+
///
108+
/// Not checking this value would be a security issue, as our peer would be able to set it to
109+
/// max relative lock-time (a year) and we would "lose" money as it would be locked for a long time.
110+
/// Default is MAX_LOCAL_BREAKDOWN_TIMEOUT, which we also enforce as a maximum value
111+
/// so you can tweak config to reduce the loss of having useless locked funds (if your peer accepts)
112+
pub their_to_self_delay: u16
91113
}
92114

93115
impl ChannelHandshakeLimits {
@@ -107,6 +129,7 @@ impl ChannelHandshakeLimits {
107129
max_dust_limit_satoshis: <u64>::max_value(),
108130
max_minimum_depth: 144,
109131
force_announced_channel_preference: true,
132+
their_to_self_delay: MAX_LOCAL_BREAKDOWN_TIMEOUT,
110133
}
111134
}
112135
}

0 commit comments

Comments
 (0)