@@ -2084,6 +2084,31 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2084
2084
self.update_time_counter += 1;
2085
2085
(monitor_update, dropped_outbound_htlcs, unbroadcasted_batch_funding_txid)
2086
2086
}
2087
+
2088
+ /// Only allowed after [`Self::channel_transaction_parameters`] is set.
2089
+ fn get_funding_created_msg<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
2090
+ let counterparty_keys = self.build_remote_transaction_keys();
2091
+ let counterparty_initial_commitment_tx = self.build_commitment_transaction(self.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, logger).tx;
2092
+ let signature = match &self.holder_signer {
2093
+ // TODO (taproot|arik): move match into calling method for Taproot
2094
+ ChannelSignerType::Ecdsa(ecdsa) => {
2095
+ ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), &self.secp_ctx)
2096
+ .map(|(sig, _)| sig).ok()?
2097
+ }
2098
+ };
2099
+
2100
+ self.signer_pending_funding = false;
2101
+ Some(msgs::FundingCreated {
2102
+ temporary_channel_id: self.temporary_channel_id.unwrap(),
2103
+ funding_txid: self.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
2104
+ funding_output_index: self.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().index,
2105
+ signature,
2106
+ #[cfg(taproot)]
2107
+ partial_signature_with_nonce: None,
2108
+ #[cfg(taproot)]
2109
+ next_local_nonce: None,
2110
+ })
2111
+ }
2087
2112
}
2088
2113
2089
2114
// Internal utility functions for channels
@@ -3909,7 +3934,9 @@ impl<SP: Deref> Channel<SP> where
3909
3934
None
3910
3935
} else { None };
3911
3936
let funding_signed = None;
3912
- let funding_created = None;
3937
+ let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
3938
+ self.context.get_funding_created_msg(logger)
3939
+ } else { None };
3913
3940
SignerResumeUpdates {
3914
3941
commitment_update,
3915
3942
funding_signed,
@@ -5939,18 +5966,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
5939
5966
})
5940
5967
}
5941
5968
5942
- fn get_funding_created_signature<L: Deref>(&mut self, logger: &L) -> Result<Signature, ()> where L::Target: Logger {
5943
- let counterparty_keys = self.context.build_remote_transaction_keys();
5944
- let counterparty_initial_commitment_tx = self.context.build_commitment_transaction(self.context.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, logger).tx;
5945
- match &self.context.holder_signer {
5946
- // TODO (taproot|arik): move match into calling method for Taproot
5947
- ChannelSignerType::Ecdsa(ecdsa) => {
5948
- ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), &self.context.secp_ctx)
5949
- .map(|(sig, _)| sig)
5950
- }
5951
- }
5952
- }
5953
-
5954
5969
/// Updates channel state with knowledge of the funding transaction's txid/index, and generates
5955
5970
/// a funding_created message for the remote peer.
5956
5971
/// Panics if called at some time other than immediately after initial handshake, if called twice,
@@ -5993,21 +6008,10 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
5993
6008
self.context.funding_transaction = Some(funding_transaction);
5994
6009
self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);
5995
6010
5996
- let funding_created = if let Ok(signature) = self.get_funding_created_signature(logger) {
5997
- Some(msgs::FundingCreated {
5998
- temporary_channel_id,
5999
- funding_txid: funding_txo.txid,
6000
- funding_output_index: funding_txo.index,
6001
- signature,
6002
- #[cfg(taproot)]
6003
- partial_signature_with_nonce: None,
6004
- #[cfg(taproot)]
6005
- next_local_nonce: None,
6006
- })
6007
- } else {
6011
+ let funding_created = self.context.get_funding_created_msg(logger);
6012
+ if funding_created.is_none() {
6008
6013
self.context.signer_pending_funding = true;
6009
- None
6010
- };
6014
+ }
6011
6015
6012
6016
let channel = Channel {
6013
6017
context: self.context,
0 commit comments