Skip to content

Commit 8f89271

Browse files
committed
More minor fixes for error message.
* Fix indentation inconsistency in TestLogger. * Fix some swapped argument for error message in Channel. * Fix more typos.
1 parent bc1d1a8 commit 8f89271

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

lightning/src/ln/channel.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -586,12 +586,12 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
586586
let mut local_config = (*config).channel_options.clone();
587587

588588
if config.own_channel_config.our_to_self_delay < BREAKDOWN_TIMEOUT {
589-
return Err(ChannelError::Close(format!("Configured with an unreasonable our_to_self_delay ({}) putting user funds at risks. It must be lower than {}", config.own_channel_config.our_to_self_delay, BREAKDOWN_TIMEOUT)));
589+
return Err(ChannelError::Close(format!("Configured with an unreasonable our_to_self_delay ({}) putting user funds at risks. It must be greater than {}", config.own_channel_config.our_to_self_delay, BREAKDOWN_TIMEOUT)));
590590
}
591591

592592
// Check sanity of message fields:
593593
if msg.funding_satoshis >= MAX_FUNDING_SATOSHIS {
594-
return Err(ChannelError::Close(format!("Funding must be smaller than {}. It was {}", msg.funding_satoshis, MAX_FUNDING_SATOSHIS)));
594+
return Err(ChannelError::Close(format!("Funding must be smaller than {}. It was {}", MAX_FUNDING_SATOSHIS, msg.funding_satoshis)));
595595
}
596596
if msg.channel_reserve_satoshis > msg.funding_satoshis {
597597
return Err(ChannelError::Close(format!("Bogus channel_reserve_satoshis ({}). Must be not greater than funding_satoshis: {}", msg.channel_reserve_satoshis, msg.funding_satoshis)));
@@ -665,7 +665,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
665665
return Err(ChannelError::Close(format!("Suitable channel reserve not found. remote_channel_reserve was ({}). our_dust_limit_satoshis is ({}).", remote_channel_reserve_satoshis, our_dust_limit_satoshis)));
666666
}
667667
if msg.channel_reserve_satoshis < our_dust_limit_satoshis {
668-
return Err(ChannelError::Close(format!("channel_reserve_satoshis ({}) is small than our dust limit ({})", msg.channel_reserve_satoshis, our_dust_limit_satoshis)));
668+
return Err(ChannelError::Close(format!("channel_reserve_satoshis ({}) is smaller than our dust limit ({})", msg.channel_reserve_satoshis, our_dust_limit_satoshis)));
669669
}
670670
if remote_channel_reserve_satoshis < msg.dust_limit_satoshis {
671671
return Err(ChannelError::Close(format!("Dust limit ({}) too high for the channel reserve we require the remote to keep ({})", msg.dust_limit_satoshis, remote_channel_reserve_satoshis)));
@@ -1387,15 +1387,15 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
13871387
}
13881388
let remote_reserve = Channel::<ChanSigner>::get_remote_channel_reserve_satoshis(self.channel_value_satoshis);
13891389
if msg.dust_limit_satoshis > remote_reserve {
1390-
return Err(ChannelError::Close(format!("Dust limit ({}) is bigger than our channel reverse ({})", msg.dust_limit_satoshis, remote_reserve)));
1390+
return Err(ChannelError::Close(format!("Dust limit ({}) is bigger than our channel reserve ({})", msg.dust_limit_satoshis, remote_reserve)));
13911391
}
13921392
let full_channel_value_msat = (self.channel_value_satoshis - msg.channel_reserve_satoshis) * 1000;
13931393
if msg.htlc_minimum_msat >= full_channel_value_msat {
13941394
return Err(ChannelError::Close(format!("Minimum htlc value ({}) is full channel value ({})", msg.htlc_minimum_msat, full_channel_value_msat)));
13951395
}
13961396
let max_delay_acceptable = u16::min(config.peer_channel_config_limits.their_to_self_delay, MAX_LOCAL_BREAKDOWN_TIMEOUT);
13971397
if msg.to_self_delay > max_delay_acceptable {
1398-
return Err(ChannelError::Close(format!("They wanted our payments to be delayed by a needlessly long period. Upper limit: {}. Actual: {}", msg.to_self_delay, max_delay_acceptable)));
1398+
return Err(ChannelError::Close(format!("They wanted our payments to be delayed by a needlessly long period. Upper limit: {}. Actual: {}", max_delay_acceptable, msg.to_self_delay)));
13991399
}
14001400
if msg.max_accepted_htlcs < 1 {
14011401
return Err(ChannelError::Close("0 max_accepted_htlcs makes for a useless channel".to_owned()));
@@ -1424,7 +1424,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14241424
return Err(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)));
14251425
}
14261426
if msg.minimum_depth > config.peer_channel_config_limits.max_minimum_depth {
1427-
return Err(ChannelError::Close(format!("We consider the minimum depth to be unreasonably large. Expected minimum: ({}). Actual: ({})", msg.minimum_depth, config.peer_channel_config_limits.max_minimum_depth)));
1427+
return Err(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)));
14281428
}
14291429

