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
let channel_value_msat = channel_value_satoshis *1000;
468
467
if push_msat > channel_value_msat {
469
-
returnErr(APIError::APIMisuseError{err:format!("push value ({}) was larger than channel_value ({})", push_msat, channel_value_msat)});
468
+
returnErr(APIError::APIMisuseError{err:format!("Push value ({}) was larger than channel_value ({})", push_msat, channel_value_msat)});
470
469
}
471
470
if config.own_channel_config.our_to_self_delay < BREAKDOWN_TIMEOUT{
472
471
returnErr(APIError::APIMisuseError{err:format!("Configured with an unreasonable our_to_self_delay ({}) putting user funds at risks", config.own_channel_config.our_to_self_delay)});
if config.own_channel_config.our_to_self_delay < BREAKDOWN_TIMEOUT{
590
-
returnErr(ChannelError::Close(format!("Configured with an unreasonable our_to_self_delay ({}) putting user funds at risks", config.own_channel_config.our_to_self_delay)));
589
+
returnErr(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)));
591
590
}
592
591
593
592
// Check sanity of message fields:
594
593
if msg.funding_satoshis >= MAX_FUNDING_SATOSHIS{
595
-
returnErr(ChannelError::Close(format!("funding must be smaller than {}. It was {}", msg.funding_satoshis,MAX_FUNDING_SATOSHIS)));
594
+
returnErr(ChannelError::Close(format!("Funding must be smaller than {}. It was {}", msg.funding_satoshis,MAX_FUNDING_SATOSHIS)));
596
595
}
597
596
if msg.channel_reserve_satoshis > msg.funding_satoshis{
598
-
returnErr(ChannelError::Close(format!("Bogus channel_reserve_satoshis({}). must be not greater than funding_satoshis: {}", msg.channel_reserve_satoshis, msg.funding_satoshis)));
597
+
returnErr(ChannelError::Close(format!("Bogus channel_reserve_satoshis({}). Must be not greater than funding_satoshis: {}", msg.channel_reserve_satoshis, msg.funding_satoshis)));
599
598
}
600
599
let funding_value = (msg.funding_satoshis - msg.channel_reserve_satoshis)*1000;
returnErr(ChannelError::Close(format!("dust_limit_satoshis {} was larger than funding_satoshis {}. Peer never wants payout outputs?", msg.dust_limit_satoshis, msg.funding_satoshis)));
606
605
}
607
606
if msg.dust_limit_satoshis > msg.channel_reserve_satoshis{
608
-
returnErr(ChannelError::Close(format!("Bogus; channel reserve({}) is less than dust limit ({})", msg.channel_reserve_satoshis, msg.dust_limit_satoshis)));
607
+
returnErr(ChannelError::Close(format!("Bogus; channel reserve({}) is less than dust limit ({})", msg.channel_reserve_satoshis, msg.dust_limit_satoshis)));
609
608
}
610
609
let full_channel_value_msat = (msg.funding_satoshis - msg.channel_reserve_satoshis)*1000;
611
610
if msg.htlc_minimum_msat >= full_channel_value_msat {
612
-
returnErr(ChannelError::Close(format!("Minimum htlc value ({}) is full channel value ({})", msg.htlc_minimum_msat, full_channel_value_msat)));
611
+
returnErr(ChannelError::Close(format!("Minimum htlc value ({}) was larger than full channel value ({})", msg.htlc_minimum_msat, full_channel_value_msat)));
let max_to_self_delay = u16::min(config.peer_channel_config_limits.their_to_self_delay,MAX_LOCAL_BREAKDOWN_TIMEOUT);
617
616
if msg.to_self_delay > max_to_self_delay {
618
-
returnErr(ChannelError::Close(format!("They wanted our payments to be delayed by a needlessly long period. upper limit: {}. actual: {}", max_to_self_delay, msg.to_self_delay)));
617
+
returnErr(ChannelError::Close(format!("They wanted our payments to be delayed by a needlessly long period. Upper limit: {}. Actual: {}", max_to_self_delay, msg.to_self_delay)));
619
618
}
620
619
if msg.max_accepted_htlcs < 1{
621
-
returnErr(ChannelError::Close("0 max_accpted_htlcs makes for a useless channel".to_owned()));
620
+
returnErr(ChannelError::Close("0 max_accepted_htlcs makes for a useless channel".to_owned()));
622
621
}
623
622
if msg.max_accepted_htlcs > 483{
624
-
returnErr(ChannelError::Close(format!("max_accpted_htlcs was {}. it must not be larger than 483", msg.max_accepted_htlcs)));
623
+
returnErr(ChannelError::Close(format!("max_accepted_htlcs was {}. It must not be larger than 483", msg.max_accepted_htlcs)));
625
624
}
626
625
627
626
// Now check against optional parameters as set by config...
628
627
if msg.funding_satoshis < config.peer_channel_config_limits.min_funding_satoshis{
629
-
returnErr(ChannelError::Close(format!("funding satoshis ({}) is less than the user specified limit ({})", msg.funding_satoshis, config.peer_channel_config_limits.min_funding_satoshis)));
628
+
returnErr(ChannelError::Close(format!("Funding satoshis ({}) is less than the user specified limit ({})", msg.funding_satoshis, config.peer_channel_config_limits.min_funding_satoshis)));
630
629
}
631
630
if msg.htlc_minimum_msat > config.peer_channel_config_limits.max_htlc_minimum_msat{
632
-
returnErr(ChannelError::Close(format!("htlc minimum msat ({}) is higher than the user specified limit ({})", msg.htlc_minimum_msat, config.peer_channel_config_limits.max_htlc_minimum_msat)));
631
+
returnErr(ChannelError::Close(format!("htlc_minimum_msat ({}) is higher than the user specified limit ({})", msg.htlc_minimum_msat, config.peer_channel_config_limits.max_htlc_minimum_msat)));
633
632
}
634
633
if msg.max_htlc_value_in_flight_msat < config.peer_channel_config_limits.min_max_htlc_value_in_flight_msat{
635
-
returnErr(ChannelError::Close(format!("max htlc value in flight msat ({}) is less than the user specified limit ({})", msg.max_htlc_value_in_flight_msat, config.peer_channel_config_limits.min_max_htlc_value_in_flight_msat)));
634
+
returnErr(ChannelError::Close(format!("max_htlc_value_in_flight_msat ({}) is less than the user specified limit ({})", msg.max_htlc_value_in_flight_msat, config.peer_channel_config_limits.min_max_htlc_value_in_flight_msat)));
636
635
}
637
636
if msg.channel_reserve_satoshis > config.peer_channel_config_limits.max_channel_reserve_satoshis{
638
-
returnErr(ChannelError::Close(format!("channel reserve satoshis ({}) is higher than the user specified limit ({})", msg.channel_reserve_satoshis, config.peer_channel_config_limits.max_channel_reserve_satoshis)));
637
+
returnErr(ChannelError::Close(format!("channel_reserve_satoshis ({}) is higher than the user specified limit ({})", msg.channel_reserve_satoshis, config.peer_channel_config_limits.max_channel_reserve_satoshis)));
639
638
}
640
639
if msg.max_accepted_htlcs < config.peer_channel_config_limits.min_max_accepted_htlcs{
641
-
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)));
640
+
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)));
642
641
}
643
642
if msg.dust_limit_satoshis < config.peer_channel_config_limits.min_dust_limit_satoshis{
644
-
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)));
643
+
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)));
645
644
}
646
645
if msg.dust_limit_satoshis > config.peer_channel_config_limits.max_dust_limit_satoshis{
647
-
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)));
646
+
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)));
648
647
}
649
648
650
649
// Convert things into internal flags and prep our state:
let our_dust_limit_satoshis = Channel::<ChanSigner>::derive_our_dust_limit_satoshis(background_feerate);
664
663
let remote_channel_reserve_satoshis = Channel::<ChanSigner>::get_remote_channel_reserve_satoshis(msg.funding_satoshis);
665
664
if remote_channel_reserve_satoshis < our_dust_limit_satoshis {
666
-
returnErr(ChannelError::Close(format!("Suitable channel reserve not found. remote_channel_reserve was ({}). our_dusts_limit_satoshis is ({}) .aborting", remote_channel_reserve_satoshis, our_dust_limit_satoshis)));
665
+
returnErr(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)));
667
666
}
668
667
if msg.channel_reserve_satoshis < our_dust_limit_satoshis {
669
668
returnErr(ChannelError::Close(format!("channel_reserve_satoshis ({}) is small than our dust limit ({})", msg.channel_reserve_satoshis, our_dust_limit_satoshis)));
let funders_amount_msat = msg.funding_satoshis*1000 - msg.push_msat;
678
677
let lower_limit = background_feerate asu64*COMMITMENT_TX_BASE_WEIGHT;
679
678
if funders_amount_msat < lower_limit {
680
-
returnErr(ChannelError::Close(format!("Insufficient funding amount ({}) for initial commitment. must be at least ({})", funders_amount_msat, lower_limit)));
679
+
returnErr(ChannelError::Close(format!("Insufficient funding amount ({}) for initial commitment. Must be at least {}", funders_amount_msat, lower_limit)));
returnErr(ChannelError::Close(format!("Peer never wants payout outputs? dust_limit_satoshis was {}", msg.dust_limit_satoshis)));
1379
1378
}
1380
1379
if msg.channel_reserve_satoshis > self.channel_value_satoshis{
1381
-
returnErr(ChannelError::Close(format!("Bogus channel_reserve_satoshis({}). must not be greater than ({})", msg.channel_reserve_satoshis,self.channel_value_satoshis)));
1380
+
returnErr(ChannelError::Close(format!("Bogus channel_reserve_satoshis({}). Must not be greater than ({})", msg.channel_reserve_satoshis,self.channel_value_satoshis)));
1382
1381
}
1383
1382
if msg.dust_limit_satoshis > msg.channel_reserve_satoshis{
1384
-
returnErr(ChannelError::Close(format!("Bogus channel_reserve({}) and dust_limit ({})", msg.dust_limit_satoshis, msg.channel_reserve_satoshis)));
1383
+
returnErr(ChannelError::Close(format!("Bogus channel_reserve({}) and dust_limit ({})", msg.dust_limit_satoshis, msg.channel_reserve_satoshis)));
1385
1384
}
1386
1385
if msg.channel_reserve_satoshis < self.our_dust_limit_satoshis{
1387
1386
returnErr(ChannelError::Close(format!("Peer never wants payout outputs? channel_reserve_satoshis was ({}). our_dust_limit is ({})", msg.channel_reserve_satoshis,self.our_dust_limit_satoshis)));
let full_channel_value_msat = (self.channel_value_satoshis - msg.channel_reserve_satoshis)*1000;
1394
1393
if msg.htlc_minimum_msat >= full_channel_value_msat {
1395
-
returnErr(ChannelError::Close(format!("Minimum htlc value({}) is full channel value ({})", msg.htlc_minimum_msat, full_channel_value_msat)));
1394
+
returnErr(ChannelError::Close(format!("Minimum htlc value({}) is full channel value ({})", msg.htlc_minimum_msat, full_channel_value_msat)));
1396
1395
}
1397
1396
let max_delay_acceptable = u16::min(config.peer_channel_config_limits.their_to_self_delay,MAX_LOCAL_BREAKDOWN_TIMEOUT);
1398
1397
if msg.to_self_delay > max_delay_acceptable {
1399
-
returnErr(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
+
returnErr(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)));
1400
1399
}
1401
1400
if msg.max_accepted_htlcs < 1{
1402
1401
returnErr(ChannelError::Close("0 max_accepted_htlcs makes for a useless channel".to_owned()));
1403
1402
}
1404
1403
if msg.max_accepted_htlcs > 483{
1405
-
returnErr(ChannelError::Close(format!("max_accepted_htlcs was {} it must not be larger than 483", msg.max_accepted_htlcs)));
1404
+
returnErr(ChannelError::Close(format!("max_accepted_htlcs was {}. It must not be larger than 483", msg.max_accepted_htlcs)));
1406
1405
}
1407
1406
1408
1407
// Now check against optional parameters as set by config...
1409
1408
if msg.htlc_minimum_msat > config.peer_channel_config_limits.max_htlc_minimum_msat{
1410
-
returnErr(ChannelError::Close(format!("htlc minimum msat ({}) is higher than the user specified limit ({})", msg.htlc_minimum_msat, config.peer_channel_config_limits.max_htlc_minimum_msat)));
1409
+
returnErr(ChannelError::Close(format!("htlc_minimum_msat ({}) is higher than the user specified limit ({})", msg.htlc_minimum_msat, config.peer_channel_config_limits.max_htlc_minimum_msat)));
1411
1410
}
1412
1411
if msg.max_htlc_value_in_flight_msat < config.peer_channel_config_limits.min_max_htlc_value_in_flight_msat{
1413
-
returnErr(ChannelError::Close(format!("max htlc value in flight msat ({}) is less than the user specified limit ({})", msg.max_htlc_value_in_flight_msat, config.peer_channel_config_limits.min_max_htlc_value_in_flight_msat)));
1412
+
returnErr(ChannelError::Close(format!("max_htlc_value_in_flight_msat ({}) is less than the user specified limit ({})", msg.max_htlc_value_in_flight_msat, config.peer_channel_config_limits.min_max_htlc_value_in_flight_msat)));
1414
1413
}
1415
1414
if msg.channel_reserve_satoshis > config.peer_channel_config_limits.max_channel_reserve_satoshis{
1416
-
returnErr(ChannelError::Close(format!("channel reserve satoshis ({}) is higher than the user specified limit ({})", msg.channel_reserve_satoshis, config.peer_channel_config_limits.max_channel_reserve_satoshis)));
1415
+
returnErr(ChannelError::Close(format!("channel_reserve_satoshis ({}) is higher than the user specified limit ({})", msg.channel_reserve_satoshis, config.peer_channel_config_limits.max_channel_reserve_satoshis)));
1417
1416
}
1418
1417
if msg.max_accepted_htlcs < config.peer_channel_config_limits.min_max_accepted_htlcs{
1419
-
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)));
1418
+
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)));
1420
1419
}
1421
1420
if msg.dust_limit_satoshis < config.peer_channel_config_limits.min_dust_limit_satoshis{
1422
-
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)));
1421
+
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)));
1423
1422
}
1424
1423
if msg.dust_limit_satoshis > config.peer_channel_config_limits.max_dust_limit_satoshis{
1425
-
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)));
1424
+
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)));
1426
1425
}
1427
1426
if msg.minimum_depth > config.peer_channel_config_limits.max_minimum_depth{
1428
-
returnErr(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
+
returnErr(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)));
1429
1428
}
1430
1429
1431
1430
let their_shutdown_scriptpubkey = if their_features.supports_upfront_shutdown_script(){
let pending_value_to_self_msat = self.value_to_self_msat - htlc_outbound_value_msat;
3721
3720
if pending_value_to_self_msat < amount_msat {
3722
-
returnErr(ChannelError::Ignore(format!("Cannot send value that would overdraw remaining funds. amount: {}, pending value to self {}", amount_msat, pending_value_to_self_msat)));
3721
+
returnErr(ChannelError::Ignore(format!("Cannot send value that would overdraw remaining funds. Amount: {}, pending value to self {}", amount_msat, pending_value_to_self_msat)));
3723
3722
}
3724
3723
3725
3724
// The `+1` is for the HTLC currently being added to the commitment tx and
if pending_value_to_self_msat - amount_msat < local_commit_tx_fee_msat {
3731
-
returnErr(ChannelError::Ignore(format!("Cannot send value that would not leave enough to pay for fees. pending value to self: {}. local_commit_tx_fee {}", pending_value_to_self_msat, local_commit_tx_fee_msat)));
3730
+
returnErr(ChannelError::Ignore(format!("Cannot send value that would not leave enough to pay for fees. Pending value to self: {}. local_commit_tx_fee {}", pending_value_to_self_msat, local_commit_tx_fee_msat)));
3732
3731
}
3733
3732
3734
3733
// Check self.local_channel_reserve_satoshis (the amount we must keep as
0 commit comments