@@ -3939,38 +3939,36 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3939
3939
log_trace!(logger, "Initial counterparty tx for channel {} is: txid {} tx {}",
3940
3940
&self.channel_id(), counterparty_initial_bitcoin_tx.txid, encode::serialize_hex(&counterparty_initial_bitcoin_tx.transaction));
3941
3941
3942
- match &self.holder_signer {
3942
+ // We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
3943
+ let signature = match &self.holder_signer {
3943
3944
// TODO (arik): move match into calling method for Taproot
3944
- ChannelSignerType::Ecdsa(ecdsa) => {
3945
- let funding_signed = ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx)
3946
- .map(|(signature, _)| msgs::FundingSigned {
3947
- channel_id: self.channel_id(),
3948
- signature,
3949
- #[cfg(taproot)]
3950
- partial_signature_with_nonce: None,
3951
- })
3952
- .ok();
3953
-
3954
- if funding_signed.is_none() {
3955
- #[cfg(not(async_signing))] {
3956
- panic!("Failed to get signature for funding_signed");
3957
- }
3958
- #[cfg(async_signing)] {
3959
- log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
3960
- self.signer_pending_funding = true;
3961
- }
3962
- } else if self.signer_pending_funding {
3963
- log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
3964
- self.signer_pending_funding = false;
3965
- }
3966
-
3967
- // We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
3968
- funding_signed
3969
- },
3945
+ ChannelSignerType::Ecdsa(ecdsa) => ecdsa.sign_counterparty_commitment(
3946
+ &counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx
3947
+ ).ok(),
3970
3948
// TODO (taproot|arik)
3971
3949
#[cfg(taproot)]
3972
3950
_ => todo!()
3951
+ };
3952
+
3953
+ if signature.is_some() && self.signer_pending_funding {
3954
+ log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
3955
+ self.signer_pending_funding = false;
3956
+ } else if signature.is_none() {
3957
+ #[cfg(not(async_signing))] {
3958
+ panic!("Failed to get signature for funding_signed");
3959
+ }
3960
+ #[cfg(async_signing)] {
3961
+ log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
3962
+ self.signer_pending_funding = true;
3963
+ }
3973
3964
}
3965
+
3966
+ signature.map(|(signature, _)| msgs::FundingSigned {
3967
+ channel_id: self.channel_id(),
3968
+ signature,
3969
+ #[cfg(taproot)]
3970
+ partial_signature_with_nonce: None,
3971
+ })
3974
3972
}
3975
3973
3976
3974
/// If we receive an error message when attempting to open a channel, it may only be a rejection
@@ -8348,19 +8346,27 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
8348
8346
// TODO (taproot|arik): move match into calling method for Taproot
8349
8347
ChannelSignerType::Ecdsa(ecdsa) => {
8350
8348
ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.context.secp_ctx)
8351
- .map(|(sig, _)| sig).ok()?
8349
+ .map(|(sig, _)| sig).ok()
8352
8350
},
8353
8351
// TODO (taproot|arik)
8354
8352
#[cfg(taproot)]
8355
8353
_ => todo!()
8356
8354
};
8357
8355
8358
- if self.context.signer_pending_funding {
8356
+ if signature.is_some() && self.context.signer_pending_funding {
8359
8357
log_trace!(logger, "Counterparty commitment signature ready for funding_created message: clearing signer_pending_funding");
8360
8358
self.context.signer_pending_funding = false;
8361
- }
8359
+ } else if signature.is_none() {
8360
+ #[cfg(not(async_signing))] {
8361
+ panic!("Failed to get signature for new funding creation");
8362
+ }
8363
+ #[cfg(async_signing)] {
8364
+ log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
8365
+ self.context.signer_pending_funding = true;
8366
+ }
8367
+ };
8362
8368
8363
- Some( msgs::FundingCreated {
8369
+ signature.map(|signature| msgs::FundingCreated {
8364
8370
temporary_channel_id: self.context.temporary_channel_id.unwrap(),
8365
8371
funding_txid: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
8366
8372
funding_output_index: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().index,
@@ -8413,18 +8419,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
8413
8419
self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);
8414
8420
8415
8421
let funding_created = self.get_funding_created_msg(logger);
8416
- if funding_created.is_none() {
8417
- #[cfg(not(async_signing))] {
8418
- panic!("Failed to get signature for new funding creation");
8419
- }
8420
- #[cfg(async_signing)] {
8421
- if !self.context.signer_pending_funding {
8422
- log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
8423
- self.context.signer_pending_funding = true;
8424
- }
8425
- }
8426
- }
8427
-
8428
8422
Ok(funding_created)
8429
8423
}
8430
8424
@@ -8582,7 +8576,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
8582
8576
} else { None };
8583
8577
let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
8584
8578
log_trace!(logger, "Attempting to generate pending funding created...");
8585
- self.context.signer_pending_funding = false;
8586
8579
self.get_funding_created_msg(logger)
8587
8580
} else { None };
8588
8581
(open_channel, funding_created)
0 commit comments