Skip to content

Commit

Permalink
Bump default CSV delay on counterparty states to 7 days of blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
Antoine Riard committed May 3, 2023
1 parent 2c57878 commit 20841db
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ impl<'a, F: Fn() -> NotifyOption> Drop for PersistenceNotifierGuard<'a, F> {
/// This can be increased (but not decreased) through [`ChannelHandshakeConfig::our_to_self_delay`]
///
/// [`ChannelHandshakeConfig::our_to_self_delay`]: crate::util::config::ChannelHandshakeConfig::our_to_self_delay
pub const BREAKDOWN_TIMEOUT: u16 = 6 * 24;
pub const BREAKDOWN_TIMEOUT: u16 = 1008;
/// The amount of time in blocks we're willing to wait to claim money back to us. This matches
/// the maximum required amount in lnd as of March 2021.
pub(crate) const MAX_LOCAL_BREAKDOWN_TIMEOUT: u16 = 2 * 6 * 24 * 7;
Expand Down
10 changes: 5 additions & 5 deletions lightning/src/ln/functional_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2352,11 +2352,11 @@ fn test_justice_tx() {
let mut alice_config = UserConfig::default();
alice_config.channel_handshake_config.announced_channel = true;
alice_config.channel_handshake_limits.force_announced_channel_preference = false;
alice_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 5;
alice_config.channel_handshake_config.our_to_self_delay = 1008 + 288;
let mut bob_config = UserConfig::default();
bob_config.channel_handshake_config.announced_channel = true;
bob_config.channel_handshake_limits.force_announced_channel_preference = false;
bob_config.channel_handshake_config.our_to_self_delay = 6 * 24 * 3;
bob_config.channel_handshake_config.our_to_self_delay = 1008 + 144;
let user_cfgs = [Some(alice_config), Some(bob_config)];
let mut chanmon_cfgs = create_chanmon_cfgs(2);
chanmon_cfgs[0].keys_manager.disable_revocation_policy_check = true;
Expand Down Expand Up @@ -7608,14 +7608,14 @@ fn test_override_channel_config() {

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

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

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

#[test]
Expand Down Expand Up @@ -8889,7 +8889,7 @@ fn do_test_tx_confirmed_skipping_blocks_immediate_broadcast(test_height_before_t

let conf_height = nodes[1].best_block_info().1;
if !test_height_before_timelock {
connect_blocks(&nodes[1], 24 * 6);
connect_blocks(&nodes[1], BREAKDOWN_TIMEOUT as u32);
}
nodes[1].chain_monitor.chain_monitor.transactions_confirmed(
&nodes[1].get_block_header(conf_height), &[(0, &node_txn[0])], conf_height);
Expand Down
2 changes: 1 addition & 1 deletion lightning/src/ln/monitor_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ fn test_no_preimage_inbound_htlc_balances() {
// Now confirm the two HTLC timeout transactions for A, checking that the inbound HTLC resolves
// after ANTI_REORG_DELAY confirmations and the other takes BREAKDOWN_TIMEOUT confirmations.
mine_transaction(&nodes[0], &as_htlc_timeout_claim[0]);
let as_timeout_claimable_height = nodes[0].best_block_info().1 + (BREAKDOWN_TIMEOUT as u32) - 1;
let as_timeout_claimable_height = nodes[0].best_block_info().1 + BREAKDOWN_TIMEOUT as u32 - 1;
assert_eq!(sorted_vec(vec![Balance::ClaimableAwaitingConfirmations {
claimable_amount_satoshis: 1_000_000 - 500_000 - 10_000 - chan_feerate *
(channel::commitment_tx_base_weight(opt_anchors) + 2 * channel::COMMITMENT_TX_WEIGHT_PER_HTLC) / 1000,
Expand Down
7 changes: 5 additions & 2 deletions lightning/src/util/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ pub struct ChannelHandshakeConfig {
/// case of an honest unilateral channel close, which implicitly decrease the economic value of
/// our channel.
///
/// Default value: [`BREAKDOWN_TIMEOUT`], we enforce it as a minimum at channel opening so you
/// can tweak config to ask for more security, not less.
/// Default value: [`BREAKDOWN_TIMEOUT`], we enforce [`BREAKDOWN_TIMEOUT`] as a minimum at
/// channel opening so you can tweak config to ask for less security than the default of 7 days
/// of block. When setting this value, consider how long it may take to upgrade node(s) after
/// a bug was discovered a patch releaaed. While not all potential sources of error can be
/// recovered, some classes of bugs may allow this much time to react.
pub our_to_self_delay: u16,
/// Set to the smallest value HTLC we will accept to process.
///
Expand Down

0 comments on commit 20841db

Please sign in to comment.