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 test_fee_estimator = &TestFeeEstimator{ sat_per_kw };
1690
+
let fee_estimator = LowerBoundedFeeEstimator::new(test_fee_estimator);
1691
+
let fee_rate_strategy = FeerateStrategy::ForceBump;
1692
+
let confirmation_target = ConfirmationTarget::UrgentOnChainSweep;
1693
+
1694
+
{
1695
+
// Check underflow doesn't occur
1696
+
let predicted_weight_units = 1000;
1697
+
let input_satoshis = 505;
1698
+
1699
+
let logger = TestLogger::new();
1700
+
let bumped_fee_rate = feerate_bump(predicted_weight_units, input_satoshis,546,253,&fee_rate_strategy, confirmation_target,&fee_estimator,&logger);
1701
+
assert!(bumped_fee_rate.is_none());
1702
+
logger.assert_log_regex("lightning::chain::package", regex::Regex::new(r"Can't bump new claiming tx, input amount 505 is too small").unwrap(),1);
1703
+
}
1704
+
1705
+
{
1706
+
// Check post-25%-bump-underflow scenario satisfying the following constraints:
1707
+
// input - fee = 546
1708
+
// input - fee * 1.25 = -1
1709
+
1710
+
// We accomplish that scenario with the following values:
1711
+
// input = 2734
1712
+
// fee = 2188
1713
+
1714
+
let predicted_weight_units = 1000;
1715
+
let input_satoshis = 2734;
1716
+
1717
+
let logger = TestLogger::new();
1718
+
let bumped_fee_rate = feerate_bump(predicted_weight_units, input_satoshis,546,2188,&fee_rate_strategy, confirmation_target,&fee_estimator,&logger);
1719
+
assert!(bumped_fee_rate.is_none());
1720
+
logger.assert_log_regex("lightning::chain::package", regex::Regex::new(r"Can't bump new claiming tx, output amount 0 would end up below dust threshold 546").unwrap(),1);
1721
+
}
1722
+
1723
+
{
1724
+
// Check that an output amount of 0 is caught
1725
+
let predicted_weight_units = 1000;
1726
+
let input_satoshis = 506;
1727
+
1728
+
let logger = TestLogger::new();
1729
+
let bumped_fee_rate = feerate_bump(predicted_weight_units, input_satoshis,546,253,&fee_rate_strategy, confirmation_target,&fee_estimator,&logger);
1730
+
assert!(bumped_fee_rate.is_none());
1731
+
logger.assert_log_regex("lightning::chain::package", regex::Regex::new(r"Can't bump new claiming tx, output amount 0 would end up below dust threshold 546").unwrap(),1);
1732
+
}
1733
+
1734
+
{
1735
+
// Check that dust_threshold - 1 is blocked
1736
+
let predicted_weight_units = 1000;
1737
+
let input_satoshis = 1051;
1738
+
1739
+
let logger = TestLogger::new();
1740
+
let bumped_fee_rate = feerate_bump(predicted_weight_units, input_satoshis,546,253,&fee_rate_strategy, confirmation_target,&fee_estimator,&logger);
1741
+
assert!(bumped_fee_rate.is_none());
1742
+
logger.assert_log_regex("lightning::chain::package", regex::Regex::new(r"Can't bump new claiming tx, output amount 545 would end up below dust threshold 546").unwrap(),1);
1743
+
}
1744
+
1745
+
{
1746
+
let predicted_weight_units = 1000;
1747
+
let input_satoshis = 1052;
1748
+
1749
+
let logger = TestLogger::new();
1750
+
let bumped_fee_rate = feerate_bump(predicted_weight_units, input_satoshis,546,253,&fee_rate_strategy, confirmation_target,&fee_estimator,&logger).unwrap();
1751
+
assert_eq!(bumped_fee_rate,(506,506));
1752
+
logger.assert_log_regex("lightning::chain::package", regex::Regex::new(r"Naive fee bump of 63s does not meet min relay fee requirements of 253s").unwrap(),1);
0 commit comments