@@ -2025,6 +2025,31 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
2025
2025
self.update_time_counter += 1;
2026
2026
(monitor_update, dropped_outbound_htlcs)
2027
2027
}
2028
+
2029
+ /// Only allowed after [`Self::channel_transaction_parameters`] is set.
2030
+ fn get_funding_created_msg<L: Deref>(&mut self, logger: &L) -> Option<msgs::FundingCreated> where L::Target: Logger {
2031
+ let counterparty_keys = self.build_remote_transaction_keys();
2032
+ let counterparty_initial_commitment_tx = self.build_commitment_transaction(self.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, logger).tx;
2033
+ let signature = match &self.holder_signer {
2034
+ // TODO (taproot|arik): move match into calling method for Taproot
2035
+ ChannelSignerType::Ecdsa(ecdsa) => {
2036
+ ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), &self.secp_ctx)
2037
+ .map(|(sig, _)| sig).ok()?
2038
+ }
2039
+ };
2040
+
2041
+ self.signer_pending_funding = false;
2042
+ Some(msgs::FundingCreated {
2043
+ temporary_channel_id: self.temporary_channel_id.unwrap(),
2044
+ funding_txid: self.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
2045
+ funding_output_index: self.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().index,
2046
+ signature,
2047
+ #[cfg(taproot)]
2048
+ partial_signature_with_nonce: None,
2049
+ #[cfg(taproot)]
2050
+ next_local_nonce: None,
2051
+ })
2052
+ }
2028
2053
}
2029
2054
2030
2055
// Internal utility functions for channels
@@ -3830,7 +3855,9 @@ impl<SP: Deref> Channel<SP> where
3830
3855
None
3831
3856
} else { None };
3832
3857
let funding_signed = None;
3833
- let funding_created = None;
3858
+ let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
3859
+ self.context.get_funding_created_msg(logger)
3860
+ } else { None };
3834
3861
SignerResumeUpdates {
3835
3862
commitment_update,
3836
3863
funding_signed,
@@ -5853,18 +5880,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
5853
5880
})
5854
5881
}
5855
5882
5856
- fn get_funding_created_signature<L: Deref>(&mut self, logger: &L) -> Result<Signature, ()> where L::Target: Logger {
5857
- let counterparty_keys = self.context.build_remote_transaction_keys();
5858
- let counterparty_initial_commitment_tx = self.context.build_commitment_transaction(self.context.cur_counterparty_commitment_transaction_number, &counterparty_keys, false, false, logger).tx;
5859
- match &self.context.holder_signer {
5860
- // TODO (taproot|arik): move match into calling method for Taproot
5861
- ChannelSignerType::Ecdsa(ecdsa) => {
5862
- ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), &self.context.secp_ctx)
5863
- .map(|(sig, _)| sig)
5864
- }
5865
- }
5866
- }
5867
-
5868
5883
/// Updates channel state with knowledge of the funding transaction's txid/index, and generates
5869
5884
/// a funding_created message for the remote peer.
5870
5885
/// Panics if called at some time other than immediately after initial handshake, if called twice,
@@ -5906,21 +5921,10 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
5906
5921
5907
5922
self.context.funding_transaction = Some(funding_transaction);
5908
5923
5909
- let funding_created = if let Ok(signature) = self.get_funding_created_signature(logger) {
5910
- Some(msgs::FundingCreated {
5911
- temporary_channel_id,
5912
- funding_txid: funding_txo.txid,
5913
- funding_output_index: funding_txo.index,
5914
- signature,
5915
- #[cfg(taproot)]
5916
- partial_signature_with_nonce: None,
5917
- #[cfg(taproot)]
5918
- next_local_nonce: None,
5919
- })
5920
- } else {
5924
+ let funding_created = self.context.get_funding_created_msg(logger);
5925
+ if funding_created.is_none() {
5921
5926
self.context.signer_pending_funding = true;
5922
- None
5923
- };
5927
+ }
5924
5928
5925
5929
let channel = Channel {
5926
5930
context: self.context,
0 commit comments