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