@@ -2243,26 +2243,27 @@ impl<SP: Deref> PendingV2Channel<SP> where SP::Target: SignerProvider {
22432243 // Note: For the error case when the inputs are insufficient, it will be handled after
22442244 // the `calculate_change_output_value` call below
22452245 let mut funding_outputs = Vec::new();
2246- let funding_output_value_satoshis = self.funding.get_value_satoshis();
2247- let funding_output_script_pubkey = self.funding.get_funding_redeemscript().to_p2wsh();
2248- let expected_remote_shared_funding_output = if self.funding.is_outbound() {
2249- let tx_out = TxOut {
2250- value: Amount::from_sat(funding_output_value_satoshis),
2251- script_pubkey: funding_output_script_pubkey,
2252- };
2253- funding_outputs.push(
2254- if self.dual_funding_context.their_funding_satoshis.unwrap_or(0) == 0 {
2255- OutputOwned::SharedControlFullyOwned(tx_out)
2256- } else {
2246+ let mut expected_remote_shared_funding_output = None;
2247+
2248+ let shared_funding_output = TxOut {
2249+ value: Amount::from_sat(self.funding.get_value_satoshis()),
2250+ script_pubkey: self.funding.get_funding_redeemscript().to_p2wsh(),
2251+ };
2252+
2253+ if self.funding.is_outbound() {
2254+ if self.dual_funding_context.their_funding_satoshis.unwrap_or(0) == 0 {
2255+ funding_outputs.push(OutputOwned::SharedControlFullyOwned(shared_funding_output));
2256+ } else {
2257+ funding_outputs.push(
22572258 OutputOwned::Shared(SharedOwnedOutput::new(
2258- tx_out , self.dual_funding_context.our_funding_satoshis
2259+ shared_funding_output , self.dual_funding_context.our_funding_satoshis,
22592260 ))
2260- }
2261- );
2262- None
2261+ );
2262+ }
22632263 } else {
2264- Some((funding_output_script_pubkey, funding_output_value_satoshis))
2265- };
2264+ let TxOut { value, script_pubkey } = shared_funding_output;
2265+ expected_remote_shared_funding_output = Some((script_pubkey, value.to_sat()));
2266+ }
22662267
22672268 // Optionally add change output
22682269 let change_script = if let Some(script) = change_destination_opt {
0 commit comments