@@ -1766,7 +1766,7 @@ where
1766
1766
1767
1767
pub fn funding_tx_constructed<L: Deref>(
1768
1768
&mut self, signing_session: InteractiveTxSigningSession, logger: &L,
1769
- ) -> Result<( msgs::CommitmentSigned, Option<Transaction>) , ChannelError>
1769
+ ) -> Result<msgs::CommitmentSigned, ChannelError>
1770
1770
where
1771
1771
L::Target: Logger,
1772
1772
{
@@ -1788,7 +1788,7 @@ where
1788
1788
#[rustfmt::skip]
1789
1789
pub fn commitment_signed<L: Deref>(
1790
1790
&mut self, msg: &msgs::CommitmentSigned, best_block: BestBlock, signer_provider: &SP, logger: &L
1791
- ) -> Result<(Option<ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>>, Option<ChannelMonitorUpdate>), ChannelError>
1791
+ ) -> Result<(Option<ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>>, Option<ChannelMonitorUpdate>, Option<Transaction> ), ChannelError>
1792
1792
where
1793
1793
L::Target: Logger
1794
1794
{
@@ -1815,7 +1815,7 @@ where
1815
1815
pending_splice: None,
1816
1816
};
1817
1817
let res = funded_channel.commitment_signed_initial_v2(msg, best_block, signer_provider, logger)
1818
- .map(|monitor| (Some(monitor), None))
1818
+ .map(|( monitor, funding_tx_opt) | (Some(monitor), None, funding_tx_opt ))
1819
1819
// TODO: Change to `inspect_err` when MSRV is high enough.
1820
1820
.map_err(|err| {
1821
1821
// We always expect a `ChannelError` close.
@@ -1842,15 +1842,15 @@ where
1842
1842
let res = if has_negotiated_pending_splice && !session_received_commitment_signed {
1843
1843
funded_channel
1844
1844
.splice_initial_commitment_signed(msg, logger)
1845
- .map(|monitor_update_opt| (None, monitor_update_opt))
1845
+ .map(|monitor_update_opt| (None, monitor_update_opt, None ))
1846
1846
} else {
1847
1847
funded_channel.commitment_signed(msg, logger)
1848
- .map(|monitor_update_opt| (None, monitor_update_opt))
1848
+ .map(|monitor_update_opt| (None, monitor_update_opt, None ))
1849
1849
};
1850
1850
1851
1851
#[cfg(not(splicing))]
1852
1852
let res = funded_channel.commitment_signed(msg, logger)
1853
- .map(|monitor_update_opt| (None, monitor_update_opt));
1853
+ .map(|monitor_update_opt| (None, monitor_update_opt, None ));
1854
1854
1855
1855
self.phase = ChannelPhase::Funded(funded_channel);
1856
1856
res
@@ -2928,7 +2928,7 @@ where
2928
2928
#[rustfmt::skip]
2929
2929
pub fn funding_tx_constructed<L: Deref>(
2930
2930
&mut self, mut signing_session: InteractiveTxSigningSession, logger: &L
2931
- ) -> Result<( msgs::CommitmentSigned, Option<Transaction>) , ChannelError>
2931
+ ) -> Result<msgs::CommitmentSigned, ChannelError>
2932
2932
where
2933
2933
L::Target: Logger
2934
2934
{
@@ -2970,7 +2970,8 @@ where
2970
2970
},
2971
2971
};
2972
2972
2973
- let funding_tx_opt = if signing_session.local_inputs_count() == 0 {
2973
+ // Check that we have the expected number of local inputs
2974
+ if signing_session.local_inputs_count() == 0 {
2974
2975
debug_assert_eq!(our_funding_satoshis, 0);
2975
2976
if signing_session.provide_holder_witnesses(self.context.channel_id, Vec::new()).is_err() {
2976
2977
debug_assert!(
@@ -2982,10 +2983,7 @@ where
2982
2983
ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }
2983
2984
)));
2984
2985
}
2985
- None
2986
- } else {
2987
- Some(signing_session.unsigned_tx().build_unsigned_tx())
2988
- };
2986
+ }
2989
2987
2990
2988
let mut channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
2991
2989
channel_state.set_interactive_signing();
@@ -2995,7 +2993,7 @@ where
2995
2993
self.interactive_tx_constructor.take();
2996
2994
self.interactive_tx_signing_session = Some(signing_session);
2997
2995
2998
- Ok(( commitment_signed, funding_tx_opt) )
2996
+ Ok(commitment_signed)
2999
2997
}
3000
2998
}
3001
2999
@@ -6632,7 +6630,7 @@ where
6632
6630
#[rustfmt::skip]
6633
6631
pub fn commitment_signed_initial_v2<L: Deref>(
6634
6632
&mut self, msg: &msgs::CommitmentSigned, best_block: BestBlock, signer_provider: &SP, logger: &L
6635
- ) -> Result<ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>, ChannelError>
6633
+ ) -> Result<( ChannelMonitor<<SP::Target as SignerProvider>::EcdsaSigner>, Option<Transaction>) , ChannelError>
6636
6634
where L::Target: Logger
6637
6635
{
6638
6636
if !self.context.channel_state.is_interactive_signing()
@@ -6663,8 +6661,11 @@ where
6663
6661
// so they'll be sent as soon as that's done.
6664
6662
self.context.monitor_pending_tx_signatures = Some(tx_signatures);
6665
6663
}
6664
+ // Only build the unsigned transaction for signing if there are any holder inputs to actually sign
6665
+ let funding_tx_opt = self.interactive_tx_signing_session.as_ref().and_then(|session|
6666
+ session.local_inputs_count().gt(&0).then_some(session.unsigned_tx().build_unsigned_tx()));
6666
6667
6667
- Ok(channel_monitor)
6668
+ Ok(( channel_monitor, funding_tx_opt) )
6668
6669
}
6669
6670
6670
6671
/// Handles an incoming `commitment_signed` message for the first commitment transaction of the
0 commit comments