@@ -3556,38 +3556,38 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
35563556 log_trace!(logger, "Initial counterparty tx for channel {} is: txid {} tx {}",
35573557 &self.channel_id(), counterparty_initial_bitcoin_tx.txid, encode::serialize_hex(&counterparty_initial_bitcoin_tx.transaction));
35583558
3559- match &self.holder_signer {
3559+ let signature = match &self.holder_signer {
35603560 // TODO (arik): move match into calling method for Taproot
3561- ChannelSignerType::Ecdsa(ecdsa) => {
3562- let funding_signed = ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx)
3563- .map(|(signature, _)| msgs::FundingSigned {
3564- channel_id: self.channel_id(),
3565- signature,
3566- #[cfg(taproot)]
3567- partial_signature_with_nonce: None,
3568- })
3569- .ok();
3570-
3571- if funding_signed.is_none() {
3572- #[cfg(not(async_signing))] {
3573- panic!("Failed to get signature for funding_signed");
3574- }
3575- #[cfg(async_signing)] {
3576- log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
3577- self.signer_pending_funding = true;
3578- }
3579- } else if self.signer_pending_funding {
3580- log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
3581- self.signer_pending_funding = false;
3582- }
3583-
3584- // We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
3585- (counterparty_initial_commitment_tx, funding_signed)
3586- },
3561+ ChannelSignerType::Ecdsa(ecdsa) => ecdsa.sign_counterparty_commitment(
3562+ &counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx
3563+ ).ok(),
35873564 // TODO (taproot|arik)
35883565 #[cfg(taproot)]
35893566 _ => todo!()
3567+ };
3568+
3569+ if signature.is_some() && self.signer_pending_funding {
3570+ log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
3571+ self.signer_pending_funding = false;
3572+ } else if signature.is_none() {
3573+ #[cfg(not(async_signing))] {
3574+ panic!("Failed to get signature for funding_signed");
3575+ }
3576+ #[cfg(async_signing)] {
3577+ log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
3578+ self.signer_pending_funding = true;
3579+ }
35903580 }
3581+
3582+ let funding_signed = signature.map(|(signature, _)| msgs::FundingSigned {
3583+ channel_id: self.channel_id(),
3584+ signature,
3585+ #[cfg(taproot)]
3586+ partial_signature_with_nonce: None,
3587+ });
3588+
3589+ // We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
3590+ (counterparty_initial_commitment_tx, funding_signed)
35913591 }
35923592
35933593 /// If we receive an error message when attempting to open a channel, it may only be a rejection
@@ -5587,8 +5587,6 @@ impl<SP: Deref> Channel<SP> where
55875587 // CS before we have any commitment point available. Blocking our
55885588 // RAA here is a convenient way to make sure that post-funding
55895589 // we're only ever waiting on one commitment point at a time.
5590- log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment point is not available",
5591- &self.context.channel_id(), self.context.holder_commitment_point.transaction_number());
55925590 self.context.signer_pending_revoke_and_ack = true;
55935591 None
55945592 }
@@ -7695,19 +7693,27 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
76957693 // TODO (taproot|arik): move match into calling method for Taproot
76967694 ChannelSignerType::Ecdsa(ecdsa) => {
76977695 ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.context.secp_ctx)
7698- .map(|(sig, _)| sig).ok()?
7696+ .map(|(sig, _)| sig).ok()
76997697 },
77007698 // TODO (taproot|arik)
77017699 #[cfg(taproot)]
77027700 _ => todo!()
77037701 };
77047702
7705- if self.context.signer_pending_funding {
7703+ if signature.is_some() && self.context.signer_pending_funding {
77067704 log_trace!(logger, "Counterparty commitment signature ready for funding_created message: clearing signer_pending_funding");
77077705 self.context.signer_pending_funding = false;
7708- }
7706+ } else if signature.is_none() {
7707+ #[cfg(not(async_signing))] {
7708+ panic!("Failed to get signature for new funding creation");
7709+ }
7710+ #[cfg(async_signing)] {
7711+ log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
7712+ self.context.signer_pending_funding = true;
7713+ }
7714+ };
77097715
7710- Some( msgs::FundingCreated {
7716+ signature.map(|signature| msgs::FundingCreated {
77117717 temporary_channel_id: self.context.temporary_channel_id.unwrap(),
77127718 funding_txid: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
77137719 funding_output_index: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().index,
@@ -7763,18 +7769,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
77637769 self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);
77647770
77657771 let funding_created = self.get_funding_created_msg(logger);
7766- if funding_created.is_none() {
7767- #[cfg(not(async_signing))] {
7768- panic!("Failed to get signature for new funding creation");
7769- }
7770- #[cfg(async_signing)] {
7771- if !self.context.signer_pending_funding {
7772- log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
7773- self.context.signer_pending_funding = true;
7774- }
7775- }
7776- }
7777-
77787772 Ok(funding_created)
77797773 }
77807774
@@ -7992,7 +7986,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
79927986 } else { None };
79937987 let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
79947988 log_trace!(logger, "Attempting to generate pending funding created...");
7995- self.context.signer_pending_funding = false;
79967989 self.get_funding_created_msg(logger)
79977990 } else { None };
79987991 (open_channel, funding_created)
0 commit comments