Пример #1
0
def cancel_hw_operation(hw_client):
    try:
        hw_type = get_hw_type(hw_client)
        if hw_type in (HWType.trezor, HWType.keepkey):
            hw_client.cancel()
    except Exception as e:
        logging.error('Error when cancelling hw operation: %s', str(e))
Пример #2
0
def get_hw_label(hw_client):
    hw_type = get_hw_type(hw_client)
    if hw_type == HWType.trezor:
        return 'Trezor (' + hw_client.features.label + ')'
    elif hw_type == HWType.keepkey:
        return 'KeepKey (' + hw_client.features.label + ')'
    elif hw_type == HWType.ledger_nano_s:
        return 'Ledger Nano S'
Пример #3
0
def disconnect_hw(hw_client):
    try:
        hw_type = get_hw_type(hw_client)
        if hw_type in (HWType.trezor, HWType.keepkey):
            hw_client.close()
        elif hw_type == HWType.ledger_nano_s:
            hw_client.dongle.close()
    except Exception as e:
        # probably already disconnected
        logging.exception('Disconnect HW error')
Пример #4
0
def get_hw_firmware_version(hw_session: HwSessionInfo):
    hw_type = get_hw_type(hw_session.hw_client)
    if hw_type in (HWType.trezor, HWType.keepkey):

        return str(hw_session.hw_client.features.major_version) + '.' + \
               str(hw_session.hw_client.features.minor_version) + '.' + \
               str(hw_session.hw_client.features.patch_version)

    elif hw_type == HWType.ledger_nano_s:

        return hw_session.hw_client.getFirmwareVersion().get('version')
Пример #5
0
def cancel_hw_thread_dialog(hw_client):
    try:
        hw_type = get_hw_type(hw_client)
        if hw_type == HWType.trezor:
            hw_client.cancel()
        elif hw_type == HWType.keepkey:
            hw_client.cancel()
        elif hw_type == HWType.ledger_nano_s:
            return False
        raise CancelException('Cancel')
    except CancelException:
        raise
    except Exception as e:
        logging.warning('Error when canceling hw session. Details: %s', str(e))
        return True
Пример #6
0
def get_hw_label(hw_client):
    hw_type = get_hw_type(hw_client)
    if hw_type in (HWType.trezor, HWType.keepkey):
        return hw_client.features.label
    elif hw_type == HWType.ledger_nano_s:
        return 'Ledger Nano S'
Пример #7
0
def cancel_hw_operation(hw_client):
    hw_type = get_hw_type(hw_client)
    if hw_type in (HWType.trezor, HWType.keepkey):
        hw_client.cancel()