@@ -161,6 +161,9 @@ pub enum APIError {
161161 #[ error( "Invalid payment hash: {0}" ) ]
162162 InvalidPaymentHash ( String ) ,
163163
164+ #[ error( "Invalid payment preimage" ) ]
165+ InvalidPaymentPreimage ,
166+
164167 #[ error( "Invalid payment secret" ) ]
165168 InvalidPaymentSecret ,
166169
@@ -212,6 +215,24 @@ pub enum APIError {
212215 #[ error( "Invalid transport endpoints: {0}" ) ]
213216 InvalidTransportEndpoints ( String ) ,
214217
218+ #[ error( "HTLC claim deadline exceeded" ) ]
219+ ClaimDeadlineExceeded ,
220+
221+ #[ error( "Invoice is already settled" ) ]
222+ InvoiceAlreadySettled ,
223+
224+ #[ error( "Invoice is expired" ) ]
225+ InvoiceExpired ,
226+
227+ #[ error( "No claimable HTLC found for this invoice" ) ]
228+ InvoiceNotClaimable ,
229+
230+ #[ error( "Invoice is not marked as HODL" ) ]
231+ InvoiceNotHodl ,
232+
233+ #[ error( "Invoice settlement is in progress" ) ]
234+ InvoiceSettlingInProgress ,
235+
215236 #[ error( "IO error: {0}" ) ]
216237 IO ( #[ from] std:: io:: Error ) ,
217238
@@ -257,6 +278,9 @@ pub enum APIError {
257278 #[ error( "Output below the dust limit" ) ]
258279 OutputBelowDustLimit ,
259280
281+ #[ error( "Payment hash already used" ) ]
282+ PaymentHashAlreadyUsed ,
283+
260284 #[ error( "Payment not found: {0}" ) ]
261285 PaymentNotFound ( String ) ,
262286
@@ -443,6 +467,8 @@ impl IntoResponse for APIError {
443467 | APIError :: InvalidOnionData ( _)
444468 | APIError :: InvalidPassword ( _)
445469 | APIError :: InvalidPaymentHash ( _)
470+ | APIError :: PaymentHashAlreadyUsed
471+ | APIError :: InvalidPaymentPreimage
446472 | APIError :: InvalidPaymentSecret
447473 | APIError :: InvalidPeerInfo ( _)
448474 | APIError :: InvalidPrecision ( _)
@@ -457,10 +483,12 @@ impl IntoResponse for APIError {
457483 | APIError :: InvalidTlvType ( _)
458484 | APIError :: InvalidTransportEndpoint ( _)
459485 | APIError :: InvalidTransportEndpoints ( _)
486+ | APIError :: InvoiceExpired
460487 | APIError :: MediaFileEmpty
461488 | APIError :: MediaFileNotProvided
462489 | APIError :: MissingSwapPaymentPreimage
463490 | APIError :: OutputBelowDustLimit
491+ | APIError :: ClaimDeadlineExceeded
464492 | APIError :: UnsupportedBackupVersion { .. } => {
465493 ( StatusCode :: BAD_REQUEST , self . to_string ( ) , self . name ( ) )
466494 }
@@ -485,6 +513,8 @@ impl IntoResponse for APIError {
485513 | APIError :: InvalidIndexer ( _)
486514 | APIError :: InvalidProxyEndpoint
487515 | APIError :: InvalidProxyProtocol ( _)
516+ | APIError :: InvoiceNotHodl
517+ | APIError :: InvoiceSettlingInProgress
488518 | APIError :: LockedNode
489519 | APIError :: MaxFeeExceeded ( _)
490520 | APIError :: MinFeeNotMet ( _)
@@ -506,6 +536,10 @@ impl IntoResponse for APIError {
506536 | APIError :: UnsupportedTransportType => {
507537 ( StatusCode :: FORBIDDEN , self . to_string ( ) , self . name ( ) )
508538 }
539+ APIError :: InvoiceAlreadySettled => {
540+ ( StatusCode :: CONFLICT , self . to_string ( ) , self . name ( ) )
541+ }
542+ APIError :: InvoiceNotClaimable => ( StatusCode :: NOT_FOUND , self . to_string ( ) , self . name ( ) ) ,
509543 APIError :: Network ( _) | APIError :: NoValidTransportEndpoint => (
510544 StatusCode :: SERVICE_UNAVAILABLE ,
511545 self . to_string ( ) ,
0 commit comments