@@ -1009,6 +1009,16 @@ 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
+ }
1012
1022
}
1013
1023
1014
1024
pub(super) struct WithChannelContext<'a, L: Deref>
@@ -1774,7 +1784,7 @@ where
1774
1784
1775
1785
pub fn funding_tx_constructed<L: Deref>(
1776
1786
&mut self, logger: &L,
1777
- ) -> Result<(msgs::CommitmentSigned, Option<Event>), ChannelError >
1787
+ ) -> Result<(msgs::CommitmentSigned, Option<Event>), msgs::TxAbort >
1778
1788
where
1779
1789
L::Target: Logger,
1780
1790
{
@@ -1829,14 +1839,17 @@ where
1829
1839
}
1830
1840
}
1831
1841
1832
- return Err(ChannelError::Warn(
1833
- "Got a tx_complete message in an invalid state".to_owned(),
1834
- ));
1842
+ return Err(msgs::TxAbort {
1843
+ channel_id: chan.context.channel_id(),
1844
+ data: "Got a tx_complete message in an invalid state".to_owned().into_bytes(),
1845
+ });
1835
1846
},
1836
1847
_ => {
1837
- return Err(ChannelError::Warn(
1838
- "Got a tx_complete message in an invalid phase".to_owned(),
1839
- ))
1848
+ debug_assert!(false);
1849
+ return Err(msgs::TxAbort {
1850
+ channel_id: self.context().channel_id(),
1851
+ data: "Got a tx_complete message in an invalid phase".to_owned().into_bytes(),
1852
+ });
1840
1853
},
1841
1854
}
1842
1855
}
@@ -5476,7 +5489,7 @@ where
5476
5489
fn funding_tx_constructed<L: Deref>(
5477
5490
&mut self, funding: &mut FundingScope, signing_session: &mut InteractiveTxSigningSession,
5478
5491
is_splice: bool, holder_commitment_transaction_number: u64, logger: &L
5479
- ) -> Result<(msgs::CommitmentSigned, Option<Event>), ChannelError >
5492
+ ) -> Result<(msgs::CommitmentSigned, Option<Event>), msgs::TxAbort >
5480
5493
where
5481
5494
L::Target: Logger
5482
5495
{
@@ -5485,19 +5498,21 @@ where
5485
5498
for (idx, outp) in signing_session.unsigned_tx().outputs().enumerate() {
5486
5499
if outp.script_pubkey() == &expected_spk && outp.value() == funding.get_value_satoshis() {
5487
5500
if output_index.is_some() {
5488
- let msg = "Multiple outputs matched the expected script and value";
5489
- let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
5490
- return Err(ChannelError::Close((msg.to_owned(), reason)));
5501
+ return Err(msgs::TxAbort {
5502
+ channel_id: self.channel_id(),
5503
+ data: "Multiple outputs matched the expected script and value".to_owned().into_bytes(),
5504
+ });
5491
5505
}
5492
5506
output_index = Some(idx as u16);
5493
5507
}
5494
5508
}
5495
5509
let outpoint = if let Some(output_index) = output_index {
5496
5510
OutPoint { txid: signing_session.unsigned_tx().compute_txid(), index: output_index }
5497
5511
} else {
5498
- let msg = "No output matched the funding script_pubkey";
5499
- let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
5500
- return Err(ChannelError::Close((msg.to_owned(), reason)));
5512
+ return Err(msgs::TxAbort {
5513
+ channel_id: self.channel_id(),
5514
+ data: "No output matched the funding script_pubkey".to_owned().into_bytes(),
5515
+ });
5501
5516
};
5502
5517
funding
5503
5518
.channel_transaction_parameters.funding_outpoint = Some(outpoint);
@@ -5507,12 +5522,11 @@ where
5507
5522
holder_commitment_transaction_number,
5508
5523
self.cur_counterparty_commitment_transaction_number,
5509
5524
);
5510
- let message = "TODO Forced error, incomplete implementation".to_owned();
5511
5525
// TODO(splicing) Forced error, as the use case is not complete
5512
- return Err(ChannelError::Close((
5513
- message.clone (),
5514
- ClosureReason::HolderForceClosed { broadcasted_latest_txn: Some(false), message }
5515
- )) );
5526
+ return Err(msgs::TxAbort {
5527
+ channel_id: self.channel_id (),
5528
+ data: "Splicing not yet supported".to_owned().into_bytes(),
5529
+ } );
5516
5530
} else {
5517
5531
self.assert_no_commitment_advancement(holder_commitment_transaction_number, "initial commitment_signed");
5518
5532
}
@@ -5522,7 +5536,10 @@ where
5522
5536
Ok(commitment_signed) => commitment_signed,
5523
5537
Err(e) => {
5524
5538
funding.channel_transaction_parameters.funding_outpoint = None;
5525
- return Err(e)
5539
+ return Err(msgs::TxAbort {
5540
+ channel_id: self.channel_id(),
5541
+ data: e.message().to_owned().into_bytes(),
5542
+ });
5526
5543
},
5527
5544
};
5528
5545
@@ -5532,9 +5549,10 @@ where
5532
5549
false,
5533
5550
"Zero inputs were provided & zero witnesses were provided, but a count mismatch was somehow found",
5534
5551
);
5535
- let msg = "V2 channel rejected due to sender error";
5536
- let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
5537
- return Err(ChannelError::Close((msg.to_owned(), reason)));
5552
+ return Err(msgs::TxAbort {
5553
+ channel_id: self.channel_id(),
5554
+ data: "V2 channel rejected due to sender error".to_owned().into_bytes(),
5555
+ });
5538
5556
}
5539
5557
None
5540
5558
} else {
@@ -5556,9 +5574,10 @@ where
5556
5574
false,
5557
5575
"We don't support users providing inputs but somehow we had more than zero inputs",
5558
5576
);
5559
- let msg = "V2 channel rejected due to sender error";
5560
- let reason = ClosureReason::ProcessingError { err: msg.to_owned() };
5561
- return Err(ChannelError::Close((msg.to_owned(), reason)));
5577
+ return Err(msgs::TxAbort {
5578
+ channel_id: self.channel_id(),
5579
+ data: "V2 channel rejected due to sender error".to_owned().into_bytes(),
5580
+ });
5562
5581
};
5563
5582
5564
5583
let mut channel_state = ChannelState::FundingNegotiated(FundingNegotiatedFlags::new());
0 commit comments