Created
April 11, 2020 20:21
-
-
Save justinmoon/b1bb409fa294d71c5e6a7dfaa6f92092 to your computer and use it in GitHub Desktop.
hwi & bitcoin rpc errors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { RPC_ERRORS, HWI_ERRORS } from "@app/constants" | |
| const bitcoinRpcErrorCodeToConstant = { | |
| "-32600": RPC_ERRORS.INVALID_REQUEST, | |
| "-32601": RPC_ERRORS.METHOD_NOT_FOUND, | |
| "-32602": RPC_ERRORS.INVALID_PARAMS, | |
| "-32603": RPC_ERRORS.INTERNAL_ERROR, | |
| "-32700": RPC_ERRORS.PARSE_ERROR, | |
| "-1": RPC_ERRORS.MISC_ERROR, | |
| "-3": RPC_ERRORS.TYPE_ERROR, | |
| "-5": RPC_ERRORS.INVALID_ADDRESS_OR_KEY, | |
| "-7": RPC_ERRORS.OUT_OF_MEMORY, | |
| "-8": RPC_ERRORS.INVALID_PARAMETER, | |
| "-20": RPC_ERRORS.DATABASE_ERROR, | |
| "-22": RPC_ERRORS.DESERIALIZATION_ERROR, | |
| "-25": RPC_ERRORS.VERIFY_ERROR, | |
| "-26": RPC_ERRORS.VERIFY_REJECTED, | |
| "-27": RPC_ERRORS.VERIFY_ALREADY_IN_CHAIN, | |
| "-28": RPC_ERRORS.IN_WARMUP, | |
| "-32": RPC_ERRORS.METHOD_DEPRECATED, | |
| "-9": RPC_ERRORS.CLIENT_NOT_CONNECTED, | |
| "-10": RPC_ERRORS.CLIENT_IN_INITIAL_BLOCK_DOWNLOAD, | |
| "-23": RPC_ERRORS.CLIENT_NODE_ALREADY_ADDED, | |
| "-24": RPC_ERRORS.CLIENT_NODE_NOT_ADDED, | |
| "-29": RPC_ERRORS.CLIENT_NODE_NOT_CONNECTED, | |
| "-30": RPC_ERRORS.CLIENT_INVALID_IP_OR_SUBNET, | |
| "-31": RPC_ERRORS.CLIENT_P2P_DISABLED, | |
| "-33": RPC_ERRORS.CLIENT_MEMPOOL_DISABLED, | |
| "-4": RPC_ERRORS.WALLET_ERROR, | |
| "-6": RPC_ERRORS.WALLET_INSUFFICIENT_FUNDS, | |
| "-11": RPC_ERRORS.WALLET_INVALID_LABEL_NAME, | |
| "-12": RPC_ERRORS.WALLET_KEYPOOL_RAN_OUT, | |
| "-13": RPC_ERRORS.WALLET_UNLOCK_NEEDED, | |
| "-14": RPC_ERRORS.WALLET_PASSPHRASE_INCORRECT, | |
| "-15": RPC_ERRORS.WALLET_WRONG_ENC_STATE, | |
| "-16": RPC_ERRORS.WALLET_ENCRYPTION_FAILED, | |
| "-17": RPC_ERRORS.WALLET_ALREADY_UNLOCKED, | |
| "-18": RPC_ERRORS.WALLET_NOT_FOUND, | |
| "-19": RPC_ERRORS.WALLET_NOT_SPECIFIED, | |
| } | |
| export function diagnoseRpcError(errorCodeNumber) { | |
| return bitcoinRpcErrorCodeToConstant[errorCodeNumber] | |
| } | |
| const hwiErrorCodeToConstant = { | |
| "-1": HWI_ERRORS.NO_DEVICE_TYPE, | |
| "-2": HWI_ERRORS.MISSING_ARGUMENTS, | |
| "-3": HWI_ERRORS.DEVICE_CONN_ERROR, | |
| "-4": HWI_ERRORS.UNKNOWN_DEVICE_TYPE, | |
| "-5": HWI_ERRORS.INVALID_TX, | |
| "-6": HWI_ERRORS.NO_PASSWORD, | |
| "-7": HWI_ERRORS.BAD_ARGUMENT, | |
| "-8": HWI_ERRORS.NOT_IMPLEMENTED, | |
| "-9": HWI_ERRORS.UNAVAILABLE_ACTION, | |
| "-10": HWI_ERRORS.DEVICE_ALREADY_INIT, | |
| "-11": HWI_ERRORS.DEVICE_ALREADY_UNLOCKED, | |
| "-12": HWI_ERRORS.DEVICE_NOT_READY, | |
| "-13": HWI_ERRORS.UNKNOWN_ERROR, | |
| "-14": HWI_ERRORS.ACTION_CANCELED, | |
| "-15": HWI_ERRORS.DEVICE_BUSY, | |
| "-16": HWI_ERRORS.NEED_TO_BE_ROOT, | |
| "-17": HWI_ERRORS.HELP_TEXT, | |
| "-18": HWI_ERRORS.DEVICE_NOT_INITIALIZED, | |
| } | |
| export function diagnoseHwiError(errorCodeNumber) { | |
| return hwiErrorCodeToConstant[errorCodeNumber] | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment