@@ -3556,38 +3556,38 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3556
3556
log_trace!(logger, "Initial counterparty tx for channel {} is: txid {} tx {}",
3557
3557
&self.channel_id(), counterparty_initial_bitcoin_tx.txid, encode::serialize_hex(&counterparty_initial_bitcoin_tx.transaction));
3558
3558
3559
- match &self.holder_signer {
3559
+ let signature = match &self.holder_signer {
3560
3560
// 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(),
3587
3564
// TODO (taproot|arik)
3588
3565
#[cfg(taproot)]
3589
3566
_ => 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
+ }
3590
3580
}
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)
3591
3591
}
3592
3592
3593
3593
/// 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
5587
5587
// CS before we have any commitment point available. Blocking our
5588
5588
// RAA here is a convenient way to make sure that post-funding
5589
5589
// 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());
5592
5590
self.context.signer_pending_revoke_and_ack = true;
5593
5591
None
5594
5592
}
@@ -7695,19 +7693,27 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
7695
7693
// TODO (taproot|arik): move match into calling method for Taproot
7696
7694
ChannelSignerType::Ecdsa(ecdsa) => {
7697
7695
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()
7699
7697
},
7700
7698
// TODO (taproot|arik)
7701
7699
#[cfg(taproot)]
7702
7700
_ => todo!()
7703
7701
};
7704
7702
7705
- if self.context.signer_pending_funding {
7703
+ if signature.is_some() && self.context.signer_pending_funding {
7706
7704
log_trace!(logger, "Counterparty commitment signature ready for funding_created message: clearing signer_pending_funding");
7707
7705
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
+ };
7709
7715
7710
- Some( msgs::FundingCreated {
7716
+ signature.map(|signature| msgs::FundingCreated {
7711
7717
temporary_channel_id: self.context.temporary_channel_id.unwrap(),
7712
7718
funding_txid: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
7713
7719
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 {
7763
7769
self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);
7764
7770
7765
7771
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
-
7778
7772
Ok(funding_created)
7779
7773
}
7780
7774
@@ -7992,7 +7986,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
7992
7986
} else { None };
7993
7987
let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
7994
7988
log_trace!(logger, "Attempting to generate pending funding created...");
7995
- self.context.signer_pending_funding = false;
7996
7989
self.get_funding_created_msg(logger)
7997
7990
} else { None };
7998
7991
(open_channel, funding_created)
0 commit comments