@@ -3931,38 +3931,36 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
3931
3931
log_trace!(logger, "Initial counterparty tx for channel {} is: txid {} tx {}",
3932
3932
&self.channel_id(), counterparty_initial_bitcoin_tx.txid, encode::serialize_hex(&counterparty_initial_bitcoin_tx.transaction));
3933
3933
3934
- match &self.holder_signer {
3934
+ // We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
3935
+ let signature = match &self.holder_signer {
3935
3936
// TODO (arik): move match into calling method for Taproot
3936
- ChannelSignerType::Ecdsa(ecdsa) => {
3937
- let funding_signed = ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx)
3938
- .map(|(signature, _)| msgs::FundingSigned {
3939
- channel_id: self.channel_id(),
3940
- signature,
3941
- #[cfg(taproot)]
3942
- partial_signature_with_nonce: None,
3943
- })
3944
- .ok();
3945
-
3946
- if funding_signed.is_none() {
3947
- #[cfg(not(async_signing))] {
3948
- panic!("Failed to get signature for funding_signed");
3949
- }
3950
- #[cfg(async_signing)] {
3951
- log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
3952
- self.signer_pending_funding = true;
3953
- }
3954
- } else if self.signer_pending_funding {
3955
- log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
3956
- self.signer_pending_funding = false;
3957
- }
3958
-
3959
- // We sign "counterparty" commitment transaction, allowing them to broadcast the tx if they wish.
3960
- funding_signed
3961
- },
3937
+ ChannelSignerType::Ecdsa(ecdsa) => ecdsa.sign_counterparty_commitment(
3938
+ &counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx
3939
+ ).ok(),
3962
3940
// TODO (taproot|arik)
3963
3941
#[cfg(taproot)]
3964
3942
_ => todo!()
3943
+ };
3944
+
3945
+ if signature.is_some() && self.signer_pending_funding {
3946
+ log_trace!(logger, "Counterparty commitment signature available for funding_signed message; clearing signer_pending_funding");
3947
+ self.signer_pending_funding = false;
3948
+ } else if signature.is_none() {
3949
+ #[cfg(not(async_signing))] {
3950
+ panic!("Failed to get signature for funding_signed");
3951
+ }
3952
+ #[cfg(async_signing)] {
3953
+ log_trace!(logger, "Counterparty commitment signature not available for funding_signed message; setting signer_pending_funding");
3954
+ self.signer_pending_funding = true;
3955
+ }
3965
3956
}
3957
+
3958
+ signature.map(|(signature, _)| msgs::FundingSigned {
3959
+ channel_id: self.channel_id(),
3960
+ signature,
3961
+ #[cfg(taproot)]
3962
+ partial_signature_with_nonce: None,
3963
+ })
3966
3964
}
3967
3965
3968
3966
/// If we receive an error message when attempting to open a channel, it may only be a rejection
@@ -8318,19 +8316,27 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
8318
8316
// TODO (taproot|arik): move match into calling method for Taproot
8319
8317
ChannelSignerType::Ecdsa(ecdsa) => {
8320
8318
ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.context.secp_ctx)
8321
- .map(|(sig, _)| sig).ok()?
8319
+ .map(|(sig, _)| sig).ok()
8322
8320
},
8323
8321
// TODO (taproot|arik)
8324
8322
#[cfg(taproot)]
8325
8323
_ => todo!()
8326
8324
};
8327
8325
8328
- if self.context.signer_pending_funding {
8326
+ if signature.is_some() && self.context.signer_pending_funding {
8329
8327
log_trace!(logger, "Counterparty commitment signature ready for funding_created message: clearing signer_pending_funding");
8330
8328
self.context.signer_pending_funding = false;
8331
- }
8329
+ } else if signature.is_none() {
8330
+ #[cfg(not(async_signing))] {
8331
+ panic!("Failed to get signature for new funding creation");
8332
+ }
8333
+ #[cfg(async_signing)] {
8334
+ log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
8335
+ self.context.signer_pending_funding = true;
8336
+ }
8337
+ };
8332
8338
8333
- Some( msgs::FundingCreated {
8339
+ signature.map(|signature| msgs::FundingCreated {
8334
8340
temporary_channel_id: self.context.temporary_channel_id.unwrap(),
8335
8341
funding_txid: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().txid,
8336
8342
funding_output_index: self.context.channel_transaction_parameters.funding_outpoint.as_ref().unwrap().index,
@@ -8383,18 +8389,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
8383
8389
self.context.is_batch_funding = Some(()).filter(|_| is_batch_funding);
8384
8390
8385
8391
let funding_created = self.get_funding_created_msg(logger);
8386
- if funding_created.is_none() {
8387
- #[cfg(not(async_signing))] {
8388
- panic!("Failed to get signature for new funding creation");
8389
- }
8390
- #[cfg(async_signing)] {
8391
- if !self.context.signer_pending_funding {
8392
- log_trace!(logger, "funding_created awaiting signer; setting signer_pending_funding");
8393
- self.context.signer_pending_funding = true;
8394
- }
8395
- }
8396
- }
8397
-
8398
8392
Ok(funding_created)
8399
8393
}
8400
8394
@@ -8552,7 +8546,6 @@ impl<SP: Deref> OutboundV1Channel<SP> where SP::Target: SignerProvider {
8552
8546
} else { None };
8553
8547
let funding_created = if self.context.signer_pending_funding && self.context.is_outbound() {
8554
8548
log_trace!(logger, "Attempting to generate pending funding created...");
8555
- self.context.signer_pending_funding = false;
8556
8549
self.get_funding_created_msg(logger)
8557
8550
} else { None };
8558
8551
(open_channel, funding_created)
0 commit comments