@@ -164,6 +164,9 @@ pub enum APIError {
164164 #[ error( "Invalid payment hash: {0}" ) ]
165165 InvalidPaymentHash ( String ) ,
166166
167+ #[ error( "Invalid payment preimage" ) ]
168+ InvalidPaymentPreimage ,
169+
167170 #[ error( "Invalid payment secret" ) ]
168171 InvalidPaymentSecret ,
169172
@@ -215,6 +218,24 @@ pub enum APIError {
215218 #[ error( "Invalid transport endpoints: {0}" ) ]
216219 InvalidTransportEndpoints ( String ) ,
217220
221+ #[ error( "HTLC claim deadline exceeded" ) ]
222+ ClaimDeadlineExceeded ,
223+
224+ #[ error( "Invoice is already settled" ) ]
225+ InvoiceAlreadySettled ,
226+
227+ #[ error( "Invoice is expired" ) ]
228+ InvoiceExpired ,
229+
230+ #[ error( "No claimable HTLC found for this invoice" ) ]
231+ InvoiceNotClaimable ,
232+
233+ #[ error( "Invoice is not marked as HODL" ) ]
234+ InvoiceNotHodl ,
235+
236+ #[ error( "Invoice settlement is in progress" ) ]
237+ InvoiceSettlingInProgress ,
238+
218239 #[ error( "IO error: {0}" ) ]
219240 IO ( #[ from] std:: io:: Error ) ,
220241
@@ -260,6 +281,9 @@ pub enum APIError {
260281 #[ error( "Output below the dust limit" ) ]
261282 OutputBelowDustLimit ,
262283
284+ #[ error( "Payment hash already used" ) ]
285+ PaymentHashAlreadyUsed ,
286+
263287 #[ error( "Payment not found: {0}" ) ]
264288 PaymentNotFound ( String ) ,
265289
@@ -447,6 +471,8 @@ impl IntoResponse for APIError {
447471 | APIError :: InvalidOnionData ( _)
448472 | APIError :: InvalidPassword ( _)
449473 | APIError :: InvalidPaymentHash ( _)
474+ | APIError :: PaymentHashAlreadyUsed
475+ | APIError :: InvalidPaymentPreimage
450476 | APIError :: InvalidPaymentSecret
451477 | APIError :: InvalidPeerInfo ( _)
452478 | APIError :: InvalidPrecision ( _)
@@ -461,10 +487,12 @@ impl IntoResponse for APIError {
461487 | APIError :: InvalidTlvType ( _)
462488 | APIError :: InvalidTransportEndpoint ( _)
463489 | APIError :: InvalidTransportEndpoints ( _)
490+ | APIError :: InvoiceExpired
464491 | APIError :: MediaFileEmpty
465492 | APIError :: MediaFileNotProvided
466493 | APIError :: MissingSwapPaymentPreimage
467494 | APIError :: OutputBelowDustLimit
495+ | APIError :: ClaimDeadlineExceeded
468496 | APIError :: UnsupportedBackupVersion { .. } => {
469497 ( StatusCode :: BAD_REQUEST , self . to_string ( ) , self . name ( ) )
470498 }
@@ -489,6 +517,8 @@ impl IntoResponse for APIError {
489517 | APIError :: InvalidIndexer ( _)
490518 | APIError :: InvalidProxyEndpoint
491519 | APIError :: InvalidProxyProtocol ( _)
520+ | APIError :: InvoiceNotHodl
521+ | APIError :: InvoiceSettlingInProgress
492522 | APIError :: LockedNode
493523 | APIError :: MaxFeeExceeded ( _)
494524 | APIError :: MinFeeNotMet ( _)
@@ -510,6 +540,10 @@ impl IntoResponse for APIError {
510540 | APIError :: UnsupportedTransportType => {
511541 ( StatusCode :: FORBIDDEN , self . to_string ( ) , self . name ( ) )
512542 }
543+ APIError :: InvoiceAlreadySettled => {
544+ ( StatusCode :: CONFLICT , self . to_string ( ) , self . name ( ) )
545+ }
546+ APIError :: InvoiceNotClaimable => ( StatusCode :: NOT_FOUND , self . to_string ( ) , self . name ( ) ) ,
513547 APIError :: Network ( _) | APIError :: NoValidTransportEndpoint => (
514548 StatusCode :: SERVICE_UNAVAILABLE ,
515549 self . to_string ( ) ,
0 commit comments