Skip to content

Commit 0f6e0c3

Browse files
committed
Rename MIN_DUST_LIMIT_SATOSHIS constant to disambiguate chan vs P2P
While channel and P2P network dust limits are related, they're ultimately two different things, and thus their constant names should reference that.
1 parent 88c0619 commit 0f6e0c3

File tree

2 files changed

+13
-13
lines changed

2 files changed

+13
-13
lines changed

lightning/src/ln/channel.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ pub const MAX_CHAN_DUST_LIMIT_SATOSHIS: u64 = MAX_STD_OUTPUT_DUST_LIMIT_SATOSHIS
571571
/// simply require our counterparty to use a dust limit which will leave any segwit output
572572
/// standard.
573573
/// See https://github.com/lightningnetwork/lightning-rfc/issues/905 for more details.
574-
pub const MIN_DUST_LIMIT_SATOSHIS: u64 = 354;
574+
pub const MIN_CHAN_DUST_LIMIT_SATOSHIS: u64 = 354;
575575

576576
/// Used to return a simple Error back to ChannelManager. Will get converted to a
577577
/// msgs::ErrorAction::SendErrorMessage or msgs::ErrorAction::IgnoreError as appropriate with our
@@ -638,7 +638,7 @@ impl<Signer: Sign> Channel<Signer> {
638638
return Err(APIError::APIMisuseError {err: format!("Configured with an unreasonable our_to_self_delay ({}) putting user funds at risks", holder_selected_contest_delay)});
639639
}
640640
let holder_selected_channel_reserve_satoshis = Channel::<Signer>::get_holder_selected_channel_reserve_satoshis(channel_value_satoshis);
641-
if holder_selected_channel_reserve_satoshis < MIN_DUST_LIMIT_SATOSHIS {
641+
if holder_selected_channel_reserve_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS {
642642
return Err(APIError::APIMisuseError { err: format!("Holder selected channel reserve below implemention limit dust_limit_satoshis {}", holder_selected_channel_reserve_satoshis) });
643643
}
644644

@@ -709,7 +709,7 @@ impl<Signer: Sign> Channel<Signer> {
709709

710710
feerate_per_kw: feerate,
711711
counterparty_dust_limit_satoshis: 0,
712-
holder_dust_limit_satoshis: MIN_DUST_LIMIT_SATOSHIS,
712+
holder_dust_limit_satoshis: MIN_CHAN_DUST_LIMIT_SATOSHIS,
713713
counterparty_max_htlc_value_in_flight_msat: 0,
714714
counterparty_selected_channel_reserve_satoshis: None, // Filled in in accept_channel
715715
counterparty_htlc_minimum_msat: 0,
@@ -843,8 +843,8 @@ impl<Signer: Sign> Channel<Signer> {
843843
if msg.max_accepted_htlcs < config.peer_channel_config_limits.min_max_accepted_htlcs {
844844
return Err(ChannelError::Close(format!("max_accepted_htlcs ({}) is less than the user specified limit ({})", msg.max_accepted_htlcs, config.peer_channel_config_limits.min_max_accepted_htlcs)));
845845
}
846-
if msg.dust_limit_satoshis < MIN_DUST_LIMIT_SATOSHIS {
847-
return Err(ChannelError::Close(format!("dust_limit_satoshis ({}) is less than the implementation limit ({})", msg.dust_limit_satoshis, MIN_DUST_LIMIT_SATOSHIS)));
846+
if msg.dust_limit_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS {
847+
return Err(ChannelError::Close(format!("dust_limit_satoshis ({}) is less than the implementation limit ({})", msg.dust_limit_satoshis, MIN_CHAN_DUST_LIMIT_SATOSHIS)));
848848
}
849849
if msg.dust_limit_satoshis > MAX_CHAN_DUST_LIMIT_SATOSHIS {
850850
return Err(ChannelError::Close(format!("dust_limit_satoshis ({}) is greater than the implementation limit ({})", msg.dust_limit_satoshis, MAX_CHAN_DUST_LIMIT_SATOSHIS)));
@@ -864,11 +864,11 @@ impl<Signer: Sign> Channel<Signer> {
864864
let background_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
865865

866866
let holder_selected_channel_reserve_satoshis = Channel::<Signer>::get_holder_selected_channel_reserve_satoshis(msg.funding_satoshis);
867-
if holder_selected_channel_reserve_satoshis < MIN_DUST_LIMIT_SATOSHIS {
868-
return Err(ChannelError::Close(format!("Suitable channel reserve not found. remote_channel_reserve was ({}). dust_limit_satoshis is ({}).", holder_selected_channel_reserve_satoshis, MIN_DUST_LIMIT_SATOSHIS)));
867+
if holder_selected_channel_reserve_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS {
868+
return Err(ChannelError::Close(format!("Suitable channel reserve not found. remote_channel_reserve was ({}). dust_limit_satoshis is ({}).", holder_selected_channel_reserve_satoshis, MIN_CHAN_DUST_LIMIT_SATOSHIS)));
869869
}
870-
if msg.channel_reserve_satoshis < MIN_DUST_LIMIT_SATOSHIS {
871-
return Err(ChannelError::Close(format!("channel_reserve_satoshis ({}) is smaller than our dust limit ({})", msg.channel_reserve_satoshis, MIN_DUST_LIMIT_SATOSHIS)));
870+
if msg.channel_reserve_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS {
871+
return Err(ChannelError::Close(format!("channel_reserve_satoshis ({}) is smaller than our dust limit ({})", msg.channel_reserve_satoshis, MIN_CHAN_DUST_LIMIT_SATOSHIS)));
872872
}
873873
if holder_selected_channel_reserve_satoshis < msg.dust_limit_satoshis {
874874
return Err(ChannelError::Close(format!("Dust limit ({}) too high for the channel reserve we require the remote to keep ({})", msg.dust_limit_satoshis, holder_selected_channel_reserve_satoshis)));
@@ -973,7 +973,7 @@ impl<Signer: Sign> Channel<Signer> {
973973
feerate_per_kw: msg.feerate_per_kw,
974974
channel_value_satoshis: msg.funding_satoshis,
975975
counterparty_dust_limit_satoshis: msg.dust_limit_satoshis,
976-
holder_dust_limit_satoshis: MIN_DUST_LIMIT_SATOSHIS,
976+
holder_dust_limit_satoshis: MIN_CHAN_DUST_LIMIT_SATOSHIS,
977977
counterparty_max_htlc_value_in_flight_msat: cmp::min(msg.max_htlc_value_in_flight_msat, msg.funding_satoshis * 1000),
978978
counterparty_selected_channel_reserve_satoshis: Some(msg.channel_reserve_satoshis),
979979
counterparty_htlc_minimum_msat: msg.htlc_minimum_msat,
@@ -1617,8 +1617,8 @@ impl<Signer: Sign> Channel<Signer> {
16171617
if msg.max_accepted_htlcs < config.peer_channel_config_limits.min_max_accepted_htlcs {
16181618
return Err(ChannelError::Close(format!("max_accepted_htlcs ({}) is less than the user specified limit ({})", msg.max_accepted_htlcs, config.peer_channel_config_limits.min_max_accepted_htlcs)));
16191619
}
1620-
if msg.dust_limit_satoshis < MIN_DUST_LIMIT_SATOSHIS {
1621-
return Err(ChannelError::Close(format!("dust_limit_satoshis ({}) is less than the implementation limit ({})", msg.dust_limit_satoshis, MIN_DUST_LIMIT_SATOSHIS)));
1620+
if msg.dust_limit_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS {
1621+
return Err(ChannelError::Close(format!("dust_limit_satoshis ({}) is less than the implementation limit ({})", msg.dust_limit_satoshis, MIN_CHAN_DUST_LIMIT_SATOSHIS)));
16221622
}
16231623
if msg.dust_limit_satoshis > MAX_CHAN_DUST_LIMIT_SATOSHIS {
16241624
return Err(ChannelError::Close(format!("dust_limit_satoshis ({}) is greater than the implementation limit ({})", msg.dust_limit_satoshis, MAX_CHAN_DUST_LIMIT_SATOSHIS)));

lightning/src/ln/functional_tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1480,7 +1480,7 @@ fn test_chan_reserve_dust_inbound_htlcs_outbound_chan() {
14801480
push_amt -= Channel::<EnforcingSigner>::get_holder_selected_channel_reserve_satoshis(100_000) * 1000;
14811481
create_announced_chan_between_nodes_with_value(&nodes, 0, 1, 100000, push_amt, InitFeatures::known(), InitFeatures::known());
14821482

1483-
let dust_amt = crate::ln::channel::MIN_DUST_LIMIT_SATOSHIS * 1000
1483+
let dust_amt = crate::ln::channel::MIN_CHAN_DUST_LIMIT_SATOSHIS * 1000
14841484
+ feerate_per_kw as u64 * HTLC_SUCCESS_TX_WEIGHT / 1000 * 1000 - 1;
14851485
// In the previous code, routing this dust payment would cause nodes[0] to perceive a channel
14861486
// reserve violation even though it's a dust HTLC and therefore shouldn't count towards the

0 commit comments

Comments
 (0)