14301430
let their_shutdown_scriptpubkey = if their_features.supports_upfront_shutdown_script() {
@@ -1438,7 +1438,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
14381438
None
14391439
// Peer is signaling upfront_shutdown and has provided a non-accepted scriptpubkey format. Fail the channel
14401440
} else {
1441-
return Err(ChannelError::Close(format!("Peer is signaling upfront_shutdown but has provided a non-accepted scriptpubkey format. scirptpubkey: ({})", script.to_bytes().to_hex())));
1441+
return Err(ChannelError::Close(format!("Peer is signaling upfront_shutdown but has provided a non-accepted scriptpubkey format. scriptpubkey: ({})", script.to_bytes().to_hex())));
14421442
}
14431443
},
14441444
// Peer is signaling upfront shutdown but don't opt-out with correct mechanism (a.k.a 0-length script). Peer looks buggy, we fail the channel
@@ -1785,7 +1785,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
17851785
return Err(ChannelError::Close("Remote side tried to send a 0-msat HTLC".to_owned()));
17861786
}
17871787
if msg.amount_msat < self.our_htlc_minimum_msat {
1788-
return Err(ChannelError::Close(format!("Remote side tried to send less than our minimum HTLC value. lower limit: ({}). actual: ({})", msg.amount_msat, self.our_htlc_minimum_msat)));
1788+
return Err(ChannelError::Close(format!("Remote side tried to send less than our minimum HTLC value. Lower limit: ({}). Actual: ({})", self.our_htlc_minimum_msat, msg.amount_msat)));
17891789
}
17901790

17911791
let (inbound_htlc_count, htlc_inbound_value_msat) = self.get_inbound_pending_htlc_stats();
@@ -1867,7 +1867,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
18671867
}
18681868

18691869
if self.next_remote_htlc_id != msg.htlc_id {
1870-
return Err(ChannelError::Close(format!("Remote skipped HTLC ID ({})", self.next_remote_htlc_id)));
1870+
return Err(ChannelError::Close(format!("Remote skipped HTLC ID (skipped ID: {})", self.next_remote_htlc_id)));
18711871
}
18721872
if msg.cltv_expiry >= 500000000 {
18731873
return Err(ChannelError::Close("Remote provided CLTV expiry in seconds instead of block height".to_owned()));
@@ -3012,7 +3012,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
30123012
let funding_redeemscript = self.get_funding_redeemscript();
30133013
let (mut closing_tx, used_total_fee) = self.build_closing_transaction(msg.fee_satoshis, false);
30143014
if used_total_fee != msg.fee_satoshis {
3015-
return Err(ChannelError::Close(format!("Remote sent us a closing_signed with a fee greater than the value they can claim. actual: {}", msg.fee_satoshis)));
3015+
return Err(ChannelError::Close(format!("Remote sent us a closing_signed with a fee greater than the value they can claim. Fee in message: {}", msg.fee_satoshis)));
30163016
}
30173017
let mut sighash = hash_to_message!(&bip143::SighashComponents::new(&closing_tx).sighash_all(&closing_tx.input[0], &funding_redeemscript, self.channel_value_satoshis)[..]);
30183018

@@ -3070,7 +3070,7 @@ impl<ChanSigner: ChannelKeys> Channel<ChanSigner> {
30703070
if (proposed_sat_per_kw as u32) < our_min_feerate {
30713071
if let Some((last_feerate, _, _)) = self.last_sent_closing_fee {
30723072
if our_min_feerate >= last_feerate {
3073-
return Err(ChannelError::Close(format!("Unable to come to consensus about closing feerate, remote wanted something lower ({}) than our Background feerate. ({})", last_feerate, our_min_feerate)));
3073+
return Err(ChannelError::Close(format!("Unable to come to consensus about closing feerate, remote wanted something lower ({}) than our Background feerate ({}).", last_feerate, our_min_feerate)));
30743074
}
30753075
}
30763076
propose_new_feerate!(our_min_feerate);

lightning/src/util/test_utils.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -304,19 +304,19 @@ impl TestLogger {
304304
}
305305

306306
pub fn assert_log_contains(&self, module: String, line: String, count: usize) {
307-
let log_entries = self.lines.lock().unwrap();
308-
let l = log_entries.iter().find(|&(&(ref m, ref l), _c)| {
309-
m == &module && l.contains(line.as_str())
307+
let log_entries = self.lines.lock().unwrap();
308+
let l = log_entries.iter().find(|&(&(ref m, ref l), _c)| {
309+
m == &module && l.contains(line.as_str())
310310
}).map(|(&(ref _m, ref _l),c) | { c });
311-
assert_eq!(l.unwrap(), &count)
311+
assert_eq!(l, Some(&count))
312312
}
313313

314-
pub fn assert_log_regex(&self, module: String, line: regex::Regex, count: usize) {
314+
pub fn assert_log_regex(&self, module: String, pattern: regex::Regex, count: usize) {
315315
let log_entries = self.lines.lock().unwrap();
316316
let l = log_entries.iter().find(|&(&(ref m, ref l), _c)| {
317-
m == &module && line.is_match(&l)
317+
m == &module && pattern.is_match(&l)
318318
}).map(|(&(ref _m, ref _l),c) | { c });
319-
assert_eq!(l.unwrap(), &count)
319+
assert_eq!(l, Some(&count))
320320
}
321321
}
322322

0 commit comments

Comments
 (0)