obelisk

Electrum server using libbitcoin as its backend
git clone https://git.parazyd.org/obelisk
Log | Files | Refs | README | LICENSE

errors_jsonrpc.py (1704B)


      1 #!/usr/bin/env python3
      2 # Copyright (C) 2021 Ivan J. <parazyd@dyne.org>
      3 #
      4 # This file is part of obelisk
      5 #
      6 # This program is free software: you can redistribute it and/or modify
      7 # it under the terms of the GNU Affero General Public License version 3
      8 # as published by the Free Software Foundation.
      9 #
     10 # This program is distributed in the hope that it will be useful,
     11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
     12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     13 # GNU Affero General Public License for more details.
     14 #
     15 # You should have received a copy of the GNU Affero General Public License
     16 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
     17 """JSON-RPC errors: https://www.jsonrpc.org/specification#error_object"""
     18 
     19 
     20 class JsonRPCError:  # pragma: no cover
     21     """Class implementing functions returning JSON-RPC errors"""
     22 
     23     def __init__(self):
     24         return
     25 
     26     @staticmethod
     27     def invalidrequest():
     28         return {"error": {"code": -32600, "message": "invalid request"}}
     29 
     30     @staticmethod
     31     def methodnotfound():
     32         return {"error": {"code": -32601, "message": "method not found"}}
     33 
     34     @staticmethod
     35     def invalidparams():
     36         return {"error": {"code": -32602, "message": "invalid parameters"}}
     37 
     38     @staticmethod
     39     def internalerror():
     40         return {"error": {"code": -32603, "message": "internal error"}}
     41 
     42     @staticmethod
     43     def parseerror():
     44         return {"error": {"code": -37200, "message": "parse error"}}
     45 
     46     @staticmethod
     47     def protonotsupported():
     48         return {
     49             "error": {
     50                 "code": -32100,
     51                 "message": "protocol version unsupported",
     52             }
     53         }