@@ -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
{
@@ -1786,7 +1786,7 @@ where
1786
1786
#[rustfmt::skip]
1787
1787
pub fn commitment_signed<L: Deref>(
1788
1788
&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>
1790
1790
where
1791
1791
L::Target: Logger
1792
1792
{
@@ -1813,7 +1813,7 @@ where
1813
1813
pending_splice: None,
1814
1814
};
1815
1815
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 ))
1817
1817
// TODO: Change to `inspect_err` when MSRV is high enough.
1818
1818
.map_err(|err| {
1819
1819
// We always expect a `ChannelError` close.
@@ -1840,15 +1840,15 @@ where
1840
1840
let res = if has_negotiated_pending_splice && !session_received_commitment_signed {
1841
1841
funded_channel
1842
1842
.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 ))
1844
1844
} else {
1845
1845
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 ))
1847
1847
};
1848
1848
1849
1849
#[cfg(not(splicing))]
1850
1850
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 ));
1852
1852
1853
1853
self.phase = ChannelPhase::Funded(funded_channel);
1854
1854
res
@@ -2916,7 +2916,7 @@ where
2916
2916
#[rustfmt::skip]
2917
2917
pub fn funding_tx_constructed<L: Deref>(
2918
2918
&mut self, mut signing_session: InteractiveTxSigningSession, logger: &L
2919
- ) -> Result<( msgs::CommitmentSigned, Option<Transaction>) , ChannelError>
2919
+ ) -> Result<msgs::CommitmentSigned, ChannelError>
2920
2920
where
2921
2921
L::Target: Logger
2922
2922
{
@@ -2954,7 +2954,8 @@ where
2954
2954
},
2955
2955
};
2956
2956
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 {
2958
2959
debug_assert_eq!(our_funding_satoshis, 0);
2959
2960
if signing_session.provide_holder_witnesses(self.context.channel_id, Vec::new()).is_err() {
2960
2961
debug_assert!(
@@ -2965,10 +2966,7 @@ where
2965
2966
let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
2966
2967
return Err(ChannelError::Close((msg.to_owned(), reason)));
2967
2968
}
2968
- None
2969
- } else {
2970
- Some(signing_session.unsigned_tx().build_unsigned_tx())
2971
- };
2969
+ }
2972
2970
2973
2971
let mut channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
2974
2972
channel_state.set_interactive_signing();
@@ -2978,7 +2976,7 @@ where
2978
2976
self.interactive_tx_constructor.take();
2979
2977
self.interactive_tx_signing_session = Some(signing_session);
2980
2978
2981
- Ok(( commitment_signed, funding_tx_opt) )
2979
+ Ok(commitment_signed)
2982
2980
}
2983
2981
}
2984
2982
@@ -6628,7 +6626,7 @@ where
6628
6626
#[rustfmt::skip]
6629
6627
pub fn commitment_signed_initial_v2<L: Deref>(
6630
6628
&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>
6632
6630
where L::Target: Logger
6633
6631
{
6634
6632
if !self.context.channel_state.is_interactive_signing()
@@ -6657,8 +6655,11 @@ where
6657
6655
// so they'll be sent as soon as that's done.
6658
6656
self.context.monitor_pending_tx_signatures = Some(tx_signatures);
6659
6657
}
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()));
6660
6661
6661
- Ok(channel_monitor)
6662
+ Ok(( channel_monitor, funding_tx_opt) )
6662
6663
}
6663
6664
6664
6665
/// Handles an incoming `commitment_signed` message for the first commitment transaction of the
0 commit comments