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