@@ -167,6 +167,9 @@ pub enum APIError {
167167 #[ error( "Invalid payment hash: {0}" ) ]
168168 InvalidPaymentHash ( String ) ,
169169
170+ #[ error( "Invalid payment preimage" ) ]
171+ InvalidPaymentPreimage ,
172+
170173 #[ error( "Invalid payment secret" ) ]
171174 InvalidPaymentSecret ,
172175
@@ -221,6 +224,24 @@ pub enum APIError {
221224 #[ error( "Invalid transport endpoints: {0}" ) ]
222225 InvalidTransportEndpoints ( String ) ,
223226
227+ #[ error( "HTLC claim deadline exceeded" ) ]
228+ ClaimDeadlineExceeded ,
229+
230+ #[ error( "Invoice is already claimed" ) ]
231+ InvoiceAlreadyClaimed ,
232+
233+ #[ error( "Invoice is expired" ) ]
234+ InvoiceExpired ,
235+
236+ #[ error( "No claimable HTLC found for this invoice" ) ]
237+ InvoiceNotClaimable ,
238+
239+ #[ error( "Invoice is not marked as HODL" ) ]
240+ InvoiceNotHodl ,
241+
242+ #[ error( "Invoice settlement is in progress" ) ]
243+ InvoiceSettlingInProgress ,
244+
224245 #[ error( "IO error: {0}" ) ]
225246 IO ( #[ from] std:: io:: Error ) ,
226247
@@ -266,6 +287,9 @@ pub enum APIError {
266287 #[ error( "Output below the dust limit" ) ]
267288 OutputBelowDustLimit ,
268289
290+ #[ error( "Payment hash already used" ) ]
291+ PaymentHashAlreadyUsed ,
292+
269293 #[ error( "Payment not found: {0}" ) ]
270294 PaymentNotFound ( String ) ,
271295
@@ -467,6 +491,8 @@ impl IntoResponse for APIError {
467491 | APIError :: InvalidOnionData ( _)
468492 | APIError :: InvalidPassword ( _)
469493 | APIError :: InvalidPaymentHash ( _)
494+ | APIError :: PaymentHashAlreadyUsed
495+ | APIError :: InvalidPaymentPreimage
470496 | APIError :: InvalidPaymentSecret
471497 | APIError :: InvalidPeerInfo ( _)
472498 | APIError :: InvalidPrecision ( _)
@@ -482,10 +508,12 @@ impl IntoResponse for APIError {
482508 | APIError :: InvalidTlvType ( _)
483509 | APIError :: InvalidTransportEndpoint ( _)
484510 | APIError :: InvalidTransportEndpoints ( _)
511+ | APIError :: InvoiceExpired
485512 | APIError :: MediaFileEmpty
486513 | APIError :: MediaFileNotProvided
487514 | APIError :: MissingSwapPaymentPreimage
488515 | APIError :: OutputBelowDustLimit
516+ | APIError :: ClaimDeadlineExceeded
489517 | APIError :: UnsupportedBackupVersion { .. } => {
490518 ( StatusCode :: BAD_REQUEST , self . to_string ( ) , self . name ( ) )
491519 }
@@ -510,6 +538,8 @@ impl IntoResponse for APIError {
510538 | APIError :: InvalidIndexer ( _)
511539 | APIError :: InvalidProxyEndpoint
512540 | APIError :: InvalidProxyProtocol ( _)
541+ | APIError :: InvoiceNotHodl
542+ | APIError :: InvoiceSettlingInProgress
513543 | APIError :: LockedNode
514544 | APIError :: MaxFeeExceeded ( _)
515545 | APIError :: MinFeeNotMet ( _)
@@ -532,6 +562,10 @@ impl IntoResponse for APIError {
532562 | APIError :: UnsupportedTransportType => {
533563 ( StatusCode :: FORBIDDEN , self . to_string ( ) , self . name ( ) )
534564 }
565+ APIError :: InvoiceAlreadyClaimed => {
566+ ( StatusCode :: CONFLICT , self . to_string ( ) , self . name ( ) )
567+ }
568+ APIError :: InvoiceNotClaimable => ( StatusCode :: NOT_FOUND , self . to_string ( ) , self . name ( ) ) ,
535569 APIError :: Network ( _) | APIError :: NoValidTransportEndpoint => (
536570 StatusCode :: SERVICE_UNAVAILABLE ,
537571 self . to_string ( ) ,
0 commit comments