def wait_for_devices(): devices = TrezorDevice.enumerate() while not len(devices): sys.stderr.write( "Please connect TREZOR to computer and press Enter...") input() devices = TrezorDevice.enumerate() return devices
def main(): # List all connected TREZORs on USB/UDP devices = TrezorDevice.enumerate() # Check whether we found any if len(devices) == 0: print('No TREZOR found') return # Use first connected device transport = 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 wallet.trezor.io) bip32_path = client.expand_path("44'/0'/0'/0/0") address = client.get_address('Bitcoin', bip32_path) print('Bitcoin address:', address) client.close()
def get_client(): devices = TrezorDevice.enumerate() # list all connected TREZORs on USB if len(devices) == 0: # check whether we found any return None transport = devices[0] # use first connected device return TrezorClient( transport) # creates object for communicating with TREZOR
def find_trezor(self): u"""Selects a trezor device and initialize the client.""" devices = TrezorDevice.enumerate() if len(devices) == 0: raise NoTrezorFoundError('No Trezor device was found. Make sure it' ' is plugged.') transport = devices[0] trezor = TrezorClient(transport, ui=ui.ClickUI()) return trezor
def enumerate(self): from trezorlib.device import TrezorDevice return [ Device(d.get_path(), -1, d.get_path(), 'TREZOR', 0) for d in TrezorDevice.enumerate() ]
def enumerate_transports(): """Returns all available transports.""" return TrezorDevice.enumerate()
#!/usr/bin/env python3 import code import readline import rlcompleter import struct import sys from trezorlib.device import TrezorDevice import trezorlib.messages as proto try: transport, = (device.find_debug() for device in TrezorDevice.enumerate()) except ValueError: sys.exit("Exactly one TREZOR must be connected, with debug link enabled.") transport.session_begin() class HexInteger(int): def __repr__(self): return hex(self) class MemoryMappedInteger(object): def __init__(self, fmt, address): self.struct = struct.Struct("<" + fmt) self.address = address def read(self): transport.write(
def enumerate(self): from trezorlib.device import TrezorDevice return [Device(d.get_path(), -1, d.get_path(), 'TREZOR', 0) for d in TrezorDevice.enumerate()]