Skip to content

Commit 01e8078

Browse files
author
Antoine Riard
committed
Bump default CSV delay on counterparty states to 3 days of blocks
1 parent 2c57878 commit 01e8078

File tree

4 files changed

+12
-9
lines changed

4 files changed

+12
-9
lines changed

lightning/src/ln/channelmanager.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,7 @@ impl<'a, F: Fn() -> NotifyOption> Drop for PersistenceNotifierGuard<'a, F> {
926926
/// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`]
927927
///
928928
/// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay
929-
pub const BREAKDOWN_TIMEOUT: u16 = 6 * 24;
929+
pub const BREAKDOWN_TIMEOUT: u16 = 1008;
930930
/// The amount of time in blocks we're willing to wait to claim money back to us. This matches
931931
/// the maximum required amount in lnd as of March 2021.
932932
pub(crate) const MAX_LOCAL_BREAKDOWN_TIMEOUT: u16 = 2 * 6 * 24 * 7;

lightning/src/ln/functional_tests.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -2352,11 +2352,11 @@ fn test_justice_tx() {
23522352
let mut alice_config = UserConfig::default();
23532353
alice_config.channel_handshake_config.announced_channel = true;
23542354
alice_config.channel_handshake_limits.force_announced_channel_preference = false;
2355-
alice_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 5;
2355+
alice_config.channel_handshake_config.our_to_self_delay = 1008 + 288;
23562356
let mut bob_config = UserConfig::default();
23572357
bob_config.channel_handshake_config.announced_channel = true;
23582358
bob_config.channel_handshake_limits.force_announced_channel_preference = false;
2359-
bob_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 3;
2359+
bob_config.channel_handshake_config.our_to_self_delay = 1008 + 144;
23602360
let user_cfgs = [Some(alice_config), Some(bob_config)];
23612361
let mut chanmon_cfgs = create_chanmon_cfgs(2);
23622362
chanmon_cfgs[0].keys_manager.disable_revocation_policy_check = true;
@@ -7608,14 +7608,14 @@ fn test_override_channel_config() {
76087608

76097609
// Node0 initiates a channel to node1 using the override config.
76107610
let mut override_config = UserConfig::default();
7611-
override_config.channel_handshake_config.our_to_self_delay = 200;
7611+
override_config.channel_handshake_config.our_to_self_delay = 1018;
76127612

76137613
nodes[0].node.create_channel(nodes[1].node.get_our_node_id(), 16_000_000, 12_000_000, 42, Some(override_config)).unwrap();
76147614

76157615
// Assert the channel created by node0 is using the override config.
76167616
let res = get_event_msg!(nodes[0], MessageSendEvent::SendOpenChannel, nodes[1].node.get_our_node_id());
76177617
assert_eq!(res.channel_flags, 0);
7618-
assert_eq!(res.to_self_delay, 200);
7618+
assert_eq!(res.to_self_delay, 1018);
76197619
}
76207620

76217621
#[test]
@@ -8889,7 +8889,7 @@ fn do_test_tx_confirmed_skipping_blocks_immediate_broadcast(test_height_before_t
88898889

88908890
let conf_height = nodes[1].best_block_info().1;
88918891
if !test_height_before_timelock {
8892-
connect_blocks(&nodes[1], 24 * 6);
8892+
connect_blocks(&nodes[1], BREAKDOWN_TIMEOUT as u32);
88938893
}
88948894
nodes[1].chain_monitor.chain_monitor.transactions_confirmed(
88958895
&nodes[1].get_block_header(conf_height), &[(0, &node_txn[0])], conf_height);

lightning/src/ln/monitor_tests.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ fn test_no_preimage_inbound_htlc_balances() {
909909
// Now confirm the two HTLC timeout transactions for A, checking that the inbound HTLC resolves
910910
// after ANTI_REORG_DELAY confirmations and the other takes BREAKDOWN_TIMEOUT confirmations.
911911
mine_transaction(&nodes[0], &as_htlc_timeout_claim[0]);
912-
let as_timeout_claimable_height = nodes[0].best_block_info().1 + (BREAKDOWN_TIMEOUT as u32) - 1;
912+
let as_timeout_claimable_height = nodes[0].best_block_info().1 + BREAKDOWN_TIMEOUT as u32 - 1;
913913
assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations {
914914
claimable_amount_satoshis: 1_000_000 - 500_000 - 10_000 - chan_feerate *
915915
(channel::commitment_tx_base_weight(opt_anchors) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000,

lightning/src/util/config.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,11 @@ pub struct ChannelHandshakeConfig {
4545
/// case of an honest unilateral channel close, which implicitly decrease the economic value of
4646
/// our channel.
4747
///
48-
/// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
49-
/// can tweak config to ask for more security, not less.
48+
/// Default value: [`BREAKDOWN_TIMEOUT`], we enforce [`BREAKDOWN_TIMEOUT`] as a minimum at
49+
/// channel opening so you can tweak config to ask for less security than the default of 7 days
50+
/// of block. When setting this value, consider how long it may take to upgrade node(s) after
51+
/// a bug was discovered a patch releaaed. While not all potential sources of error can be
52+
/// recovered, some classes of bugs may allow this much time to react.
5053
pub our_to_self_delay: u16,
5154
/// Set to the smallest value HTLC we will accept to process.
5255
///

0 commit comments

Comments
 (0)