mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-20 10:34:20 +01:00
* nut-19 sign mint quote * ephemeral key for quote * `mint` adjustments + crypto/nut19.py * wip: mint side working * fix import * post-merge fixups * more fixes * make format * move nut19 to nuts directory * `key` -> `privkey` and `pubkey` * make format * mint_info method for nut-19 support * fix tests imports * fix signature missing positional argument + fix db migration format not correctly escaped + pass in NUT-19 keypair to `request_mint` `request_mint_with_callback` * make format * fix `get_invoice_status` * rename to xx * nutxx -> nut20 * mypy * remove `mint_quote_signature_required` as per spec * wip edits * clean up * fix tests * fix deprecated api tests * fix redis tests * fix cache tests * fix regtest mint external * fix mint regtest * add test without signature * test pubkeys in quotes * wip * add compat --------- Co-authored-by: callebtc <93376500+callebtc@users.noreply.github.com>
115 lines
2.7 KiB
Python
115 lines
2.7 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 TransactionNotBalancedError(TransactionError):
|
|
code = 11002
|
|
|
|
def __init__(self, detail):
|
|
super().__init__(detail, code=self.code)
|
|
|
|
|
|
class SecretTooLongError(TransactionError):
|
|
code = 11003
|
|
|
|
def __init__(self, detail="secret too long"):
|
|
super().__init__(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 TransactionUnitError(TransactionError):
|
|
code = 11005
|
|
|
|
def __init__(self, detail):
|
|
super().__init__(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)
|
|
|
|
|
|
class QuoteSignatureInvalidError(CashuError):
|
|
detail = "Signature for mint request invalid"
|
|
code = 20008
|
|
|
|
def __init__(self):
|
|
super().__init__(self.detail, code=20008)
|
|
|
|
|
|
class QuoteRequiresPubkeyError(CashuError):
|
|
detail = "Pubkey required for mint quote"
|
|
code = 20009
|
|
|
|
def __init__(self):
|
|
super().__init__(self.detail, code=20009)
|