@@ -57,7 +57,7 @@ use crate::ln::channelmanager::{
5757use crate::ln::interactivetxs::{
5858 calculate_change_output_value, get_output_weight, AbortReason, HandleTxCompleteResult,
5959 InteractiveTxConstructor, InteractiveTxConstructorArgs, InteractiveTxMessageSend,
60- InteractiveTxMessageSendResult, InteractiveTxSigningSession, OutputOwned, SharedOwnedOutput,
60+ InteractiveTxMessageSendResult, InteractiveTxSigningSession, SharedOwnedOutput,
6161 TX_COMMON_FIELDS_WEIGHT,
6262};
6363use crate::ln::msgs;
@@ -2756,24 +2756,12 @@ where
27562756 // Note: For the error case when the inputs are insufficient, it will be handled after
27572757 // the `calculate_change_output_value` call below
27582758 let mut funding_outputs = Vec::new();
2759- let mut expected_remote_shared_funding_output = None;
27602759
27612760 let shared_funding_output = TxOut {
27622761 value: Amount::from_sat(self.funding.get_value_satoshis()),
27632762 script_pubkey: self.funding.get_funding_redeemscript().to_p2wsh(),
27642763 };
27652764
2766- if self.funding.is_outbound() {
2767- funding_outputs.push(
2768- OutputOwned::Shared(SharedOwnedOutput::new(
2769- shared_funding_output, self.dual_funding_context.our_funding_satoshis,
2770- ))
2771- );
2772- } else {
2773- let TxOut { value, script_pubkey } = shared_funding_output;
2774- expected_remote_shared_funding_output = Some((script_pubkey, value.to_sat()));
2775- }
2776-
27772765 // Optionally add change output
27782766 let change_script = if let Some(script) = change_destination_opt {
27792767 script
@@ -2783,7 +2771,7 @@ where
27832771 };
27842772 let change_value_opt = calculate_change_output_value(
27852773 self.funding.is_outbound(), self.dual_funding_context.our_funding_satoshis,
2786- &funding_inputs, &funding_outputs,
2774+ &shared_funding_output.script_pubkey, & funding_inputs, &funding_outputs,
27872775 self.dual_funding_context.funding_feerate_sat_per_1000_weight,
27882776 change_script.minimal_non_dust().to_sat(),
27892777 )?;
@@ -2798,7 +2786,7 @@ where
27982786 // Check dust limit again
27992787 if change_value_decreased_with_fee > self.context.holder_dust_limit_satoshis {
28002788 change_output.value = Amount::from_sat(change_value_decreased_with_fee);
2801- funding_outputs.push(OutputOwned::Single( change_output) );
2789+ funding_outputs.push(change_output);
28022790 }
28032791 }
28042792
@@ -2811,8 +2799,8 @@ where
28112799 is_initiator: self.funding.is_outbound(),
28122800 funding_tx_locktime: self.dual_funding_context.funding_tx_locktime,
28132801 inputs_to_contribute: funding_inputs,
2802+ shared_funding_output: SharedOwnedOutput::new(shared_funding_output, self.dual_funding_context.our_funding_satoshis),
28142803 outputs_to_contribute: funding_outputs,
2815- expected_remote_shared_funding_output,
28162804 };
28172805 let mut tx_constructor = InteractiveTxConstructor::new(constructor_args)?;
28182806 let msg = tx_constructor.take_initiator_first_message();
@@ -11809,6 +11797,10 @@ where
1180911797 funding_feerate_sat_per_1000_weight: msg.funding_feerate_sat_per_1000_weight,
1181011798 our_funding_inputs: our_funding_inputs.clone(),
1181111799 };
11800+ let shared_funding_output = TxOut {
11801+ value: Amount::from_sat(funding.get_value_satoshis()),
11802+ script_pubkey: funding.get_funding_redeemscript().to_p2wsh(),
11803+ };
1181211804
1181311805 let interactive_tx_constructor = Some(InteractiveTxConstructor::new(
1181411806 InteractiveTxConstructorArgs {
@@ -11820,8 +11812,8 @@ where
1182011812 funding_tx_locktime: dual_funding_context.funding_tx_locktime,
1182111813 is_initiator: false,
1182211814 inputs_to_contribute: our_funding_inputs,
11815+ shared_funding_output: SharedOwnedOutput::new(shared_funding_output, our_funding_satoshis),
1182311816 outputs_to_contribute: Vec::new(),
11824- expected_remote_shared_funding_output: Some((funding.get_funding_redeemscript().to_p2wsh(), funding.get_value_satoshis())),
1182511817 }
1182611818 ).map_err(|_| ChannelError::Close((
1182711819 "V2 channel rejected due to sender error".into(),
0 commit comments