@@ -162,6 +162,9 @@ pub enum APIError {
162162 #[ error( "Invalid payment hash: {0}" ) ]
163163 InvalidPaymentHash ( String ) ,
164164
165+ #[ error( "Payment hash already used" ) ]
166+ PaymentHashAlreadyUsed ,
167+
165168 #[ error( "Invalid payment secret" ) ]
166169 InvalidPaymentSecret ,
167170
@@ -210,6 +213,24 @@ pub enum APIError {
210213 #[ error( "Invalid transport endpoints: {0}" ) ]
211214 InvalidTransportEndpoints ( String ) ,
212215
216+ #[ error( "Invoice is expired" ) ]
217+ InvoiceExpired ,
218+
219+ #[ error( "HTLC claim deadline exceeded" ) ]
220+ ClaimDeadlineExceeded ,
221+
222+ #[ error( "Invoice is not marked as HODL" ) ]
223+ InvoiceNotHodl ,
224+
225+ #[ error( "No claimable HTLC found for this invoice" ) ]
226+ InvoiceNotClaimable ,
227+
228+ #[ error( "Invoice settlement is in progress" ) ]
229+ InvoiceSettlingInProgress ,
230+
231+ #[ error( "Invoice is already settled" ) ]
232+ InvoiceAlreadySettled ,
233+
213234 #[ error( "IO error: {0}" ) ]
214235 IO ( #[ from] std:: io:: Error ) ,
215236
@@ -234,6 +255,9 @@ pub enum APIError {
234255 #[ error( "Unable to find payment preimage, be sure you've provided the correct swap info" ) ]
235256 MissingSwapPaymentPreimage ,
236257
258+ #[ error( "Invalid payment preimage" ) ]
259+ InvalidPaymentPreimage ,
260+
237261 #[ error( "Network error: {0}" ) ]
238262 Network ( String ) ,
239263
@@ -437,13 +461,16 @@ impl IntoResponse for APIError {
437461 | APIError :: InvalidOnionData ( _)
438462 | APIError :: InvalidPassword ( _)
439463 | APIError :: InvalidPaymentHash ( _)
464+ | APIError :: PaymentHashAlreadyUsed
440465 | APIError :: InvalidPaymentSecret
466+ | APIError :: InvalidPaymentPreimage
441467 | APIError :: InvalidPeerInfo ( _)
442468 | APIError :: InvalidPrecision ( _)
443469 | APIError :: InvalidPubkey
444470 | APIError :: InvalidRecipientData ( _)
445471 | APIError :: InvalidRecipientID
446472 | APIError :: InvalidRecipientNetwork
473+ | APIError :: InvoiceExpired
447474 | APIError :: InvalidSwap ( _)
448475 | APIError :: InvalidSwapString ( _, _)
449476 | APIError :: InvalidTicker ( _)
@@ -454,6 +481,7 @@ impl IntoResponse for APIError {
454481 | APIError :: MediaFileNotProvided
455482 | APIError :: MissingSwapPaymentPreimage
456483 | APIError :: OutputBelowDustLimit
484+ | APIError :: ClaimDeadlineExceeded
457485 | APIError :: UnsupportedBackupVersion { .. } => {
458486 ( StatusCode :: BAD_REQUEST , self . to_string ( ) , self . name ( ) )
459487 }
@@ -499,6 +527,13 @@ impl IntoResponse for APIError {
499527 | APIError :: UnsupportedTransportType => {
500528 ( StatusCode :: FORBIDDEN , self . to_string ( ) , self . name ( ) )
501529 }
530+ APIError :: InvoiceNotClaimable => ( StatusCode :: NOT_FOUND , self . to_string ( ) , self . name ( ) ) ,
531+ APIError :: InvoiceAlreadySettled => {
532+ ( StatusCode :: CONFLICT , self . to_string ( ) , self . name ( ) )
533+ }
534+ APIError :: InvoiceNotHodl | APIError :: InvoiceSettlingInProgress => {
535+ ( StatusCode :: FORBIDDEN , self . to_string ( ) , self . name ( ) )
536+ }
502537 APIError :: Network ( _) | APIError :: NoValidTransportEndpoint => (
503538 StatusCode :: SERVICE_UNAVAILABLE ,
504539 self . to_string ( ) ,
0 commit comments