@@ -1766,7 +1766,7 @@ where
17661766
17671767 pub fn funding_tx_constructed<L: Deref>(
17681768 &mut self, signing_session: InteractiveTxSigningSession, logger: &L,
1769- ) -> Result<( msgs::CommitmentSigned, Option<Transaction>) , ChannelError>
1769+ ) -> Result<msgs::CommitmentSigned, ChannelError>
17701770 where
17711771 L::Target: Logger,
17721772 {
@@ -1786,7 +1786,7 @@ where
17861786 #[rustfmt::skip]
17871787 pub fn commitment_signed<L: Deref>(
17881788 &mut self, msg: &msgs::CommitmentSigned, best_block: BestBlock, signer_provider: &SP, logger: &L
1789- ) -> Result<(Option<ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>>, Option<ChannelMonitorUpdate>), ChannelError>
1789+ ) -> Result<(Option<ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>>, Option<ChannelMonitorUpdate>, Option<Transaction> ), ChannelError>
17901790 where
17911791 L::Target: Logger
17921792 {
@@ -1813,7 +1813,7 @@ where
18131813 pending_splice: None,
18141814 };
18151815 let res = funded_channel.commitment_signed_initial_v2(msg, best_block, signer_provider, logger)
1816- .map(|monitor| (Some(monitor), None))
1816+ .map(|( monitor, funding_tx_opt) | (Some(monitor), None, funding_tx_opt ))
18171817 // TODO: Change to `inspect_err` when MSRV is high enough.
18181818 .map_err(|err| {
18191819 // We always expect a `ChannelError` close.
@@ -1840,15 +1840,15 @@ where
18401840 let res = if has_negotiated_pending_splice && !session_received_commitment_signed {
18411841 funded_channel
18421842 .splice_initial_commitment_signed(msg, logger)
1843- .map(|monitor_update_opt| (None, monitor_update_opt))
1843+ .map(|monitor_update_opt| (None, monitor_update_opt, None ))
18441844 } else {
18451845 funded_channel.commitment_signed(msg, logger)
1846- .map(|monitor_update_opt| (None, monitor_update_opt))
1846+ .map(|monitor_update_opt| (None, monitor_update_opt, None ))
18471847 };
18481848
18491849 #[cfg(not(splicing))]
18501850 let res = funded_channel.commitment_signed(msg, logger)
1851- .map(|monitor_update_opt| (None, monitor_update_opt));
1851+ .map(|monitor_update_opt| (None, monitor_update_opt, None ));
18521852
18531853 self.phase = ChannelPhase::Funded(funded_channel);
18541854 res
@@ -2916,7 +2916,7 @@ where
29162916 #[rustfmt::skip]
29172917 pub fn funding_tx_constructed<L: Deref>(
29182918 &mut self, mut signing_session: InteractiveTxSigningSession, logger: &L
2919- ) -> Result<( msgs::CommitmentSigned, Option<Transaction>) , ChannelError>
2919+ ) -> Result<msgs::CommitmentSigned, ChannelError>
29202920 where
29212921 L::Target: Logger
29222922 {
@@ -2954,7 +2954,8 @@ where
29542954 },
29552955 };
29562956
2957- let funding_tx_opt = if signing_session.local_inputs_count() == 0 {
2957+ // Check that we have the expected number of local inputs
2958+ if signing_session.local_inputs_count() == 0 {
29582959 debug_assert_eq!(our_funding_satoshis, 0);
29592960 if signing_session.provide_holder_witnesses(self.context.channel_id, Vec::new()).is_err() {
29602961 debug_assert!(
@@ -2965,10 +2966,7 @@ where
29652966 let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
29662967 return Err(ChannelError::Close((msg.to_owned(), reason)));
29672968 }
2968- None
2969- } else {
2970- Some(signing_session.unsigned_tx().build_unsigned_tx())
2971- };
2969+ }
29722970
29732971 let mut channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
29742972 channel_state.set_interactive_signing();
@@ -2978,7 +2976,7 @@ where
29782976 self.interactive_tx_constructor.take();
29792977 self.interactive_tx_signing_session = Some(signing_session);
29802978
2981- Ok(( commitment_signed, funding_tx_opt) )
2979+ Ok(commitment_signed)
29822980 }
29832981}
29842982
@@ -6628,7 +6626,7 @@ where
66286626 #[rustfmt::skip]
66296627 pub fn commitment_signed_initial_v2<L: Deref>(
66306628 &mut self, msg: &msgs::CommitmentSigned, best_block: BestBlock, signer_provider: &SP, logger: &L
6631- ) -> Result<ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>, ChannelError>
6629+ ) -> Result<( ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>, Option<Transaction>) , ChannelError>
66326630 where L::Target: Logger
66336631 {
66346632 if !self.context.channel_state.is_interactive_signing()
@@ -6657,8 +6655,11 @@ where
66576655 // so they'll be sent as soon as that's done.
66586656 self.context.monitor_pending_tx_signatures = Some(tx_signatures);
66596657 }
6658+ // Only build the unsigned transaction for signing if there are any holder inputs to actually sign
6659+ let funding_tx_opt = self.interactive_tx_signing_session.as_ref().and_then(|session|
6660+ session.local_inputs_count().gt(&0).then_some(session.unsigned_tx().build_unsigned_tx()));
66606661
6661- Ok(channel_monitor)
6662+ Ok(( channel_monitor, funding_tx_opt) )
66626663 }
66636664
66646665 /// Handles an incoming `commitment_signed` message for the first commitment transaction of the
0 commit comments