@@ -1996,6 +1996,31 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
1996
1996
self.update_time_counter += 1;
1997
1997
(monitor_update, dropped_outbound_htlcs)
1998
1998
}
1999
+
2000
+ /// Only allowed after [`Self::channel_transaction_parameters`] is set.
2001
+ fn get_funding_created_msg<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
2002
+ let counterparty_keys = self.build_remote_transaction_keys();
2003
+ let counterparty_initial_commitment_tx = self.build_commitment_transaction(self.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, logger).tx;
2004
+ let signature = match &self.holder_signer {
2005
+ // TODO (taproot|arik): move match into calling method for Taproot
2006
+ ChannelSignerType::Ecdsa(ecdsa) => {
2007
+ ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), &self.secp_ctx)
2008
+ .map(|(sig, _)| sig).ok()?
2009
+ }
2010
+ };
2011
+
2012
+ self.signer_pending_funding = false;
2013
+ Some(msgs::FundingCreated {
2014
+ temporary_channel_id: self.temporary_channel_id.unwrap(),
2015
+ funding_txid: self.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
2016
+ funding_output_index: self.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().index,
2017
+ signature,
2018
+ #[cfg(taproot)]
2019
+ partial_signature_with_nonce: None,
2020
+ #[cfg(taproot)]
2021
+ next_local_nonce: None,
2022
+ })
2023
+ }
1999
2024
}
2000
2025
2001
2026
// Internal utility functions for channels
@@ -3806,7 +3831,9 @@ impl<SP: Deref> Channel<SP> where
3806
3831
None
3807
3832
} else { None };
3808
3833
let funding_signed = None;
3809
- let funding_created = None;
3834
+ let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
3835
+ self.context.get_funding_created_msg(logger)
3836
+ } else { None };
3810
3837
SignerResumeUpdates {
3811
3838
commitment_update,
3812
3839
funding_signed,
@@ -5829,18 +5856,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
5829
5856
})
5830
5857
}
5831
5858
5832
- fn get_funding_created_signature<L: Deref>(&mut self, logger: &L) -> Result<Signature, ()> where L::Target: Logger {
5833
- let counterparty_keys = self.context.build_remote_transaction_keys();
5834
- let counterparty_initial_commitment_tx = self.context.build_commitment_transaction(self.context.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, logger).tx;
5835
- match &self.context.holder_signer {
5836
- // TODO (taproot|arik): move match into calling method for Taproot
5837
- ChannelSignerType::Ecdsa(ecdsa) => {
5838
- ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), &self.context.secp_ctx)
5839
- .map(|(sig, _)| sig)
5840
- }
5841
- }
5842
- }
5843
-
5844
5859
/// Updates channel state with knowledge of the funding transaction's txid/index, and generates
5845
5860
/// a funding_created message for the remote peer.
5846
5861
/// Panics if called at some time other than immediately after initial handshake, if called twice,
@@ -5882,21 +5897,10 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
5882
5897
5883
5898
self.context.funding_transaction = Some(funding_transaction);
5884
5899
5885
- let funding_created = if let Ok(signature) = self.get_funding_created_signature(logger) {
5886
- Some(msgs::FundingCreated {
5887
- temporary_channel_id,
5888
- funding_txid: funding_txo.txid,
5889
- funding_output_index: funding_txo.index,
5890
- signature,
5891
- #[cfg(taproot)]
5892
- partial_signature_with_nonce: None,
5893
- #[cfg(taproot)]
5894
- next_local_nonce: None,
5895
- })
5896
- } else {
5900
+ let funding_created = self.context.get_funding_created_msg(logger);
5901
+ if funding_created.is_none() {
5897
5902
self.context.signer_pending_funding = true;
5898
- None
5899
- };
5903
+ }
5900
5904
5901
5905
let channel = Channel {
5902
5906
context: self.context,
0 commit comments