@@ -4606,13 +4606,12 @@ fn estimate_v2_funding_transaction_fee(
46064606#[cfg(splicing)]
46074607pub(super) fn check_v2_funding_inputs_sufficient(
46084608 contribution_amount: i64, funding_inputs: &[(TxIn, Transaction, Weight)], is_initiator: bool,
4609- extra_common_input_weight: Option<Weight> , funding_feerate_sat_per_1000_weight: u32,
4609+ is_splice: bool , funding_feerate_sat_per_1000_weight: u32,
46104610) -> Result<u64, ChannelError> {
46114611 let mut total_input_witness_weight = Weight::from_wu(funding_inputs.iter().map(|(_, _, w)| w.to_wu()).sum());
4612- if is_initiator {
4613- if let Some(extra) = extra_common_input_weight {
4614- total_input_witness_weight += extra;
4615- }
4612+ if is_initiator && is_splice {
4613+ // consider the weight of the witness needed for spending the old funding transaction
4614+ total_input_witness_weight += Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT);
46164615 }
46174616 let estimated_fee = estimate_v2_funding_transaction_fee(is_initiator, funding_inputs.len(), total_input_witness_weight, funding_feerate_sat_per_1000_weight);
46184617
@@ -8295,8 +8294,7 @@ impl<SP: Deref> FundedChannel<SP> where
82958294
82968295 // Check that inputs are sufficient to cover our contribution.
82978296 // Extra common weight is the weight for spending the old funding
8298- let extra_input_weight = Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT);
8299- let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, Some(extra_input_weight), funding_feerate_per_kw)
8297+ let _fee = check_v2_funding_inputs_sufficient(our_funding_contribution_satoshis, &our_funding_inputs, true, true, funding_feerate_per_kw)
83008298 .map_err(|err| APIError::APIMisuseError { err: format!(
83018299 "Insufficient inputs for splicing; channel ID {}, err {}",
83028300 self.context.channel_id(), err,
@@ -12617,9 +12615,7 @@ mod tests {
1261712615 #[cfg(splicing)]
1261812616 #[test]
1261912617 fn test_check_v2_funding_inputs_sufficient() {
12620- use crate::ln::chan_utils::FUNDING_TRANSACTION_WITNESS_WEIGHT;
1262112618 use crate::ln::channel::check_v2_funding_inputs_sufficient;
12622- use bitcoin::Weight;
1262312619
1262412620 // positive case, inputs well over intended contribution
1262512621 assert_eq!(
@@ -12630,7 +12626,7 @@ mod tests {
1263012626 funding_input_sats(100_000),
1263112627 ],
1263212628 true,
12633- Some(Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT)) ,
12629+ true ,
1263412630 2000,
1263512631 ).unwrap(),
1263612632 1948,
@@ -12644,7 +12640,7 @@ mod tests {
1264412640 funding_input_sats(100_000),
1264512641 ],
1264612642 true,
12647- Some(Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT)) ,
12643+ true ,
1264812644 2000,
1264912645 );
1265012646 assert_eq!(
@@ -12664,7 +12660,7 @@ mod tests {
1266412660 funding_input_sats(100_000),
1266512661 ],
1266612662 true,
12667- Some(Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT)) ,
12663+ true ,
1266812664 2000,
1266912665 ).unwrap(),
1267012666 expected_fee,
@@ -12680,7 +12676,7 @@ mod tests {
1268012676 funding_input_sats(100_000),
1268112677 ],
1268212678 true,
12683- Some(Weight::from_wu(FUNDING_TRANSACTION_WITNESS_WEIGHT)) ,
12679+ true ,
1268412680 2200,
1268512681 );
1268612682 assert_eq!(
@@ -12700,7 +12696,7 @@ mod tests {
1270012696 funding_input_sats(100_000),
1270112697 ],
1270212698 false,
12703- None ,
12699+ false ,
1270412700 2000,
1270512701 ).unwrap(),
1270612702 expected_fee,
0 commit comments