@@ -4706,11 +4706,13 @@ fn check_v2_funding_inputs_sufficient(
4706
4706
is_splice: bool, funding_feerate_sat_per_1000_weight: u32,
4707
4707
) -> Result<u64, ChannelError> {
4708
4708
let mut total_input_witness_weight = Weight::from_wu(funding_inputs.iter().map(|(_, _, w)| w.to_wu()).sum());
4709
+ let mut funding_inputs_len = funding_inputs.len();
4709
4710
if is_initiator && is_splice {
4710
- // consider the weight of the witness needed for spending the old funding transaction
4711
+ // consider the weight of the input and witness needed for spending the old funding transaction
4712
+ funding_inputs_len += 1;
4711
4713
total_input_witness_weight += Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT);
4712
4714
}
4713
- let estimated_fee = estimate_v2_funding_transaction_fee(is_initiator, funding_inputs.len() , total_input_witness_weight, funding_feerate_sat_per_1000_weight);
4715
+ let estimated_fee = estimate_v2_funding_transaction_fee(is_initiator, funding_inputs_len , total_input_witness_weight, funding_feerate_sat_per_1000_weight);
4714
4716
4715
4717
let mut total_input_sats = 0u64;
4716
4718
for (idx, input) in funding_inputs.iter().enumerate() {
@@ -12953,7 +12955,7 @@ mod tests {
12953
12955
true,
12954
12956
2000,
12955
12957
).unwrap(),
12956
- 1948 ,
12958
+ 2268 ,
12957
12959
);
12958
12960
12959
12961
// negative case, inputs clearly insufficient
@@ -12969,13 +12971,13 @@ mod tests {
12969
12971
);
12970
12972
assert_eq!(
12971
12973
format!("{:?}", res.err().unwrap()),
12972
- "Warn: Total input amount 100000 is lower than needed for contribution 220000, considering fees of 1410 . Need more inputs.",
12974
+ "Warn: Total input amount 100000 is lower than needed for contribution 220000, considering fees of 1730 . Need more inputs.",
12973
12975
);
12974
12976
}
12975
12977
12976
12978
// barely covers
12977
12979
{
12978
- let expected_fee: u64 = 1948 ;
12980
+ let expected_fee: u64 = 2268 ;
12979
12981
assert_eq!(
12980
12982
check_v2_funding_inputs_sufficient(
12981
12983
(300_000 - expected_fee - 20) as i64,
@@ -13005,7 +13007,7 @@ mod tests {
13005
13007
);
13006
13008
assert_eq!(
13007
13009
format!("{:?}", res.err().unwrap()),
13008
- "Warn: Total input amount 300000 is lower than needed for contribution 298032, considering fees of 2143 . Need more inputs.",
13010
+ "Warn: Total input amount 300000 is lower than needed for contribution 298032, considering fees of 2495 . Need more inputs.",
13009
13011
);
13010
13012
}
13011
13013
0 commit comments