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
Explicitly support counterparty setting 0 channel reserve
A peer providing a channel_reserve_satoshis of 0 (or less than our
dust limit) is insecure, but only for them. Because some LSPs do it
with some level of trust of the clients (for a substantial UX
improvement), we explicitly allow it. Because its unlikely to
happen often in normal testing, we test it explicitly here.
if msg.dust_limit_satoshis > msg.funding_satoshis{
922
934
returnErr(ChannelError::Close(format!("dust_limit_satoshis {} was larger than funding_satoshis {}. Peer never wants payout outputs?", msg.dust_limit_satoshis, msg.funding_satoshis)));
923
935
}
924
-
if msg.dust_limit_satoshis > msg.channel_reserve_satoshis{
925
-
returnErr(ChannelError::Close(format!("Bogus; channel reserve ({}) is less than dust limit ({})", msg.channel_reserve_satoshis, msg.dust_limit_satoshis)));
926
-
}
927
936
let full_channel_value_msat = (msg.funding_satoshis - msg.channel_reserve_satoshis)*1000;
928
937
if msg.htlc_minimum_msat >= full_channel_value_msat {
929
938
returnErr(ChannelError::Close(format!("Minimum htlc value ({}) was larger than full channel value ({})", msg.htlc_minimum_msat, full_channel_value_msat)));
returnErr(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)));
981
990
}
982
991
if msg.channel_reserve_satoshis < MIN_CHAN_DUST_LIMIT_SATOSHIS{
983
-
returnErr(ChannelError::Close(format!("channel_reserve_satoshis ({}) is smaller than our dust limit ({})", msg.channel_reserve_satoshis,MIN_CHAN_DUST_LIMIT_SATOSHIS)));
992
+
log_debug!(logger,"channel_reserve_satoshis ({}) is smaller than our dust limit ({}). We can broadcast stale states without any risk, implying this channel is very insecure for our counterparty.",
if holder_selected_channel_reserve_satoshis < msg.dust_limit_satoshis{
986
996
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.channel_reserve_satoshis > self.channel_value_satoshis{
1713
1723
returnErr(ChannelError::Close(format!("Bogus channel_reserve_satoshis ({}). Must not be greater than ({})", msg.channel_reserve_satoshis,self.channel_value_satoshis)));
1714
1724
}
1715
-
if msg.channel_reserve_satoshis < self.holder_dust_limit_satoshis{
1716
-
returnErr(ChannelError::Close(format!("Peer never wants payout outputs? channel_reserve_satoshis was ({}). dust_limit is ({})", msg.channel_reserve_satoshis,self.holder_dust_limit_satoshis)));
1717
-
}
1718
1725
if msg.dust_limit_satoshis > self.holder_selected_channel_reserve_satoshis{
1719
1726
returnErr(ChannelError::Close(format!("Dust limit ({}) is bigger than our channel reserve ({})", msg.dust_limit_satoshis,self.holder_selected_channel_reserve_satoshis)));
1720
1727
}
@@ -5912,6 +5919,7 @@ mod tests {
5912
5919
let seed = [42;32];
5913
5920
let network = Network::Testnet;
5914
5921
let keys_provider = test_utils::TestKeysInterface::new(&seed, network);
5922
+
let logger = test_utils::TestLogger::new();
5915
5923
5916
5924
// Go through the flow of opening a channel between two nodes, making sure
5917
5925
// they have different dust limits.
@@ -5925,7 +5933,7 @@ mod tests {
5925
5933
// Make sure A's dust limit is as we expect.
5926
5934
let open_channel_msg = node_a_chan.get_open_channel(genesis_block(network).header.block_hash());
5927
5935
let node_b_node_id = PublicKey::from_secret_key(&secp_ctx,&SecretKey::from_slice(&[7;32]).unwrap());
5928
-
let node_b_chan = Channel::<EnforcingSigner>::new_from_req(&&feeest,&&keys_provider, node_b_node_id,&InitFeatures::known(),&open_channel_msg,7,&config,0).unwrap();
5936
+
let node_b_chan = Channel::<EnforcingSigner>::new_from_req(&&feeest,&&keys_provider, node_b_node_id,&InitFeatures::known(),&open_channel_msg,7,&config,0,&&logger).unwrap();
Copy file name to clipboardExpand all lines: lightning/src/ln/functional_tests.rs
+64-5Lines changed: 64 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ use chain::channelmonitor::{ChannelMonitor, CLTV_CLAIM_BUFFER, LATENCY_GRACE_PER
18
18
use chain::transaction::OutPoint;
19
19
use chain::keysinterface::BaseSign;
20
20
use ln::{PaymentPreimage,PaymentSecret,PaymentHash};
21
-
use ln::channel::{COMMITMENT_TX_BASE_WEIGHT,COMMITMENT_TX_WEIGHT_PER_HTLC,CONCURRENT_INBOUND_HTLC_FEE_BUFFER,MIN_AFFORDABLE_HTLC_COUNT};
21
+
use ln::channel::{COMMITMENT_TX_BASE_WEIGHT,COMMITMENT_TX_WEIGHT_PER_HTLC,CONCURRENT_INBOUND_HTLC_FEE_BUFFER,FEE_SPIKE_BUFFER_FEE_INCREASE_MULTIPLE,MIN_AFFORDABLE_HTLC_COUNT};
22
22
use ln::channelmanager::{ChannelManager,ChannelManagerReadArgs,PaymentId,RAACommitmentOrder,PaymentSendFailure,BREAKDOWN_TIMEOUT,MIN_CLTV_EXPIRY_DELTA};
insane_open_helper(r"Bogus; channel reserve \(\d+\) is less than dust limit \(\d+\)", |mut msg| { msg.dust_limit_satoshis = msg.channel_reserve_satoshis + 1; msg });
112
-
113
111
insane_open_helper(r"Minimum htlc value \(\d+\) was larger than full channel value \(\d+\)", |mut msg| { msg.htlc_minimum_msat = (msg.funding_satoshis - msg.channel_reserve_satoshis)*1000; msg });
114
112
115
113
insane_open_helper("They wanted our payments to be delayed by a needlessly long period", |mut msg| { msg.to_self_delay = MAX_LOCAL_BREAKDOWN_TIMEOUT + 1; msg });
ChannelError::Close(err) => {assert!(regex::Regex::new(r"Configured with an unreasonable our_to_self_delay \(\d+\) putting user funds at risks").unwrap().is_match(err.as_str()));},
ChannelError::Close(err) => {assert!(regex::Regex::new(r"They wanted our payments to be delayed by a needlessly long period\. Upper limit: \d+\. Actual: \d+").unwrap().is_match(err.as_str()));},
0 commit comments