@@ -3540,38 +3540,38 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
35403540 log_trace!(logger, "Initial counterparty tx for channel {} is: txid {} tx {}",
35413541 &self.channel_id(), counterparty_initial_bitcoin_tx.txid, encode::serialize_hex(&counterparty_initial_bitcoin_tx.transaction));
35423542
3543- match &self.holder_signer {
3543+ let signature = match &self.holder_signer {
35443544 // TODO (arik): move match into calling method for Taproot
3545- ChannelSignerType::Ecdsa(ecdsa) => {
3546- let funding_signed = ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx)
3547- .map(|(signature, _)| msgs::FundingSigned {
3548- channel_id: self.channel_id(),
3549- signature,
3550- #[cfg(taproot)]
3551- partial_signature_with_nonce: None,
3552- })
3553- .ok();
3554-
3555- if funding_signed.is_none() {
3556- #[cfg(not(async_signing))] {
3557- panic!("Failed to get signature for funding_signed");
3558- }
3559- #[cfg(async_signing)] {
3560- log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
3561- self.signer_pending_funding = true;
3562- }
3563- } else if self.signer_pending_funding {
3564- log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
3565- self.signer_pending_funding = false;
3566- }
3567-
3568- // We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
3569- (counterparty_initial_commitment_tx, funding_signed)
3570- },
3545+ ChannelSignerType::Ecdsa(ecdsa) => ecdsa.sign_counterparty_commitment(
3546+ &counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx
3547+ ).ok(),
35713548 // TODO (taproot|arik)
35723549 #[cfg(taproot)]
35733550 _ => todo!()
3551+ };
3552+
3553+ if signature.is_some() && self.signer_pending_funding {
3554+ log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
3555+ self.signer_pending_funding = false;
3556+ } else if signature.is_none() {
3557+ #[cfg(not(async_signing))] {
3558+ panic!("Failed to get signature for funding_signed");
3559+ }
3560+ #[cfg(async_signing)] {
3561+ log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
3562+ self.signer_pending_funding = true;
3563+ }
35743564 }
3565+
3566+ let funding_signed = signature.map(|(signature, _)| msgs::FundingSigned {
3567+ channel_id: self.channel_id(),
3568+ signature,
3569+ #[cfg(taproot)]
3570+ partial_signature_with_nonce: None,
3571+ });
3572+
3573+ // We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
3574+ (counterparty_initial_commitment_tx, funding_signed)
35753575 }
35763576
35773577 /// If we receive an error message when attempting to open a channel, it may only be a rejection
@@ -7681,19 +7681,27 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
76817681 // TODO (taproot|arik): move match into calling method for Taproot
76827682 ChannelSignerType::Ecdsa(ecdsa) => {
76837683 ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.context.secp_ctx)
7684- .map(|(sig, _)| sig).ok()?
7684+ .map(|(sig, _)| sig).ok()
76857685 },
76867686 // TODO (taproot|arik)
76877687 #[cfg(taproot)]
76887688 _ => todo!()
76897689 };
76907690
7691- if self.context.signer_pending_funding {
7691+ if signature.is_some() && self.context.signer_pending_funding {
76927692 log_trace!(logger, "Counterparty commitment signature ready for funding_created message: clearing signer_pending_funding");
76937693 self.context.signer_pending_funding = false;
7694- }
7694+ } else if signature.is_none() {
7695+ #[cfg(not(async_signing))] {
7696+ panic!("Failed to get signature for new funding creation");
7697+ }
7698+ #[cfg(async_signing)] {
7699+ log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
7700+ self.context.signer_pending_funding = true;
7701+ }
7702+ };
76957703
7696- Some( msgs::FundingCreated {
7704+ signature.map(|signature| msgs::FundingCreated {
76977705 temporary_channel_id: self.context.temporary_channel_id.unwrap(),
76987706 funding_txid: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
76997707 funding_output_index: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().index,
@@ -7749,18 +7757,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
77497757 self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);
77507758
77517759 let funding_created = self.get_funding_created_msg(logger);
7752- if funding_created.is_none() {
7753- #[cfg(not(async_signing))] {
7754- panic!("Failed to get signature for new funding creation");
7755- }
7756- #[cfg(async_signing)] {
7757- if !self.context.signer_pending_funding {
7758- log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
7759- self.context.signer_pending_funding = true;
7760- }
7761- }
7762- }
7763-
77647760 Ok(funding_created)
77657761 }
77667762
@@ -7989,7 +7985,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
79897985 };
79907986 let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
79917987 log_trace!(logger, "Attempting to generate pending funding created...");
7992- self.context.signer_pending_funding = false;
79937988 self.get_funding_created_msg(logger)
79947989 } else { None };
79957990 (open_channel, funding_created)
0 commit comments