github.com/btcsuite/btcd@v0.24.0/btcjson/jsonrpcerr.go (about)

     1  // Copyright (c) 2014 The btcsuite developers
     2  // Use of this source code is governed by an ISC
     3  // license that can be found in the LICENSE file.
     4  
     5  package btcjson
     6  
     7  // Standard JSON-RPC 2.0 errors.
     8  var (
     9  	ErrRPCInvalidRequest = &RPCError{
    10  		Code:    -32600,
    11  		Message: "Invalid request",
    12  	}
    13  	ErrRPCMethodNotFound = &RPCError{
    14  		Code:    -32601,
    15  		Message: "Method not found",
    16  	}
    17  	ErrRPCInvalidParams = &RPCError{
    18  		Code:    -32602,
    19  		Message: "Invalid parameters",
    20  	}
    21  	ErrRPCInternal = &RPCError{
    22  		Code:    -32603,
    23  		Message: "Internal error",
    24  	}
    25  	ErrRPCParse = &RPCError{
    26  		Code:    -32700,
    27  		Message: "Parse error",
    28  	}
    29  )
    30  
    31  // General application defined JSON errors.
    32  const (
    33  	// ErrRPCMisc indicates an exception thrown during command handling.
    34  	ErrRPCMisc RPCErrorCode = -1
    35  
    36  	// ErrRPCForbiddenBySafeMode indicates that server is in safe mode, and
    37  	// command is not allowed in safe mode.
    38  	ErrRPCForbiddenBySafeMode RPCErrorCode = -2
    39  
    40  	// ErrRPCType indicates that an unexpected type was passed as parameter.
    41  	ErrRPCType RPCErrorCode = -3
    42  
    43  	// ErrRPCInvalidAddressOrKey indicates an invalid address or key.
    44  	ErrRPCInvalidAddressOrKey RPCErrorCode = -5
    45  
    46  	// ErrRPCOutOfMemory indicates that the server ran out of memory during
    47  	// operation.
    48  	ErrRPCOutOfMemory RPCErrorCode = -7
    49  
    50  	// ErrRPCInvalidParameter indicates an invalid, missing, or duplicate
    51  	// parameter.
    52  	ErrRPCInvalidParameter RPCErrorCode = -8
    53  
    54  	// ErrRPCDatabase indicates a database error.
    55  	ErrRPCDatabase RPCErrorCode = -20
    56  
    57  	// ErrRPCDeserialization indicates an error parsing or validating structure
    58  	// in raw format.
    59  	ErrRPCDeserialization RPCErrorCode = -22
    60  
    61  	// ErrRPCVerify indicates a general error during transaction or block
    62  	// submission.
    63  	ErrRPCVerify RPCErrorCode = -25
    64  
    65  	// ErrRPCVerifyRejected indicates that transaction or block was rejected by
    66  	// network rules.
    67  	ErrRPCVerifyRejected RPCErrorCode = -26
    68  
    69  	// ErrRPCVerifyAlreadyInChain indicates that submitted transaction is
    70  	// already in chain.
    71  	ErrRPCVerifyAlreadyInChain RPCErrorCode = -27
    72  
    73  	// ErrRPCInWarmup indicates that client is still warming up.
    74  	ErrRPCInWarmup RPCErrorCode = -28
    75  
    76  	// ErrRPCInWarmup indicates that the RPC error is deprecated.
    77  	ErrRPCMethodDeprecated RPCErrorCode = -32
    78  )
    79  
    80  // Peer-to-peer client errors.
    81  const (
    82  	// ErrRPCClientNotConnected indicates that Bitcoin is not connected.
    83  	ErrRPCClientNotConnected RPCErrorCode = -9
    84  
    85  	// ErrRPCClientInInitialDownload indicates that client is still downloading
    86  	// initial blocks.
    87  	ErrRPCClientInInitialDownload RPCErrorCode = -10
    88  
    89  	// ErrRPCClientNodeAlreadyAdded indicates that node is already added.
    90  	ErrRPCClientNodeAlreadyAdded RPCErrorCode = -23
    91  
    92  	// ErrRPCClientNodeNotAdded indicates that node has not been added before.
    93  	ErrRPCClientNodeNotAdded RPCErrorCode = -24
    94  
    95  	// ErrRPCClientNodeNotConnected indicates that node to disconnect was not
    96  	// found in connected nodes.
    97  	ErrRPCClientNodeNotConnected RPCErrorCode = -29
    98  
    99  	// ErrRPCClientInvalidIPOrSubnet indicates an invalid IP/Subnet.
   100  	ErrRPCClientInvalidIPOrSubnet RPCErrorCode = -30
   101  
   102  	// ErrRPCClientP2PDisabled indicates that no valid connection manager
   103  	// instance was found.
   104  	ErrRPCClientP2PDisabled RPCErrorCode = -31
   105  )
   106  
   107  // Chain errors
   108  const (
   109  	// ErrRPCClientMempoolDisabled indicates that no mempool instance was
   110  	// found.
   111  	ErrRPCClientMempoolDisabled RPCErrorCode = -33
   112  )
   113  
   114  // Wallet JSON errors
   115  const (
   116  	// ErrRPCWallet indicates an unspecified problem with wallet, for
   117  	// example, key not found, etc.
   118  	ErrRPCWallet RPCErrorCode = -4
   119  
   120  	// ErrRPCWalletInvalidAddressType indicates an invalid address type.
   121  	ErrRPCWalletInvalidAddressType RPCErrorCode = -5
   122  
   123  	// ErrRPCWalletInsufficientFunds indicates that there are not enough
   124  	// funds in wallet or account.
   125  	ErrRPCWalletInsufficientFunds RPCErrorCode = -6
   126  
   127  	// ErrRPCWalletInvalidAccountName indicates an invalid label name.
   128  	ErrRPCWalletInvalidAccountName RPCErrorCode = -11
   129  
   130  	// ErrRPCWalletKeypoolRanOut indicates that the keypool ran out, and that
   131  	// keypoolrefill must be called first.
   132  	ErrRPCWalletKeypoolRanOut RPCErrorCode = -12
   133  
   134  	// ErrRPCWalletUnlockNeeded indicates that the wallet passphrase must be
   135  	// entered first with the walletpassphrase RPC.
   136  	ErrRPCWalletUnlockNeeded RPCErrorCode = -13
   137  
   138  	// ErrRPCWalletPassphraseIncorrect indicates that the wallet passphrase
   139  	// that was entered was incorrect.
   140  	ErrRPCWalletPassphraseIncorrect RPCErrorCode = -14
   141  
   142  	// ErrRPCWalletWrongEncState indicates that a command was given in wrong
   143  	// wallet encryption state, for example, encrypting an encrypted wallet.
   144  	ErrRPCWalletWrongEncState RPCErrorCode = -15
   145  
   146  	// ErrRPCWalletEncryptionFailed indicates a failure to encrypt the wallet.
   147  	ErrRPCWalletEncryptionFailed RPCErrorCode = -16
   148  
   149  	// ErrRPCWalletAlreadyUnlocked indicates an attempt to unlock a wallet
   150  	// that was already unlocked.
   151  	ErrRPCWalletAlreadyUnlocked RPCErrorCode = -17
   152  
   153  	// ErrRPCWalletNotFound indicates that an invalid wallet was specified,
   154  	// which does not exist. It can also indicate an attempt to unload a
   155  	// wallet that was not previously loaded.
   156  	//
   157  	// Not to be confused with ErrRPCNoWallet, which is specific to btcd.
   158  	ErrRPCWalletNotFound RPCErrorCode = -18
   159  
   160  	// ErrRPCWalletNotSpecified indicates that no wallet was specified, for
   161  	// example, when there are multiple wallets loaded.
   162  	ErrRPCWalletNotSpecified RPCErrorCode = -19
   163  )
   164  
   165  // Specific Errors related to commands.  These are the ones a user of the RPC
   166  // server are most likely to see.  Generally, the codes should match one of the
   167  // more general errors above.
   168  const (
   169  	ErrRPCBlockNotFound     RPCErrorCode = -5
   170  	ErrRPCBlockCount        RPCErrorCode = -5
   171  	ErrRPCBestBlockHash     RPCErrorCode = -5
   172  	ErrRPCDifficulty        RPCErrorCode = -5
   173  	ErrRPCOutOfRange        RPCErrorCode = -1
   174  	ErrRPCNoTxInfo          RPCErrorCode = -5
   175  	ErrRPCNoCFIndex         RPCErrorCode = -5
   176  	ErrRPCNoNewestBlockInfo RPCErrorCode = -5
   177  	ErrRPCInvalidTxVout     RPCErrorCode = -5
   178  	ErrRPCRawTxString       RPCErrorCode = -32602
   179  	ErrRPCDecodeHexString   RPCErrorCode = -22
   180  	ErrRPCTxError           RPCErrorCode = -25
   181  	ErrRPCTxRejected        RPCErrorCode = -26
   182  	ErrRPCTxAlreadyInChain  RPCErrorCode = -27
   183  )
   184  
   185  // Errors that are specific to btcd.
   186  const (
   187  	ErrRPCNoWallet      RPCErrorCode = -1
   188  	ErrRPCUnimplemented RPCErrorCode = -1
   189  )