11use bdk:: blockchain:: esplora;
2- use lightning:: ln:: msgs;
3- use lightning:: util:: errors;
4- use lightning_invoice:: payment;
52use std:: fmt;
6- use std:: io;
7- use std:: time;
83
94#[ derive( Debug ) ]
105/// An error that possibly needs to be handled by the user.
@@ -19,112 +14,65 @@ pub enum LdkLiteError {
1914 ConnectionFailed ,
2015 /// Payment of the given invoice has already been intiated.
2116 NonUniquePaymentHash ,
17+ /// The given invoice is invalid.
18+ InvoiceInvalid ,
19+ /// Invoice creation failed.
20+ InvoiceCreationFailed ,
21+ /// No route for the given target could be found.
22+ RoutingFailed ,
2223 /// A given peer info could not be parsed.
23- PeerInfoParse ( & ' static str ) ,
24- /// A wrapped LDK `APIError`
25- LdkApi ( errors:: APIError ) ,
26- /// A wrapped LDK `DecodeError`
27- LdkDecode ( msgs:: DecodeError ) ,
28- /// A wrapped LDK `PaymentError`
29- LdkPayment ( payment:: PaymentError ) ,
30- /// A wrapped LDK `SignOrCreationError`
31- LdkInvoiceCreation ( lightning_invoice:: SignOrCreationError ) ,
32- /// A wrapped BDK error
33- Bdk ( bdk:: Error ) ,
34- /// A wrapped `EsploraError`
35- Esplora ( esplora:: EsploraError ) ,
36- /// A wrapped `Bip32` error
37- Bip32 ( bitcoin:: util:: bip32:: Error ) ,
38- /// A wrapped `std::io::Error`
39- StdIo ( io:: Error ) ,
40- /// A wrapped `SystemTimeError`
41- StdTime ( time:: SystemTimeError ) ,
24+ PeerInfoParseFailed ,
25+ /// A channel could not be opened.
26+ ChannelCreationFailed ,
27+ /// A channel could not be closed.
28+ ChannelClosingFailed ,
29+ /// Persistence failed.
30+ PersistenceFailed ,
31+ /// A wallet operation failed.
32+ WalletOperationFailed ,
33+ /// A siging operation failed.
34+ WalletSigningFailed ,
35+ /// A chain access operation failed.
36+ ChainAccessFailed ,
4237}
4338
4439impl fmt:: Display for LdkLiteError {
4540 fn fmt ( & self , f : & mut fmt:: Formatter ) -> fmt:: Result {
4641 match * self {
47- LdkLiteError :: AlreadyRunning => write ! ( f, "LDKLite is already running." ) ,
48- LdkLiteError :: NotRunning => write ! ( f, "LDKLite is not running." ) ,
49- LdkLiteError :: FundingTxCreationFailed => {
50- write ! ( f, "the funding transaction could not be created" )
42+ Self :: AlreadyRunning => write ! ( f, "LDKLite is already running." ) ,
43+ Self :: NotRunning => write ! ( f, "LDKLite is not running." ) ,
44+ Self :: FundingTxCreationFailed => {
45+ write ! ( f, "Funding transaction could not be created. " )
5146 }
52- LdkLiteError :: ConnectionFailed => write ! ( f, "network connection closed" ) ,
53- LdkLiteError :: NonUniquePaymentHash => write ! ( f, "an invoice must not get payed twice." ) ,
54- LdkLiteError :: PeerInfoParse ( ref e) => {
55- write ! ( f, "given peer info could not be parsed: {}" , e)
56- }
57- LdkLiteError :: LdkDecode ( ref e) => write ! ( f, "LDK decode error: {}" , e) ,
58- LdkLiteError :: LdkApi ( ref e) => write ! ( f, "LDK API error: {:?}" , e) ,
59- LdkLiteError :: LdkPayment ( ref e) => write ! ( f, "LDK payment error: {:?}" , e) ,
60- LdkLiteError :: LdkInvoiceCreation ( ref e) => {
61- write ! ( f, "LDK invoice sign or creation error: {:?}" , e)
62- }
63- LdkLiteError :: Bdk ( ref e) => write ! ( f, "BDK error: {}" , e) ,
64- LdkLiteError :: Esplora ( ref e) => write ! ( f, "Esplora error: {}" , e) ,
65- LdkLiteError :: Bip32 ( ref e) => write ! ( f, "Bitcoin error: {}" , e) ,
66- LdkLiteError :: StdIo ( ref e) => write ! ( f, "IO error: {}" , e) ,
67- LdkLiteError :: StdTime ( ref e) => write ! ( f, "time error: {}" , e) ,
47+ Self :: ConnectionFailed => write ! ( f, "Network connection closed." ) ,
48+ Self :: NonUniquePaymentHash => write ! ( f, "An invoice must not get payed twice." ) ,
49+ Self :: InvoiceInvalid => write ! ( f, "The given invoice is invalid." ) ,
50+ Self :: InvoiceCreationFailed => write ! ( f, "Failed to create invoice." ) ,
51+ Self :: RoutingFailed => write ! ( f, "Failed to find route." ) ,
52+ Self :: PeerInfoParseFailed => write ! ( f, "Failed to parse the given peer information." ) ,
53+ Self :: ChannelCreationFailed => write ! ( f, "Failed to create channel." ) ,
54+ Self :: ChannelClosingFailed => write ! ( f, "Failed to close channel." ) ,
55+ Self :: PersistenceFailed => write ! ( f, "Failed to persist data." ) ,
56+ Self :: WalletOperationFailed => write ! ( f, "Failed to conduct wallet operation." ) ,
57+ Self :: WalletSigningFailed => write ! ( f, "Failed to sign given transaction." ) ,
58+ Self :: ChainAccessFailed => write ! ( f, "Failed to conduct chain access operation." ) ,
6859 }
6960 }
7061}
7162
72- impl From < errors:: APIError > for LdkLiteError {
73- fn from ( e : errors:: APIError ) -> Self {
74- Self :: LdkApi ( e)
75- }
76- }
77-
78- impl From < msgs:: DecodeError > for LdkLiteError {
79- fn from ( e : msgs:: DecodeError ) -> Self {
80- Self :: LdkDecode ( e)
81- }
82- }
83-
84- impl From < payment:: PaymentError > for LdkLiteError {
85- fn from ( e : payment:: PaymentError ) -> Self {
86- Self :: LdkPayment ( e)
87- }
88- }
89-
90- impl From < lightning_invoice:: SignOrCreationError > for LdkLiteError {
91- fn from ( e : lightning_invoice:: SignOrCreationError ) -> Self {
92- Self :: LdkInvoiceCreation ( e)
93- }
94- }
63+ impl std:: error:: Error for LdkLiteError { }
9564
9665impl From < bdk:: Error > for LdkLiteError {
9766 fn from ( e : bdk:: Error ) -> Self {
98- Self :: Bdk ( e)
99- }
100- }
101-
102- impl From < bdk:: sled:: Error > for LdkLiteError {
103- fn from ( e : bdk:: sled:: Error ) -> Self {
104- Self :: Bdk ( bdk:: Error :: Sled ( e) )
105- }
106- }
107-
108- impl From < bitcoin:: util:: bip32:: Error > for LdkLiteError {
109- fn from ( e : bitcoin:: util:: bip32:: Error ) -> Self {
110- Self :: Bip32 ( e)
111- }
112- }
113-
114- impl From < io:: Error > for LdkLiteError {
115- fn from ( e : io:: Error ) -> Self {
116- Self :: StdIo ( e)
117- }
118- }
119-
120- impl From < time:: SystemTimeError > for LdkLiteError {
121- fn from ( e : time:: SystemTimeError ) -> Self {
122- Self :: StdTime ( e)
67+ match e {
68+ bdk:: Error :: Signer ( _) => Self :: WalletSigningFailed ,
69+ _ => Self :: WalletOperationFailed ,
70+ }
12371 }
12472}
12573
12674impl From < esplora:: EsploraError > for LdkLiteError {
127- fn from ( e : esplora:: EsploraError ) -> Self {
128- Self :: Esplora ( e )
75+ fn from ( _e : esplora:: EsploraError ) -> Self {
76+ Self :: ChainAccessFailed
12977 }
13078}
0 commit comments