mirror of
https://github.com/aljazceru/nutshell.git
synced 2025-12-21 19:14:19 +01:00
* add websockets for quote updates * add test (not working) * wip: emit events to everyone * wip: emit events to everyone * wip, lots of things broken but invoice callback works * wip * add wip files * tests almost passing * add task * refactor nut constants * startup fix * works with old mints * wip cli * fix mypy * remove automatic invoice test now with websockets * remove comment * better logging * send back response * add rate limiter to websocket * add rate limiter to subscriptions * refactor websocket ratelimit * websocket tests * subscription kinds * doesnt start * remove circular import * update * fix mypy * move test file in test because it fails if it runs later... dunno why * adjust websocket NUT-06 settings * local import and small fix * disable websockets in CLI if "no_check" is selected * move subscription test to where it was * check proof state with callback, add tests * tests: run mint fixture per module instead of per session * subscription command name fix * test per session again * update test race conditions * fix tests * clean up * tmp * fix db issues and remove cached secrets * fix tests * blindly try pipeline * remove comments * comments
87 lines
1.6 KiB
Python
87 lines
1.6 KiB
Python
from enum import Enum
|
|
from typing import List
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
from ..settings import settings
|
|
|
|
|
|
class JSONRPCRequest(BaseModel):
|
|
jsonrpc: str = "2.0"
|
|
id: int
|
|
method: str
|
|
params: dict
|
|
|
|
|
|
class JSONRPCResponse(BaseModel):
|
|
jsonrpc: str = "2.0"
|
|
result: dict
|
|
id: int
|
|
|
|
|
|
class JSONRPCNotification(BaseModel):
|
|
jsonrpc: str = "2.0"
|
|
method: str
|
|
params: dict
|
|
|
|
|
|
class JSONRPCErrorCode(Enum):
|
|
PARSE_ERROR = -32700
|
|
INVALID_REQUEST = -32600
|
|
METHOD_NOT_FOUND = -32601
|
|
INVALID_PARAMS = -32602
|
|
INTERNAL_ERROR = -32603
|
|
SERVER_ERROR = -32000
|
|
APPLICATION_ERROR = -32099
|
|
SYSTEM_ERROR = -32098
|
|
TRANSPORT_ERROR = -32097
|
|
|
|
|
|
class JSONRPCError(BaseModel):
|
|
code: JSONRPCErrorCode
|
|
message: str
|
|
|
|
|
|
class JSONRPCErrorResponse(BaseModel):
|
|
jsonrpc: str = "2.0"
|
|
error: JSONRPCError
|
|
id: int
|
|
|
|
|
|
# Cashu Websocket protocol
|
|
|
|
|
|
class JSONRPCMethods(Enum):
|
|
SUBSCRIBE = "subscribe"
|
|
UNSUBSCRIBE = "unsubscribe"
|
|
|
|
|
|
class JSONRPCSubscriptionKinds(Enum):
|
|
BOLT11_MINT_QUOTE = "bolt11_mint_quote"
|
|
BOLT11_MELT_QUOTE = "bolt11_melt_quote"
|
|
PROOF_STATE = "proof_state"
|
|
|
|
|
|
class JSONRPCStatus(Enum):
|
|
OK = "OK"
|
|
|
|
|
|
class JSONRPCSubscribeParams(BaseModel):
|
|
kind: JSONRPCSubscriptionKinds
|
|
filters: List[str] = Field(..., max_length=settings.mint_max_request_length)
|
|
subId: str
|
|
|
|
|
|
class JSONRPCUnsubscribeParams(BaseModel):
|
|
subId: str
|
|
|
|
|
|
class JSONRPCNotficationParams(BaseModel):
|
|
subId: str
|
|
payload: dict
|
|
|
|
|
|
class JSONRRPCSubscribeResponse(BaseModel):
|
|
status: JSONRPCStatus
|
|
subId: str
|