@@ -4688,13 +4688,12 @@ fn estimate_v2_funding_transaction_fee(
4688
4688
#[cfg(splicing)]
4689
4689
pub(super) fn check_v2_funding_inputs_sufficient(
4690
4690
contribution_amount: i64, funding_inputs: &[(TxIn, Transaction, Weight)], is_initiator: bool,
4691
- extra_common_input_weight: Option<Weight> , funding_feerate_sat_per_1000_weight: u32,
4691
+ is_splice: bool , funding_feerate_sat_per_1000_weight: u32,
4692
4692
) -> Result<u64, ChannelError> {
4693
4693
let mut total_input_witness_weight = Weight::from_wu(funding_inputs.iter().map(|(_, _, w)| w.to_wu()).sum());
4694
- if is_initiator {
4695
- if let Some(extra) = extra_common_input_weight {
4696
- total_input_witness_weight += extra;
4697
- }
4694
+ if is_initiator && is_splice {
4695
+ // consider the weight of the witness needed for spending the old funding transaction
4696
+ total_input_witness_weight += Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT);
4698
4697
}
4699
4698
let estimated_fee = estimate_v2_funding_transaction_fee(is_initiator, funding_inputs.len(), total_input_witness_weight, funding_feerate_sat_per_1000_weight);
4700
4699
@@ -8425,8 +8424,7 @@ impl<SP: Deref> FundedChannel<SP> where
8425
8424
8426
8425
// Check that inputs are sufficient to cover our contribution.
8427
8426
// Extra common weight is the weight for spending the old funding
8428
- let extra_input_weight = Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT);
8429
- let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, Some(extra_input_weight), funding_feerate_per_kw)
8427
+ let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, true, funding_feerate_per_kw)
8430
8428
.map_err(|err| APIError::APIMisuseError { err: format!(
8431
8429
"Insufficient inputs for splicing; channel ID {}, err {}",
8432
8430
self.context.channel_id(), err,
@@ -12959,9 +12957,7 @@ mod tests {
12959
12957
#[cfg(splicing)]
12960
12958
#[test]
12961
12959
fn test_check_v2_funding_inputs_sufficient() {
12962
- use crate::ln::chan_utils::FUNDING_TRANSACTION_WITNESS_WEIGHT;
12963
12960
use crate::ln::channel::check_v2_funding_inputs_sufficient;
12964
- use bitcoin::Weight;
12965
12961
12966
12962
// positive case, inputs well over intended contribution
12967
12963
assert_eq!(
@@ -12972,7 +12968,7 @@ mod tests {
12972
12968
funding_input_sats(100_000),
12973
12969
],
12974
12970
true,
12975
- Some(Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT)) ,
12971
+ true ,
12976
12972
2000,
12977
12973
).unwrap(),
12978
12974
1948,
@@ -12986,7 +12982,7 @@ mod tests {
12986
12982
funding_input_sats(100_000),
12987
12983
],
12988
12984
true,
12989
- Some(Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT)) ,
12985
+ true ,
12990
12986
2000,
12991
12987
);
12992
12988
assert_eq!(
@@ -13006,7 +13002,7 @@ mod tests {
13006
13002
funding_input_sats(100_000),
13007
13003
],
13008
13004
true,
13009
- Some(Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT)) ,
13005
+ true ,
13010
13006
2000,
13011
13007
).unwrap(),
13012
13008
expected_fee,
@@ -13022,7 +13018,7 @@ mod tests {
13022
13018
funding_input_sats(100_000),
13023
13019
],
13024
13020
true,
13025
- Some(Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT)) ,
13021
+ true ,
13026
13022
2200,
13027
13023
);
13028
13024
assert_eq!(
@@ -13042,7 +13038,7 @@ mod tests {
13042
13038
funding_input_sats(100_000),
13043
13039
],
13044
13040
false,
13045
- None ,
13041
+ false ,
13046
13042
2000,
13047
13043
).unwrap(),
13048
13044
expected_fee,
0 commit comments