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