mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-20 10:34:20 +01:00
* wip works with fakewallet * startup refactor * add tests * regtest tests for pending melts * wip CLN * remove db migration * remove foreign key relation to keyset id * fix: get_promise from db and restore DLEQs * test: check for keyset not found error * fix migrations * lower-case all db column names * add more tests for regtest * simlate failure for lightning * test wallet spent state with hodl invoices * retry * regtest with postgres * retry postgres * add sleeps * longer sleep on github * more sleep for github sigh * increase sleep ffs * add sleep loop * try something * do not pay with wallet but with ledger * fix lnbits pending state * fix pipeline to use fake admin from docker
86 lines
2.1 KiB
Python
86 lines
2.1 KiB
Python
from typing import Optional
|
|
|
|
|
|
class CashuError(Exception):
|
|
code: int
|
|
detail: str
|
|
|
|
def __init__(self, detail, code=0):
|
|
super().__init__(detail)
|
|
self.code = code
|
|
self.detail = detail
|
|
|
|
|
|
class NotAllowedError(CashuError):
|
|
detail = "not allowed"
|
|
code = 10000
|
|
|
|
def __init__(self, detail: Optional[str] = None, code: Optional[int] = None):
|
|
super().__init__(detail or self.detail, code=code or self.code)
|
|
|
|
|
|
class TransactionError(CashuError):
|
|
detail = "transaction error"
|
|
code = 11000
|
|
|
|
def __init__(self, detail: Optional[str] = None, code: Optional[int] = None):
|
|
super().__init__(detail or self.detail, code=code or self.code)
|
|
|
|
|
|
class TokenAlreadySpentError(TransactionError):
|
|
detail = "Token already spent."
|
|
code = 11001
|
|
|
|
def __init__(self):
|
|
super().__init__(self.detail, code=self.code)
|
|
|
|
|
|
class SecretTooLongError(TransactionError):
|
|
detail = "secret too long"
|
|
code = 11003
|
|
|
|
def __init__(self):
|
|
super().__init__(self.detail, code=self.code)
|
|
|
|
|
|
class NoSecretInProofsError(TransactionError):
|
|
detail = "no secret in proofs"
|
|
code = 11004
|
|
|
|
def __init__(self):
|
|
super().__init__(self.detail, code=self.code)
|
|
|
|
|
|
class KeysetError(CashuError):
|
|
detail = "keyset error"
|
|
code = 12000
|
|
|
|
def __init__(self, detail: Optional[str] = None, code: Optional[int] = None):
|
|
super().__init__(detail or self.detail, code=code or self.code)
|
|
|
|
|
|
class KeysetNotFoundError(KeysetError):
|
|
detail = "keyset not found"
|
|
code = 12001
|
|
|
|
def __init__(self, keyset_id: Optional[str] = None):
|
|
if keyset_id:
|
|
self.detail = f"{self.detail}: {keyset_id}"
|
|
super().__init__(self.detail, code=self.code)
|
|
|
|
|
|
class LightningError(CashuError):
|
|
detail = "Lightning error"
|
|
code = 20000
|
|
|
|
def __init__(self, detail: Optional[str] = None, code: Optional[int] = None):
|
|
super().__init__(detail or self.detail, code=code or self.code)
|
|
|
|
|
|
class QuoteNotPaidError(CashuError):
|
|
detail = "quote not paid"
|
|
code = 20001
|
|
|
|
def __init__(self):
|
|
super().__init__(self.detail, code=2001)
|