@@ -2096,6 +2096,31 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2096
2096
self.update_time_counter += 1;
2097
2097
(monitor_update, dropped_outbound_htlcs, unbroadcasted_batch_funding_txid)
2098
2098
}
2099
+
2100
+ /// Only allowed after [`Self::channel_transaction_parameters`] is set.
2101
+ fn get_funding_created_msg<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
2102
+ let counterparty_keys = self.build_remote_transaction_keys();
2103
+ let counterparty_initial_commitment_tx = self.build_commitment_transaction(self.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, logger).tx;
2104
+ let signature = match &self.holder_signer {
2105
+ // TODO (taproot|arik): move match into calling method for Taproot
2106
+ ChannelSignerType::Ecdsa(ecdsa) => {
2107
+ ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), &self.secp_ctx)
2108
+ .map(|(sig, _)| sig).ok()?
2109
+ }
2110
+ };
2111
+
2112
+ self.signer_pending_funding = false;
2113
+ Some(msgs::FundingCreated {
2114
+ temporary_channel_id: self.temporary_channel_id.unwrap(),
2115
+ funding_txid: self.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
2116
+ funding_output_index: self.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().index,
2117
+ signature,
2118
+ #[cfg(taproot)]
2119
+ partial_signature_with_nonce: None,
2120
+ #[cfg(taproot)]
2121
+ next_local_nonce: None,
2122
+ })
2123
+ }
2099
2124
}
2100
2125
2101
2126
// Internal utility functions for channels
@@ -3925,7 +3950,9 @@ impl<SP: Deref> Channel<SP> where
3925
3950
self.get_last_commitment_update_for_send(logger).ok()
3926
3951
} else { None };
3927
3952
let funding_signed = None;
3928
- let funding_created = None;
3953
+ let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
3954
+ self.context.get_funding_created_msg(logger)
3955
+ } else { None };
3929
3956
SignerResumeUpdates {
3930
3957
commitment_update,
3931
3958
funding_signed,
@@ -5957,18 +5984,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
5957
5984
})
5958
5985
}
5959
5986
5960
- fn get_funding_created_signature<L: Deref>(&mut self, logger: &L) -> Result<Signature, ()> where L::Target: Logger {
5961
- let counterparty_keys = self.context.build_remote_transaction_keys();
5962
- let counterparty_initial_commitment_tx = self.context.build_commitment_transaction(self.context.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, logger).tx;
5963
- match &self.context.holder_signer {
5964
- // TODO (taproot|arik): move match into calling method for Taproot
5965
- ChannelSignerType::Ecdsa(ecdsa) => {
5966
- ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), &self.context.secp_ctx)
5967
- .map(|(sig, _)| sig)
5968
- }
5969
- }
5970
- }
5971
-
5972
5987
/// Updates channel state with knowledge of the funding transaction's txid/index, and generates
5973
5988
/// a funding_created message for the remote peer.
5974
5989
/// Panics if called at some time other than immediately after initial handshake, if called twice,
@@ -6011,21 +6026,10 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
6011
6026
self.context.funding_transaction = Some(funding_transaction);
6012
6027
self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);
6013
6028
6014
- let funding_created = if let Ok(signature) = self.get_funding_created_signature(logger) {
6015
- Some(msgs::FundingCreated {
6016
- temporary_channel_id,
6017
- funding_txid: funding_txo.txid,
6018
- funding_output_index: funding_txo.index,
6019
- signature,
6020
- #[cfg(taproot)]
6021
- partial_signature_with_nonce: None,
6022
- #[cfg(taproot)]
6023
- next_local_nonce: None,
6024
- })
6025
- } else {
6029
+ let funding_created = self.context.get_funding_created_msg(logger);
6030
+ if funding_created.is_none() {
6026
6031
self.context.signer_pending_funding = true;
6027
- None
6028
- };
6032
+ }
6029
6033
6030
6034
let channel = Channel {
6031
6035
context: self.context,
0 commit comments