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