You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace config max counterpary dust_limit_satoshis by a constant.
Current Bitcoin Core's policy will reject a p2wsh as a dust if it's
under 330 satoshis. A typical p2wsh output is 43 bytes big to which
Core's `GetDustThreshold()` sums up a minimal spend of 67 bytes (even
if a p2wsh witnessScript might be smaller). `dustRelayFee` is set
to 3000 sat/kb, thus 110 * 3000 / 1000 = 330. As all time-sensitive
outputs are p2wsh, a value of 330 sat is the lower bound desired
to ensure good propagation of transactions. We give a bit margin to
our counterparty and pick up 660 satoshis as an accepted
`dust_limit_satoshis` upper bound.
As this reasoning is tricky and error-prone we hardcode it instead of
letting the user picking up a non-sense value.
Further, this lower bound of 330 sats is also hardcoded as another constant
(MIN_DUST_LIMIT_SATOSHIS) instead of being dynamically computed on
feerate (derive_holder_dust_limit_satoshis`). Reducing risks of
non-propagating transactions in casee of failing fee festimation.
if holder_selected_contest_delay < BREAKDOWN_TIMEOUT{
520
531
returnErr(APIError::APIMisuseError{err:format!("Configured with an unreasonable our_to_self_delay ({}) putting user funds at risks", holder_selected_contest_delay)});
returnErr(APIError::FeeRateTooHigh{err:format!("Not enough reserve above dust limit can be found at current fee rate({})",background_feerate),feerate: background_feerate});
if msg.max_accepted_htlcs < config.peer_channel_config_limits.min_max_accepted_htlcs{
700
711
returnErr(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)));
701
712
}
702
-
if msg.dust_limit_satoshis < config.peer_channel_config_limits.min_dust_limit_satoshis{
703
-
returnErr(ChannelError::Close(format!("dust_limit_satoshis ({}) is less than the user specified limit ({})", msg.dust_limit_satoshis,config.peer_channel_config_limits.min_dust_limit_satoshis)));
713
+
if msg.dust_limit_satoshis < MIN_DUST_LIMIT_SATOSHIS{
714
+
returnErr(ChannelError::Close(format!("dust_limit_satoshis ({}) is less than the implementation limit ({})", msg.dust_limit_satoshis,MIN_DUST_LIMIT_SATOSHIS)));
704
715
}
705
-
if msg.dust_limit_satoshis > config.peer_channel_config_limits.max_dust_limit_satoshis{
706
-
returnErr(ChannelError::Close(format!("dust_limit_satoshis ({}) is greater than the user specified limit ({})", msg.dust_limit_satoshis,config.peer_channel_config_limits.max_dust_limit_satoshis)));
716
+
if msg.dust_limit_satoshis > MAX_DUST_LIMIT_SATOSHIS{
717
+
returnErr(ChannelError::Close(format!("dust_limit_satoshis ({}) is greater than the implementation limit ({})", msg.dust_limit_satoshis,MAX_DUST_LIMIT_SATOSHIS)));
707
718
}
708
719
709
720
// Convert things into internal flags and prep our state:
let background_feerate = fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background);
721
732
722
-
let holder_dust_limit_satoshis = Channel::<Signer>::derive_holder_dust_limit_satoshis(background_feerate);
723
733
let holder_selected_channel_reserve_satoshis = Channel::<Signer>::get_holder_selected_channel_reserve_satoshis(msg.funding_satoshis);
724
-
if holder_selected_channel_reserve_satoshis < holder_dust_limit_satoshis{
725
-
returnErr(ChannelError::Close(format!("Suitable channel reserve not found. remote_channel_reserve was ({}). dust_limit_satoshis is ({}).", holder_selected_channel_reserve_satoshis,holder_dust_limit_satoshis)));
734
+
if holder_selected_channel_reserve_satoshis < MIN_DUST_LIMIT_SATOSHIS{
735
+
returnErr(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)));
726
736
}
727
-
if msg.channel_reserve_satoshis < holder_dust_limit_satoshis{
728
-
returnErr(ChannelError::Close(format!("channel_reserve_satoshis ({}) is smaller than our dust limit ({})", msg.channel_reserve_satoshis,holder_dust_limit_satoshis)));
737
+
if msg.channel_reserve_satoshis < MIN_DUST_LIMIT_SATOSHIS{
738
+
returnErr(ChannelError::Close(format!("channel_reserve_satoshis ({}) is smaller than our dust limit ({})", msg.channel_reserve_satoshis,MIN_DUST_LIMIT_SATOSHIS)));
729
739
}
730
740
if holder_selected_channel_reserve_satoshis < msg.dust_limit_satoshis{
731
741
returnErr(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)));
if msg.max_accepted_htlcs < config.peer_channel_config_limits.min_max_accepted_htlcs{
1442
1452
returnErr(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)));
1443
1453
}
1444
-
if msg.dust_limit_satoshis < config.peer_channel_config_limits.min_dust_limit_satoshis{
1445
-
returnErr(ChannelError::Close(format!("dust_limit_satoshis ({}) is less than the user specified limit ({})", msg.dust_limit_satoshis,config.peer_channel_config_limits.min_dust_limit_satoshis)));
1454
+
if msg.dust_limit_satoshis < MIN_DUST_LIMIT_SATOSHIS{
1455
+
returnErr(ChannelError::Close(format!("dust_limit_satoshis ({}) is less than the implementation limit ({})", msg.dust_limit_satoshis,MIN_DUST_LIMIT_SATOSHIS)));
1446
1456
}
1447
-
if msg.dust_limit_satoshis > config.peer_channel_config_limits.max_dust_limit_satoshis{
1448
-
returnErr(ChannelError::Close(format!("dust_limit_satoshis ({}) is greater than the user specified limit ({})", msg.dust_limit_satoshis,config.peer_channel_config_limits.max_dust_limit_satoshis)));
1457
+
if msg.dust_limit_satoshis > MAX_DUST_LIMIT_SATOSHIS{
1458
+
returnErr(ChannelError::Close(format!("dust_limit_satoshis ({}) is greater than the implementation limit ({})", msg.dust_limit_satoshis,MAX_DUST_LIMIT_SATOSHIS)));
1449
1459
}
1450
1460
if msg.minimum_depth > config.peer_channel_config_limits.max_minimum_depth{
1451
1461
returnErr(ChannelError::Close(format!("We consider the minimum depth to be unreasonably large. Expected minimum: ({}). Actual: ({})", config.peer_channel_config_limits.max_minimum_depth, msg.minimum_depth)));
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx,&SecretKey::from_slice(&[7;32]).unwrap());
4940
4949
let node_b_chan = Channel::<EnforcingSigner>::new_from_req(&&feeest,&&keys_provider, node_b_node_id,InitFeatures::known(),&open_channel_msg,7,&config).unwrap();
0 commit comments