@@ -3540,38 +3540,38 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3540
3540
log_trace!(logger, "Initial counterparty tx for channel {} is: txid {} tx {}",
3541
3541
&self.channel_id(), counterparty_initial_bitcoin_tx.txid, encode::serialize_hex(&counterparty_initial_bitcoin_tx.transaction));
3542
3542
3543
- match &self.holder_signer {
3543
+ let signature = match &self.holder_signer {
3544
3544
// 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(),
3571
3548
// TODO (taproot|arik)
3572
3549
#[cfg(taproot)]
3573
3550
_ => 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
+ }
3574
3564
}
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)
3575
3575
}
3576
3576
3577
3577
/// 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 {
7681
7681
// TODO (taproot|arik): move match into calling method for Taproot
7682
7682
ChannelSignerType::Ecdsa(ecdsa) => {
7683
7683
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()
7685
7685
},
7686
7686
// TODO (taproot|arik)
7687
7687
#[cfg(taproot)]
7688
7688
_ => todo!()
7689
7689
};
7690
7690
7691
- if self.context.signer_pending_funding {
7691
+ if signature.is_some() && self.context.signer_pending_funding {
7692
7692
log_trace!(logger, "Counterparty commitment signature ready for funding_created message: clearing signer_pending_funding");
7693
7693
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
+ };
7695
7703
7696
- Some( msgs::FundingCreated {
7704
+ signature.map(|signature| msgs::FundingCreated {
7697
7705
temporary_channel_id: self.context.temporary_channel_id.unwrap(),
7698
7706
funding_txid: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
7699
7707
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 {
7749
7757
self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);
7750
7758
7751
7759
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
-
7764
7760
Ok(funding_created)
7765
7761
}
7766
7762
@@ -7988,7 +7984,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
7988
7984
};
7989
7985
let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
7990
7986
log_trace!(logger, "Attempting to generate pending funding created...");
7991
- self.context.signer_pending_funding = false;
7992
7987
self.get_funding_created_msg(logger)
7993
7988
} else { None };
7994
7989
(open_channel, funding_created)
0 commit comments