@@ -1760,7 +1760,7 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
1760
1760
1761
1761
fn funding_tx_constructed<L: Deref>(
1762
1762
&mut self, logger: &L
1763
- ) -> Result<(msgs::CommitmentSigned, Option<Event>), ChannelError>
1763
+ ) -> Result<(Option< msgs::CommitmentSigned> , Option<Event>), ChannelError>
1764
1764
where
1765
1765
L::Target: Logger
1766
1766
{
@@ -1803,11 +1803,14 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
1803
1803
1804
1804
let commitment_signed = context.get_initial_commitment_signed(logger);
1805
1805
let commitment_signed = match commitment_signed {
1806
- Ok (commitment_signed) => {
1806
+ Some (commitment_signed) => {
1807
1807
context.funding_transaction = Some(unsigned_tx.into_unsigned_tx());
1808
1808
commitment_signed
1809
1809
},
1810
- Err(err) => return Err(ChannelError::Close((err.to_string(), ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) }))),
1810
+ None => {
1811
+ context.channel_transaction_parameters.funding_outpoint = None;
1812
+ return Ok((None, None));
1813
+ },
1811
1814
};
1812
1815
1813
1816
let funding_ready_for_sig_event = None;
@@ -1839,7 +1842,7 @@ pub(super) trait InteractivelyFunded<SP: Deref> where SP::Target: SignerProvider
1839
1842
// Clear the interactive transaction constructor
1840
1843
self.interactive_tx_constructor_mut().take();
1841
1844
1842
- Ok((commitment_signed, funding_ready_for_sig_event))
1845
+ Ok((Some( commitment_signed) , funding_ready_for_sig_event))
1843
1846
}
1844
1847
}
1845
1848
@@ -4031,7 +4034,7 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
4031
4034
4032
4035
fn get_initial_counterparty_commitment_signature<L: Deref>(
4033
4036
&self, logger: &L
4034
- ) -> Result <Signature, ChannelError >
4037
+ ) -> Option <Signature>
4035
4038
where
4036
4039
SP::Target: SignerProvider,
4037
4040
L::Target: Logger
@@ -4044,19 +4047,15 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
4044
4047
ChannelSignerType::Ecdsa(ref ecdsa) => {
4045
4048
ecdsa.sign_counterparty_commitment(&counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx)
4046
4049
.map(|(signature, _)| signature)
4047
- .map_err(|_| ChannelError::Close(
4048
- (
4049
- "Failed to get signatures for new commitment_signed".to_owned(),
4050
- ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false) },
4051
- )))
4050
+ .ok()
4052
4051
},
4053
4052
// TODO (taproot|arik)
4054
4053
#[cfg(taproot)]
4055
4054
_ => todo!(),
4056
4055
}
4057
4056
}
4058
4057
4059
- fn get_initial_commitment_signed<L: Deref>(&mut self, logger: &L) -> Result <msgs::CommitmentSigned, ChannelError >
4058
+ fn get_initial_commitment_signed<L: Deref>(&mut self, logger: &L) -> Option <msgs::CommitmentSigned>
4060
4059
where
4061
4060
SP::Target: SignerProvider,
4062
4061
L::Target: Logger
@@ -4072,32 +4071,42 @@ impl<SP: Deref> ChannelContext<SP> where SP::Target: SignerProvider {
4072
4071
panic!("Should not have advanced channel commitment tx numbers prior to initial commitment_signed");
4073
4072
}
4074
4073
4075
- let signature = match self.get_initial_counterparty_commitment_signature(logger) {
4076
- Ok(res) => res,
4077
- Err(e) => {
4078
- log_error!(logger, "Got bad signatures: {:?}!", e);
4079
- self.channel_transaction_parameters.funding_outpoint = None;
4080
- return Err(e);
4081
- }
4082
- };
4074
+ match self.get_initial_counterparty_commitment_signature(logger) {
4075
+ Some(signature) => {
4076
+ if self.signer_pending_funding {
4077
+ log_trace!(logger, "Counterparty commitment signature ready for initial commitment_signed message: clearing signer_pending_funding");
4078
+ self.signer_pending_funding = false;
4079
+ }
4083
4080
4084
- log_info!(logger, "Generated commitment_signed for peer for channel {}", &self.channel_id() );
4081
+ log_info!(logger, "Generated commitment_signed for peer for channel {}", &self.channel_id);
4085
4082
4086
- Ok(msgs::CommitmentSigned {
4087
- channel_id: self.channel_id,
4088
- htlc_signatures: vec![],
4089
- signature,
4090
- batch: None,
4091
- #[cfg(taproot)]
4092
- partial_signature_with_nonce: None,
4093
- })
4083
+ Some(msgs::CommitmentSigned {
4084
+ channel_id: self.channel_id,
4085
+ htlc_signatures: vec![],
4086
+ signature,
4087
+ batch: None,
4088
+ #[cfg(taproot)]
4089
+ partial_signature_with_nonce: None,
4090
+ })
4091
+ },
4092
+ None => {
4093
+ #[cfg(not(async_signing))] {
4094
+ panic!("Failed to get signature for initial commitment_signed");
4095
+ }
4096
+ #[cfg(async_signing)] {
4097
+ log_trace!(logger, "Counterparty commitment signature not available for initial commitment_signed message; setting signer_pending_funding");
4098
+ self.signer_pending_funding = true;
4099
+ None
4100
+ }
4101
+ },
4102
+ }
4094
4103
}
4095
4104
4096
4105
#[cfg(test)]
4097
4106
pub fn get_initial_counterparty_commitment_signature_for_test<L: Deref>(
4098
4107
&mut self, logger: &L, channel_transaction_parameters: ChannelTransactionParameters,
4099
4108
counterparty_cur_commitment_point_override: PublicKey,
4100
- ) -> Result <Signature, ChannelError >
4109
+ ) -> Option <Signature>
4101
4110
where
4102
4111
SP::Target: SignerProvider,
4103
4112
L::Target: Logger
0 commit comments