当前位置: 首页>>代码示例>>Python>>正文


Python HidTransport.enumerate方法代码示例

本文整理汇总了Python中trezorlib.transport_hid.HidTransport.enumerate方法的典型用法代码示例。如果您正苦于以下问题:Python HidTransport.enumerate方法的具体用法?Python HidTransport.enumerate怎么用?Python HidTransport.enumerate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trezorlib.transport_hid.HidTransport的用法示例。


在下文中一共展示了HidTransport.enumerate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: wait_for_devices

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
def wait_for_devices():
    devices = HidTransport.enumerate()
    while not len(devices):
        sys.stderr.write("Please connect Trezor to computer and press Enter...")
        raw_input()
        devices = HidTransport.enumerate()

    return devices
开发者ID:aussiehash,项目名称:python-trezor,代码行数:10,代码来源:encfs_aes_getpass.py

示例2: main

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
def main():
    # List all connected TREZORs on USB
    devices = HidTransport.enumerate()

    # Check whether we found any
    if len(devices) == 0:
        print 'No TREZOR found'
        return

    # Use first connected device
    transport = HidTransport(devices[0])

    # Creates object for manipulating TREZOR
    client = TrezorClient(transport)

    # Print out TREZOR's features and settings
    print client.features

    # Get the first address of first BIP44 account
    # (should be the same address as shown in mytrezor.com)
    bip32_path = client.expand_path("44'/0'/0'/0/0")
    address = client.get_address('Bitcoin', bip32_path)
    print 'Bitcoin address:', address

    client.close()
开发者ID:EdwardBetts,项目名称:python-trezor,代码行数:27,代码来源:helloworld.py

示例3: get_client

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
    def get_client(self):
        if not TREZOR:
            give_error("please install github.com/trezor/python-trezor")

        if not self.client or self.client.bad:
            try:
                d = HidTransport.enumerate()[0]
                self.transport = HidTransport(d)
            except:
                give_error(
                    "Could not connect to your Trezor. Please verify the cable is connected and that no other app is using it."
                )
            self.client = QtGuiTrezorClient(self.transport)
            if (self.client.features.major_version == 1 and self.client.features.minor_version < 2) or (
                self.client.features.major_version == 1
                and self.client.features.minor_version == 2
                and self.client.features.patch_version < 1
            ):
                give_error("Outdated Trezor firmware. Please update the firmware from https://www.mytrezor.com")
            self.client.set_tx_api(self)
            # self.client.clear_session()# TODO Doesn't work with firmware 1.1, returns proto.Failure
            self.client.bad = False
            self.device_checked = False
            self.proper_device = False
        return self.client
开发者ID:azhar3339,项目名称:electrum,代码行数:27,代码来源:trezor.py

示例4: get_transport

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
def get_transport(transport_string, path, **kwargs):
    if transport_string == 'usb':
        from trezorlib.transport_hid import HidTransport

        if path == '':
            try:
                path = list_usb()[0][0]
            except IndexError:
                raise Exception("No Trezor found on USB")

        for d in HidTransport.enumerate():
            # Two-tuple of (normal_interface, debug_interface)
            if path in d:
                return HidTransport(d, **kwargs)

        raise Exception("Device not found")
 
    if transport_string == 'serial':
        from trezorlib.transport_serial import SerialTransport
        return SerialTransport(path, **kwargs)

    if transport_string == 'pipe':
        from trezorlib.transport_pipe import PipeTransport
        return PipeTransport(path, is_device=False, **kwargs)
    
    if transport_string == 'socket':
        from trezorlib.transport_socket import SocketTransportClient
        return SocketTransportClient(path, **kwargs)
    
    if transport_string == 'fake':
        from trezorlib.transport_fake import FakeTransport
        return FakeTransport(path, **kwargs)
    
    raise NotImplemented("Unknown transport")
开发者ID:cyberaa,项目名称:python-trezor,代码行数:36,代码来源:cmd.py

示例5: __init__

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
 def __init__(self, w3, index):
     self.w3 = w3
     self.client = TrezorClient(HidTransport.enumerate()[0])
     self.index = index
     self.address = self.w3.toChecksumAddress(
         "0x" + bytes(self.client.ethereum_get_address([44 + BIP32_HARDEN,
                                                        60 + BIP32_HARDEN,
                                                        BIP32_HARDEN, 0,
                                                        index])).hex())
开发者ID:arturgontijo,项目名称:snet-cli,代码行数:11,代码来源:identity.py

示例6: client

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
def client():
    # pylint: disable=import-error
    from trezorlib.client import TrezorClient
    from trezorlib.transport_hid import HidTransport
    from trezorlib.messages_pb2 import PassphraseAck

    devices = list(HidTransport.enumerate())
    if len(devices) != 1:
        msg = '{:d} Trezor devices found'.format(len(devices))
        raise IOError(msg)

    t = TrezorClient(HidTransport(devices[0]))
    t.callback_PassphraseRequest = lambda msg: PassphraseAck(passphrase='')
    return t
开发者ID:gitter-badger,项目名称:trezor-agent,代码行数:16,代码来源:_factory.py

示例7: get_client

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
    def get_client(self):
        if not TREZOR:
            raise Exception('please install github.com/trezor/python-trezor')

        if not self.client or self.client.bad:
            try:
                d = HidTransport.enumerate()[0]
                self.transport = HidTransport(d)
            except:
                raise Exception("Trezor not found")
            self.client = QtGuiTrezorClient(self.transport)
            self.client.set_tx_api(self)
            #self.client.clear_session()# TODO Doesn't work with firmware 1.1, returns proto.Failure
            self.client.bad = False
            self.device_checked = False
            self.proper_device = False
        return self.client
开发者ID:XertroV,项目名称:electrum3-lib,代码行数:19,代码来源:trezor.py

示例8: get_client

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
    def get_client(self):
        if not TREZOR:
            give_error('please install github.com/trezor/python-trezor')

        if not self.client or self.client.bad:
            try:
                d = HidTransport.enumerate()[0]
                self.transport = HidTransport(d)
            except:
                give_error('Could not connect to your Trezor. Please verify the cable is connected and that no other app is using it.')
            self.client = QtGuiTrezorClient(self.transport)
            self.client.set_tx_api(self)
            #self.client.clear_session()# TODO Doesn't work with firmware 1.1, returns proto.Failure
            self.client.bad = False
            self.device_checked = False
            self.proper_device = False
        return self.client
开发者ID:Tyronethedev,项目名称:electrum,代码行数:19,代码来源:trezor.py

示例9: get_client

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
    def get_client(self):
        if not TREZOR:
            give_error('please install github.com/trezor/python-trezor')

        if not self.client or self.client.bad:
            d = HidTransport.enumerate()
            if not d:
                give_error('Could not connect to your Trezor. Please verify the cable is connected and that no other app is using it.')
            self.transport = HidTransport(d[0])
            self.client = QtGuiTrezorClient(self.transport)
            self.client.handler = self.handler
            self.client.set_tx_api(self)
            self.client.bad = False
            if not self.atleast_version(1, 2, 1):
                self.client = None
                give_error('Outdated Trezor firmware. Please update the firmware from https://www.mytrezor.com')
        return self.client
开发者ID:paulmadore,项目名称:electrum-ltc,代码行数:19,代码来源:trezor.py

示例10: main

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
def main():
    devices = HidTransport.enumerate()
    if not devices:
        print('TREZOR is not plugged in. Please, connect TREZOR and retry.')
        return

    client = TrezorClient(devices[0])

    print()
    print('Confirm operation on TREZOR')
    print()

    masterKey = getMasterKey(client)
    # print('master key:', masterKey)

    fileName = getFileEncKey(masterKey)[0]
    # print('file name:', fileName)

    path = os.path.expanduser('~/Dropbox/Apps/TREZOR Password Manager/')
    # print('path to file:', path)

    encKey = getFileEncKey(masterKey)[2]
    # print('enckey:', encKey)

    full_path = path + fileName
    parsed_json = decryptStorage(full_path, encKey)

    # list entries
    entries = parsed_json['entries']
    printEntries(entries)

    entry_id = input('Select entry number to decrypt: ')
    entry_id = str(entry_id)

    plain_nonce = getDecryptedNonce(client, entries[entry_id])

    pwdArr = entries[entry_id]['password']['data']
    pwdHex = ''.join([ hex(x)[2:].zfill(2) for x in pwdArr ])
    print('password: ', decryptEntryValue(plain_nonce, unhexlify(pwdHex)))

    safeNoteArr = entries[entry_id]['safe_note']['data']
    safeNoteHex = ''.join([ hex(x)[2:].zfill(2) for x in safeNoteArr ])
    print('safe_note:', decryptEntryValue(plain_nonce, unhexlify(safeNoteHex)))

    return
开发者ID:admxjx,项目名称:slips,代码行数:47,代码来源:pwdreader.py

示例11: main

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
def main():
    # List all connected TREZORs on USB
    devices = HidTransport.enumerate()

    # Check whether we found any
    if len(devices) == 0:
        print('No TREZOR found')
        return

    # Use first connected device
    transport = HidTransport(devices[0])

    # Creates object for manipulating TREZOR
    debug_transport = HidTransport(devices[0], **{'debug_link': True})
    client = TrezorClient(transport)
    debug = DebugLink(debug_transport)

    mem = debug.memory_write(int(sys.argv[1],16), binascii.unhexlify(sys.argv[2]), flash=True)
    client.close()
开发者ID:schinzelh,项目名称:python-trezor,代码行数:21,代码来源:mem_write.py

示例12: main

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
def main():
    # List all connected TREZORs on USB
    devices = HidTransport.enumerate()

    # Check whether we found any
    if len(devices) == 0:
        print('No TREZOR found')
        return

    # Use first connected device
    transport = HidTransport(devices[0])

    # Creates object for manipulating TREZOR
    debug_transport = HidTransport(devices[0], **{'debug_link': True})
    client = TrezorClient(transport)
    debug = DebugLink(debug_transport)

    mem = debug.memory_read(int(sys.argv[1],16), int(sys.argv[2],16))
    f = open('memory.dat', 'w')
    f.write(mem)
    f.close()

    client.close()
开发者ID:schinzelh,项目名称:python-trezor,代码行数:25,代码来源:mem_read.py

示例13: __init__

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
import time

from PyQt4 import QtCore, QtGui
from PyQt4.QtCore import QThread, SIGNAL

from pycoin.key.bip32 import Wallet

from trezorlib.client import TrezorClient
from trezorlib.transport_hid import HidTransport
import trezorlib

import mnemonic

from gui import Ui_MainWindow

devices = HidTransport.enumerate()
transport = HidTransport(devices[0])

client = TrezorClient(transport)

#netcode = "BTC"
#xpub = Wallet(False, netcode, node.chain_code, node.depth, unhexlify("%08x" % node.fingerprint), node.child_num)

#
# Wrap trezor functions in a with statement (using this) to show on the UI that
# interaction is required on the trezor
#

class TrezorWarning:

    def __init__(self):
开发者ID:EricSchles,项目名称:TrezorToolkit,代码行数:33,代码来源:toolkit.py

示例14: _get_devices

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
 def _get_devices(self):
     """
     Returns Trezor HID devices
     """
     return HidTransport.enumerate()
开发者ID:Harikrishnan-github,项目名称:deosorg,代码行数:7,代码来源:vault.py

示例15: decryptStorage

# 需要导入模块: from trezorlib.transport_hid import HidTransport [as 别名]
# 或者: from trezorlib.transport_hid.HidTransport import enumerate [as 别名]
    full_path = ''.join((path, fileName))
    parsed_json = decryptStorage(full_path, encKey)

    #list entries
    entries = parsed_json['entries']
    printEntries(entries)

    entry_id = raw_input('Select entry number to decrypt: ')
    entry_id = str(entry_id)

    plain_nonce = getDecryptedNonce(entries[entry_id])

    pwdArr = entries[entry_id]['password']['data']
    pwdHex = ''.join([ hex(x)[2:].zfill(2) for x in pwdArr ])
    print 'password: ', decryptEntryValue(plain_nonce, unhexlify(pwdHex))

    safeNoteArr = entries[entry_id]['safe_note']['data']
    safeNoteHex = ''.join([ hex(x)[2:].zfill(2) for x in safeNoteArr ])
    print 'safe_note:', decryptEntryValue(plain_nonce, unhexlify(safeNoteHex))

    return

if __name__ == '__main__':
    try:
        # init TREZOR transport
        client = TrezorClient(HidTransport(HidTransport.enumerate()[0]))
    except:
        print 'TREZOR is not plugged in. Please, connect TREZOR and retry.'
    else:
        main()
开发者ID:BTA-BATA,项目名称:slips,代码行数:32,代码来源:pwdreader.py


注:本文中的trezorlib.transport_hid.HidTransport.enumerate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。