consolidate errors to errors.py
This commit is contained in:
parent
0d88d07638
commit
32e56c7b58
@ -2,8 +2,13 @@
|
||||
|
||||
from .commands import backup_device, displayaddress, enumerate, find_device, \
|
||||
get_client, getmasterxpub, getxpub, getkeypool, prompt_pin, restore_device, send_pin, setup_device, \
|
||||
signmessage, signtx, wipe_device, NO_DEVICE_PATH, DEVICE_CONN_ERROR, NO_PASSWORD, \
|
||||
signmessage, signtx, wipe_device
|
||||
from .errors import (
|
||||
NO_DEVICE_PATH,
|
||||
DEVICE_CONN_ERROR,
|
||||
NO_PASSWORD,
|
||||
UNKNWON_DEVICE_TYPE
|
||||
)
|
||||
|
||||
import argparse
|
||||
import getpass
|
||||
|
||||
@ -8,24 +8,7 @@ import importlib
|
||||
from .serializations import PSBT, Base64ToHex, HexToBase64, hash160
|
||||
from .base58 import xpub_to_address, xpub_to_pub_hex, get_xpub_fingerprint_as_id, get_xpub_fingerprint_hex
|
||||
from os.path import dirname, basename, isfile
|
||||
from .hwwclient import NoPasswordError, UnavailableActionError, DeviceAlreadyInitError, DeviceAlreadyUnlockedError
|
||||
|
||||
# Error codes
|
||||
NO_DEVICE_PATH = -1
|
||||
NO_DEVICE_TYPE = -2
|
||||
DEVICE_CONN_ERROR = -3
|
||||
UNKNWON_DEVICE_TYPE = -4
|
||||
INVALID_TX = -5
|
||||
NO_PASSWORD = -6
|
||||
BAD_ARGUMENT = -7
|
||||
NOT_IMPLEMENTED = -8
|
||||
UNAVAILABLE_ACTION = -9
|
||||
DEVICE_ALREADY_INIT = -10
|
||||
DEVICE_ALREADY_UNLOCKED = -11
|
||||
|
||||
class UnknownDeviceError(Exception):
|
||||
def __init__(self,*args,**kwargs):
|
||||
Exception.__init__(self,*args,**kwargs)
|
||||
from .errors import NoPasswordError, UnavailableActionError, DeviceAlreadyInitError, DeviceAlreadyUnlockedError, UnknownDeviceError, BAD_ARGUMENT, NOT_IMPLEMENTED
|
||||
|
||||
# Get the client for the device
|
||||
def get_client(device_type, device_path, password=''):
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# Coldcard interaction script
|
||||
|
||||
from ..hwwclient import HardwareWalletClient, UnavailableActionError
|
||||
from ..hwwclient import HardwareWalletClient
|
||||
from ..errors import UnavailableActionError
|
||||
from ckcc.client import ColdcardDevice, COINKITE_VID, CKCC_PID
|
||||
from ckcc.protocol import CCProtocolPacker, CCProtoError
|
||||
from ckcc.constants import MAX_BLK_LEN, AF_P2WPKH, AF_CLASSIC, AF_P2WPKH_P2SH
|
||||
|
||||
@ -14,7 +14,8 @@ import socket
|
||||
import sys
|
||||
import time
|
||||
|
||||
from ..hwwclient import HardwareWalletClient, NoPasswordError, UnavailableActionError
|
||||
from ..hwwclient import HardwareWalletClient
|
||||
from ..errors import NoPasswordError, UnavailableActionError
|
||||
from ..serializations import CTransaction, PSBT, hash256, hash160, ser_sig_der, ser_sig_compact, ser_compact_size
|
||||
from ..base58 import get_xpub_fingerprint, decode, to_address, xpub_main_2_test, get_xpub_fingerprint_hex
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# KeepKey interaction script
|
||||
|
||||
from ..hwwclient import DeviceAlreadyUnlockedError, HardwareWalletClient, UnavailableActionError, DeviceNotReadyError
|
||||
from ..hwwclient import HardwareWalletClient
|
||||
from ..errors import DeviceAlreadyUnlockedError, UnavailableActionError, DeviceNotReadyError
|
||||
from keepkeylib.transport_hid import HidTransport
|
||||
from keepkeylib.transport_udp import UDPTransport
|
||||
from keepkeylib.client import BaseClient, DebugWireMixin, DebugLinkMixin, ProtocolMixin, TextUIMixin
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# Ledger interaction script
|
||||
|
||||
from ..hwwclient import HardwareWalletClient, UnavailableActionError
|
||||
from ..hwwclient import HardwareWalletClient
|
||||
from ..errors import UnavailableActionError
|
||||
from btchip.btchip import *
|
||||
from btchip.btchipUtils import *
|
||||
import base64
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# Trezor interaction script
|
||||
|
||||
from ..hwwclient import HardwareWalletClient, DeviceAlreadyInitError, DeviceAlreadyUnlockedError, UnavailableActionError, DeviceNotReadyError
|
||||
from ..hwwclient import HardwareWalletClient
|
||||
from ..errors import DeviceAlreadyInitError, DeviceAlreadyUnlockedError, UnavailableActionError, DeviceNotReadyError
|
||||
from trezorlib.client import TrezorClient as Trezor
|
||||
from trezorlib.debuglink import TrezorClientDebugLink
|
||||
from trezorlib.transport import enumerate_devices, get_transport
|
||||
|
||||
39
hwilib/errors.py
Normal file
39
hwilib/errors.py
Normal file
@ -0,0 +1,39 @@
|
||||
# Defines errors and error codes
|
||||
|
||||
# Error codes
|
||||
NO_DEVICE_PATH = -1
|
||||
NO_DEVICE_TYPE = -2
|
||||
DEVICE_CONN_ERROR = -3
|
||||
UNKNWON_DEVICE_TYPE = -4
|
||||
INVALID_TX = -5
|
||||
NO_PASSWORD = -6
|
||||
BAD_ARGUMENT = -7
|
||||
NOT_IMPLEMENTED = -8
|
||||
UNAVAILABLE_ACTION = -9
|
||||
DEVICE_ALREADY_INIT = -10
|
||||
DEVICE_ALREADY_UNLOCKED = -11
|
||||
|
||||
# Exceptions
|
||||
class NoPasswordError(Exception):
|
||||
def __init__(self,*args,**kwargs):
|
||||
Exception.__init__(self,*args,**kwargs)
|
||||
|
||||
class UnavailableActionError(Exception):
|
||||
def __init__(self,*args,**kwargs):
|
||||
Exception.__init__(self,*args,**kwargs)
|
||||
|
||||
class DeviceAlreadyInitError(Exception):
|
||||
def __init__(self,*args,**kwargs):
|
||||
Exception.__init__(self,*args,**kwargs)
|
||||
|
||||
class DeviceNotReadyError(Exception):
|
||||
def __init__(self,*args,**kwargs):
|
||||
Exception.__init__(self,*args,**kwargs)
|
||||
|
||||
class DeviceAlreadyUnlockedError(Exception):
|
||||
def __init__(self,*args,**kwargs):
|
||||
Exception.__init__(self,*args,**kwargs)
|
||||
|
||||
class UnknownDeviceError(Exception):
|
||||
def __init__(self,*args,**kwargs):
|
||||
Exception.__init__(self,*args,**kwargs)
|
||||
@ -61,23 +61,3 @@ class HardwareWalletClient(object):
|
||||
# Send pin
|
||||
def send_pin(self):
|
||||
raise NotImplementedError('The HardwareWalletClient base class does not implement this method')
|
||||
|
||||
class NoPasswordError(Exception):
|
||||
def __init__(self,*args,**kwargs):
|
||||
Exception.__init__(self,*args,**kwargs)
|
||||
|
||||
class UnavailableActionError(Exception):
|
||||
def __init__(self,*args,**kwargs):
|
||||
Exception.__init__(self,*args,**kwargs)
|
||||
|
||||
class DeviceAlreadyInitError(Exception):
|
||||
def __init__(self,*args,**kwargs):
|
||||
Exception.__init__(self,*args,**kwargs)
|
||||
|
||||
class DeviceNotReadyError(Exception):
|
||||
def __init__(self,*args,**kwargs):
|
||||
Exception.__init__(self,*args,**kwargs)
|
||||
|
||||
class DeviceAlreadyUnlockedError(Exception):
|
||||
def __init__(self,*args,**kwargs):
|
||||
Exception.__init__(self,*args,**kwargs)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user