1use thiserror::Error;
4use tonic::Status;
5
6#[derive(Debug, Error)]
8pub enum Error {
9 #[error("Unknown invoice amount")]
11 UnknownInvoiceAmount,
12 #[error("Unknown invoice")]
14 UnknownInvoice,
15 #[error("LND connection error")]
17 Connection,
18 #[error("Invalid hash")]
20 InvalidHash,
21 #[error("LND payment failed")]
23 PaymentFailed,
24 #[error("LND unknown payment status")]
26 UnknownPaymentStatus,
27 #[error("LND missing last hop in route")]
29 MissingLastHop,
30 #[error("Amount overflow")]
32 AmountOverflow,
33 #[error("LND error: `{0}`")]
35 LndError(Status),
36 #[error("LND invalid config: `{0}`")]
38 InvalidConfig(String),
39 #[error("Could not read file")]
41 ReadFile,
42}
43
44impl From<Error> for cdk_common::payment::Error {
45 fn from(e: Error) -> Self {
46 Self::Lightning(Box::new(e))
47 }
48}
49
50impl From<tonic::transport::Error> for Error {
51 fn from(e: tonic::transport::Error) -> Self {
52 Error::InvalidConfig(format!("Transport error: {e}"))
53 }
54}