@@ -3514,38 +3514,38 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3514
3514
log_trace!(logger, "Initial counterparty tx for channel {} is: txid {} tx {}",
3515
3515
&self.channel_id(), counterparty_initial_bitcoin_tx.txid, encode::serialize_hex(&counterparty_initial_bitcoin_tx.transaction));
3516
3516
3517
- match &self.holder_signer {
3517
+ let signature = match &self.holder_signer {
3518
3518
// TODO (arik): move match into calling method for Taproot
3519
- ChannelSignerType::Ecdsa(ecdsa) => {
3520
- let funding_signed = ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx)
3521
- .map(|(signature, _)| msgs::FundingSigned {
3522
- channel_id: self.channel_id(),
3523
- signature,
3524
- #[cfg(taproot)]
3525
- partial_signature_with_nonce: None,
3526
- })
3527
- .ok();
3528
-
3529
- if funding_signed.is_none() {
3530
- #[cfg(not(async_signing))] {
3531
- panic!("Failed to get signature for funding_signed");
3532
- }
3533
- #[cfg(async_signing)] {
3534
- log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
3535
- self.signer_pending_funding = true;
3536
- }
3537
- } else if self.signer_pending_funding {
3538
- log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
3539
- self.signer_pending_funding = false;
3540
- }
3541
-
3542
- // We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
3543
- (counterparty_initial_commitment_tx, funding_signed)
3544
- },
3519
+ ChannelSignerType::Ecdsa(ecdsa) => ecdsa.sign_counterparty_commitment(
3520
+ &counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx
3521
+ ).ok(),
3545
3522
// TODO (taproot|arik)
3546
3523
#[cfg(taproot)]
3547
3524
_ => todo!()
3525
+ };
3526
+
3527
+ if signature.is_some() && self.signer_pending_funding {
3528
+ log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
3529
+ self.signer_pending_funding = false;
3530
+ } else if signature.is_none() {
3531
+ #[cfg(not(async_signing))] {
3532
+ panic!("Failed to get signature for funding_signed");
3533
+ }
3534
+ #[cfg(async_signing)] {
3535
+ log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
3536
+ self.signer_pending_funding = true;
3537
+ }
3548
3538
}
3539
+
3540
+ let funding_signed = signature.map(|(signature, _)| msgs::FundingSigned {
3541
+ channel_id: self.channel_id(),
3542
+ signature,
3543
+ #[cfg(taproot)]
3544
+ partial_signature_with_nonce: None,
3545
+ });
3546
+
3547
+ // We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
3548
+ (counterparty_initial_commitment_tx, funding_signed)
3549
3549
}
3550
3550
3551
3551
/// If we receive an error message when attempting to open a channel, it may only be a rejection
@@ -5543,8 +5543,6 @@ impl<SP: Deref> Channel<SP> where
5543
5543
// CS before we have any commitment point available. Blocking our
5544
5544
// RAA here is a convenient way to make sure that post-funding
5545
5545
// we're only ever waiting on one commitment point at a time.
5546
- log_trace!(logger, "Last revoke-and-ack pending in channel {} for sequence {} because the next per-commitment point is not available",
5547
- &self.context.channel_id(), self.context.holder_commitment_point.transaction_number());
5548
5546
self.context.signer_pending_revoke_and_ack = true;
5549
5547
None
5550
5548
}
@@ -7651,19 +7649,27 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
7651
7649
// TODO (taproot|arik): move match into calling method for Taproot
7652
7650
ChannelSignerType::Ecdsa(ecdsa) => {
7653
7651
ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.context.secp_ctx)
7654
- .map(|(sig, _)| sig).ok()?
7652
+ .map(|(sig, _)| sig).ok()
7655
7653
},
7656
7654
// TODO (taproot|arik)
7657
7655
#[cfg(taproot)]
7658
7656
_ => todo!()
7659
7657
};
7660
7658
7661
- if self.context.signer_pending_funding {
7659
+ if signature.is_some() && self.context.signer_pending_funding {
7662
7660
log_trace!(logger, "Counterparty commitment signature ready for funding_created message: clearing signer_pending_funding");
7663
7661
self.context.signer_pending_funding = false;
7664
- }
7662
+ } else if signature.is_none() {
7663
+ #[cfg(not(async_signing))] {
7664
+ panic!("Failed to get signature for new funding creation");
7665
+ }
7666
+ #[cfg(async_signing)] {
7667
+ log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
7668
+ self.context.signer_pending_funding = true;
7669
+ }
7670
+ };
7665
7671
7666
- Some( msgs::FundingCreated {
7672
+ signature.map(|signature| msgs::FundingCreated {
7667
7673
temporary_channel_id: self.context.temporary_channel_id.unwrap(),
7668
7674
funding_txid: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
7669
7675
funding_output_index: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().index,
@@ -7719,18 +7725,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
7719
7725
self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);
7720
7726
7721
7727
let funding_created = self.get_funding_created_msg(logger);
7722
- if funding_created.is_none() {
7723
- #[cfg(not(async_signing))] {
7724
- panic!("Failed to get signature for new funding creation");
7725
- }
7726
- #[cfg(async_signing)] {
7727
- if !self.context.signer_pending_funding {
7728
- log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
7729
- self.context.signer_pending_funding = true;
7730
- }
7731
- }
7732
- }
7733
-
7734
7728
Ok(funding_created)
7735
7729
}
7736
7730
@@ -7948,7 +7942,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
7948
7942
} else { None };
7949
7943
let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
7950
7944
log_trace!(logger, "Attempting to generate pending funding created...");
7951
- self.context.signer_pending_funding = false;
7952
7945
self.get_funding_created_msg(logger)
7953
7946
} else { None };
7954
7947
(open_channel, funding_created)
0 commit comments