@@ -1009,16 +1009,6 @@ impl ChannelError {
1009
1009
pub(super) fn close(err: String) -> Self {
1010
1010
ChannelError::Close((err.clone(), ClosureReason::ProcessingError { err }))
1011
1011
}
1012
-
1013
- pub(super) fn message(&self) -> &str {
1014
- match self {
1015
- &ChannelError::Ignore(ref e) => &e,
1016
- &ChannelError::Warn(ref e) => &e,
1017
- &ChannelError::WarnAndDisconnect(ref e) => &e,
1018
- &ChannelError::Close((ref e, _)) => &e,
1019
- &ChannelError::SendError(ref e) => &e,
1020
- }
1021
- }
1022
1012
}
1023
1013
1024
1014
pub(super) struct WithChannelContext<'a, L: Deref>
@@ -5535,12 +5525,12 @@ where
5535
5525
5536
5526
let commitment_signed = self.get_initial_commitment_signed(&funding, logger);
5537
5527
let commitment_signed = match commitment_signed {
5538
- Ok (commitment_signed) => commitment_signed,
5539
- Err(e) => {
5528
+ Some (commitment_signed) => commitment_signed,
5529
+ None => {
5540
5530
funding.channel_transaction_parameters.funding_outpoint = None;
5541
5531
return Err(msgs::TxAbort {
5542
5532
channel_id: self.channel_id(),
5543
- data: e.message() .to_owned().into_bytes(),
5533
+ data: "Failed to get signature for commitment_signed" .to_owned().into_bytes(),
5544
5534
});
5545
5535
},
5546
5536
};
@@ -5601,7 +5591,7 @@ where
5601
5591
#[rustfmt::skip]
5602
5592
fn get_initial_counterparty_commitment_signature<L: Deref>(
5603
5593
&self, funding: &FundingScope, logger: &L
5604
- ) -> Result <Signature, ChannelError >
5594
+ ) -> Option <Signature>
5605
5595
where
5606
5596
SP::Target: SignerProvider,
5607
5597
L::Target: Logger
@@ -5616,11 +5606,7 @@ where
5616
5606
let channel_parameters = &funding.channel_transaction_parameters;
5617
5607
ecdsa.sign_counterparty_commitment(channel_parameters, &counterparty_initial_commitment_tx, Vec::new(), Vec::new(), &self.secp_ctx)
5618
5608
.map(|(signature, _)| signature)
5619
- .map_err(|()| {
5620
- let msg = "Failed to get signatures for new commitment_signed";
5621
- let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
5622
- ChannelError::Close((msg.to_owned(), reason))
5623
- })
5609
+ .ok()
5624
5610
},
5625
5611
// TODO (taproot|arik)
5626
5612
#[cfg(taproot)]
@@ -5631,38 +5617,35 @@ where
5631
5617
#[rustfmt::skip]
5632
5618
fn get_initial_commitment_signed<L: Deref>(
5633
5619
&mut self, funding: &FundingScope, logger: &L
5634
- ) -> Result <msgs::CommitmentSigned, ChannelError >
5620
+ ) -> Option <msgs::CommitmentSigned>
5635
5621
where
5636
5622
SP::Target: SignerProvider,
5637
5623
L::Target: Logger
5638
5624
{
5639
5625
assert!(matches!(self.channel_state, ChannelState::FundingNegotiated(_)));
5640
5626
5641
- let signature = match self.get_initial_counterparty_commitment_signature(funding, logger) {
5642
- Ok(res) => res,
5643
- Err(e) => {
5644
- log_error!(logger, "Got bad signatures: {:?}!", e);
5645
- return Err(e);
5646
- }
5647
- };
5648
-
5649
- log_info!(logger, "Generated commitment_signed for peer for channel {}", &self.channel_id());
5650
-
5651
- Ok(msgs::CommitmentSigned {
5652
- channel_id: self.channel_id,
5653
- htlc_signatures: vec![],
5654
- signature,
5655
- funding_txid: funding.get_funding_txo().map(|funding_txo| funding_txo.txid),
5656
- #[cfg(taproot)]
5657
- partial_signature_with_nonce: None,
5658
- })
5627
+ let signature = self.get_initial_counterparty_commitment_signature(funding, logger);
5628
+ if let Some(signature) = signature {
5629
+ log_info!(logger, "Generated commitment_signed for peer for channel {}", &self.channel_id());
5630
+ Some(msgs::CommitmentSigned {
5631
+ channel_id: self.channel_id,
5632
+ htlc_signatures: vec![],
5633
+ signature,
5634
+ funding_txid: funding.get_funding_txo().map(|funding_txo| funding_txo.txid),
5635
+ #[cfg(taproot)]
5636
+ partial_signature_with_nonce: None,
5637
+ })
5638
+ } else {
5639
+ // TODO: Support async signing
5640
+ None
5641
+ }
5659
5642
}
5660
5643
5661
5644
#[cfg(all(test))]
5662
5645
pub fn get_initial_counterparty_commitment_signature_for_test<L: Deref>(
5663
5646
&mut self, funding: &mut FundingScope, logger: &L,
5664
5647
counterparty_cur_commitment_point_override: PublicKey,
5665
- ) -> Result <Signature, ChannelError >
5648
+ ) -> Option <Signature>
5666
5649
where
5667
5650
SP::Target: SignerProvider,
5668
5651
L::Target: Logger,
@@ -8815,7 +8798,16 @@ where
8815
8798
// if it has not received tx_signatures for that funding transaction AND
8816
8799
// if next_commitment_number is zero:
8817
8800
// MUST retransmit its commitment_signed for that funding transaction.
8818
- let commitment_signed = self.context.get_initial_commitment_signed(&self.funding, logger)?;
8801
+ let commitment_signed = self.context.get_initial_commitment_signed(&self.funding, logger)
8802
+ // TODO Support async signing
8803
+ .ok_or_else(|| {
8804
+ let message = "Failed to get signatures for new commitment_signed".to_owned();
8805
+ ChannelError::Close(
8806
+ (
8807
+ message.clone(),
8808
+ ClosureReason::HolderForceClosed { message, broadcasted_latest_txn: Some(false) },
8809
+ )
8810
+ )})?;
8819
8811
Some(msgs::CommitmentUpdate {
8820
8812
commitment_signed: vec![commitment_signed],
8821
8813
update_add_htlcs: vec![],
0 commit comments