def get_transport(): from trezorlib.transport_hid import HidTransport count = len(HidTransport.enumerate()) if not count: logging.warning('Number of Trezor devices: 0') for d in HidTransport.enumerate(): transport = HidTransport(d) return transport
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
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
def Wait_for_devices(): devices = HidTransport.enumerate() while not len(devices): print("Please connect TREZOR to computer and press Enter...") input() devices = HidTransport.enumerate() return devices
def load_hw_devices(self): """ Load all instances of the selected hardware wallet type. If there is more than one, user has to select which one he is going to use. """ control_trezor_keepkey_libs(self.hw_type) self.main_ui.disconnectHardwareWallet( ) # disconnect hw if it's open in the main window self.hw_device_instances.clear() self.cboDeviceInstance.clear() if self.hw_type == HWType.trezor: import trezorlib.client as client from trezorlib.transport_hid import HidTransport for d in HidTransport.enumerate(): transport = HidTransport(d) cl = client.TrezorClient(transport) lbl = cl.features.label + ' (' + cl.features.device_id + ')' self.hw_device_instances.append([lbl, cl.features.device_id]) self.cboDeviceInstance.addItem(lbl) cl.clear_session() cl.close() elif self.hw_type == HWType.keepkey: import keepkeylib.client as client from keepkeylib.transport_hid import HidTransport for d in HidTransport.enumerate(): transport = HidTransport(d) cl = client.KeepKeyClient(transport) lbl = cl.features.label + ' (' + cl.features.device_id + ')' self.hw_device_instances.append([lbl, cl.features.device_id]) self.cboDeviceInstance.addItem(lbl) cl.clear_session() cl.close() elif self.hw_type == HWType.ledger_nano_s: from btchip.btchipComm import getDongle from btchip.btchipException import BTChipException try: dongle = getDongle() if dongle: lbl = HWType.get_desc(self.hw_type) self.hw_device_instances.append([lbl, None]) self.cboDeviceInstance.addItem(lbl) dongle.close() del dongle except BTChipException as e: if e.message != 'No dongle found': raise
def get_transport(): if HID_ENABLED and HidTransport.enumerate(): devices = HidTransport.enumerate() wirelink = devices[0] debuglink = devices[0].find_debug() elif PIPE_ENABLED and pipe_exists('/tmp/pipe.trezor.to'): wirelink = PipeTransport('/tmp/pipe.trezor', False) debuglink = PipeTransport('/tmp/pipe.trezor_debug', False) elif UDP_ENABLED: wirelink = UdpTransport() debuglink = UdpTransport() return wirelink, debuglink
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()
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 = devices[0] debug_transport = devices[0].find_debug() # Creates object for manipulating TREZOR client = TrezorClient(transport) debug = DebugLink(debug_transport) arg1 = int(sys.argv[1], 16) arg2 = int(sys.argv[2], 16) step = 0x400 if arg2 >= 0x400 else arg2 f = open('memory.dat', 'wb') for addr in range(arg1, arg1 + arg2, step): mem = debug.memory_read(addr, step) f.write(mem) f.close() client.close()
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
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")
def main(): try: # List all connected TREZORs on USB devices = HidTransport.enumerate() # Check whether we found any if len(devices) == 0: input('No TREZOR found. Press any key...') 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 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() input('Press any key...') except Exception as e: print(str(e)) traceback.print_exc(file=sys.stdout) input('Press any key...')
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 = devices[0] debug_transport = devices[0].find_debug() # Creates object for manipulating TREZOR client = TrezorClient(transport) debug = DebugLink(debug_transport) sector = int(sys.argv[1]) f = open(sys.argv[2], "rb") content = f.read(sectorlens[sector]) if (len(content) != sectorlens[sector]): print("Not enough bytes in file") return debug.flash_erase(sector) step = 0x400 for offset in range(0, sectorlens[sector], step): debug.memory_write(sectoraddrs[sector] + offset, content[offset:offset + step], flash=True) client.close()
def get_client() -> Optional[MyTrezorClient]: from trezorlib.transport_hid import HidTransport count = len(HidTransport.enumerate()) if not count: logging.warning('Number of Trezor devices: 0') for d in HidTransport.enumerate(): transport = HidTransport(d) client = MyTrezorClient(transport, ask_for_pin_callback, ask_for_pass_callback) if not device_id or client.features.device_id == device_id: return client else: client.clear_session() client.close() return None
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
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 wallet.trezor.io) bip32_path = client.expand_path("44'/42'/0'/0/0") address = client.get_address('Decred', bip32_path) print('Decred address:', address) address_n = client.expand_path("0") xpub = client.get_public_node('Decred', address_n) print('xpub: ', xpub) client.close()
def get_client(): devices = HidTransport.enumerate() # list all connected TREZORs on USB if len(devices) == 0: # check whether we found any return None transport = HidTransport(devices[0]) # use first connected device return TrezorClient( transport) # creates object for communicating with TREZOR
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())
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())
def get_trezor_client(): devices = HidTransport.enumerate() if len(devices) == 0: worklog.error('could not find any trezor device connected') return None transport = HidTransport(devices[0]) client = TrezorClient(transport) return client
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
def __init__(self, device, path): super(TrezorClient, self).__init__(device) device.close() devices = HidTransport.enumerate() self.client = None for d in devices: if d[0] == path: transport = HidTransport(d) self.client = Trezor(transport) break # if it wasn't able to find a client, throw an error if not self.client: raise IOError("no Device")
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
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
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
def connect_trezor(ask_for_pin_fun, ask_for_pass_fun): try: from trezorlib.transport_hid import HidTransport transport = None for d in HidTransport.enumerate(): transport = HidTransport(d) break if transport: client = MyTrezorClient(transport, ask_for_pin_fun, ask_for_pass_fun) return client else: return None except Exception as e: raise
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: '******'safe_note']['data'] safeNoteHex = ''.join([hex(x)[2:].zfill(2) for x in safeNoteArr]) print('safe_note:', decryptEntryValue(plain_nonce, unhexlify(safeNoteHex))) return
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: '******'safe_note']['data'] safeNoteHex = ''.join([ hex(x)[2:].zfill(2) for x in safeNoteArr ]) print('safe_note:', decryptEntryValue(plain_nonce, unhexlify(safeNoteHex))) return
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 = devices[0] debug_transport = devices[0].find_debug() # Creates object for manipulating TREZOR client = TrezorClient(transport) debug = DebugLink(debug_transport) debug.memory_write(int(sys.argv[1], 16), binascii.unhexlify(sys.argv[2]), flash=True) client.close()
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()
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
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 == 'bridge': from trezorlib.transport_bridge import BridgeTransport return BridgeTransport(path, **kwargs) if transport_string == 'fake': from trezorlib.transport_fake import FakeTransport return FakeTransport(path, **kwargs) raise NotImplemented("Unknown transport")
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()
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()
UDP_ENABLED = True except Exception as e: print('UDP transport disabled:', e.message, e.args) UDP_ENABLED = False def pipe_exists(path): import os import stat try: return stat.S_ISFIFO(os.stat(path).st_mode) except: return False if HID_ENABLED and len(HidTransport.enumerate()) > 0: devices = HidTransport.enumerate() print('Using TREZOR') TRANSPORT = HidTransport TRANSPORT_ARGS = (devices[0], ) TRANSPORT_KWARGS = {'debug_link': False} DEBUG_TRANSPORT = HidTransport DEBUG_TRANSPORT_ARGS = (devices[0], ) DEBUG_TRANSPORT_KWARGS = {'debug_link': True} elif PIPE_ENABLED and pipe_exists('/tmp/pipe.trezor.to'): print('Using Emulator (v1=pipe)') TRANSPORT = PipeTransport TRANSPORT_ARGS = ('/tmp/pipe.trezor', False)
def main(): numinputs = 600 sizeinputtx = 10 # 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 print(devices[0][0]) # transport = BridgeTransport(devices[0][0]) transport = HidTransport(devices[0]) txstore = MyTXAPIBitcoin() # Creates object for manipulating TREZOR client = TrezorClient(transport) # client.set_tx_api(TXAPITestnet()) txstore.set_client(client) txstore.set_publickey(client.get_public_node(client.expand_path("44'/0'/0'"))) print("creating input txs") txstore.create_inputs(numinputs, sizeinputtx) print("go") client.set_tx_api(txstore) # client.set_tx_api(MyTXAPIBitcoin()) # 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) outputs = [ proto_types.TxOutputType( amount=0, script_type=proto_types.PAYTOADDRESS, address='p2xtZoXeX5X8BP8JfFhQK2nD3emtjch7UeFm' # op_return_data=binascii.unhexlify('2890770995194662774cd192ee383b805e9a066e6a456be037727649228fb7f6') # address_n=client.expand_path("44'/0'/0'/0/35"), # address='3PUxV6Cc4udQZQsJhArVUzvvVoKC8ohkAj', ), # proto_types.TxOutputType( # amount=0, # script_type=proto_types.PAYTOOPRETURN, # op_return_data=binascii.unhexlify('2890770995194662774cd192ee383b805e9a066e6a456be037727649228fb7f6') # ), # proto_types.TxOutputType( # amount= 8120, # script_type=proto_types.PAYTOADDRESS, # address_n=client.expand_path("44'/1'/0'/1/0"), # address='1PtCkQgyN6xHmXWzLmFFrDNA5vYhYLeNFZ', # address='14KRxYgFc7Se8j7MDdrK5PTNv8meq4GivK', # ), # proto_types.TxOutputType( # amount= 18684 - 2000, # script_type=proto_types.PAYTOADDRESS, # address_n=client.expand_path("44'/0'/0'/0/7"), # # address='1PtCkQgyN6xHmXWzLmFFrDNA5vYhYLeNFZ', # # address='1s9TSqr3PHZdXGrYws59Uaf5SPqavH43z', # ), # proto_types.TxOutputType( # amount= 1000, # script_type=proto_types.PAYTOADDRESS, # # address_n=client.expand_path("44'/0'/0'/0/18"), # # address='1PtCkQgyN6xHmXWzLmFFrDNA5vYhYLeNFZ', # address='1NcMqUvyWv1K3Zxwmx5sqfj7ZEmPCSdJFM', # ), ] # (signatures, serialized_tx) = client.sign_tx('Testnet', inputs, outputs) (signatures, serialized_tx) = client.sign_tx('Bitcoin', txstore.get_inputs(), txstore.get_outputs()) print('Transaction:', binascii.hexlify(serialized_tx)) client.close()
def enumerateHIDDevices(self): """Returns Trezor HID devices""" devices = HidTransport.enumerate() return devices
from __future__ import print_function import sys sys.path = [ '../', ] + sys.path from trezorlib.transport_pipe import PipeTransport from trezorlib.transport_hid import HidTransport from trezorlib.transport_socket import SocketTransportClient #from trezorlib.transport_bridge import BridgeTransport devices = HidTransport.enumerate() if len(devices) > 0: if devices[0][1] != None: print('Using TREZOR') TRANSPORT = HidTransport TRANSPORT_ARGS = (devices[0], ) TRANSPORT_KWARGS = {'debug_link': False} DEBUG_TRANSPORT = HidTransport DEBUG_TRANSPORT_ARGS = (devices[0], ) DEBUG_TRANSPORT_KWARGS = {'debug_link': True} else: print('Using Raspberry Pi') TRANSPORT = HidTransport TRANSPORT_ARGS = (devices[0], ) TRANSPORT_KWARGS = {'debug_link': False} DEBUG_TRANSPORT = SocketTransportClient DEBUG_TRANSPORT_ARGS = ('trezor.bo:2000', ) DEBUG_TRANSPORT_KWARGS = {}
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: '******'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()
def _get_devices(self): """ Returns Trezor HID devices """ return HidTransport.enumerate()
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: '******'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()
devices = HidTransport.enumerate() wirelink = devices[0] debuglink = devices[0].find_debug() elif PIPE_ENABLED and pipe_exists('/tmp/pipe.trezor.to'): wirelink = PipeTransport('/tmp/pipe.trezor', False) debuglink = PipeTransport('/tmp/pipe.trezor_debug', False) elif UDP_ENABLED: wirelink = UdpTransport() debuglink = UdpTransport() return wirelink, debuglink if HID_ENABLED and HidTransport.enumerate(): print('Using TREZOR') elif PIPE_ENABLED and pipe_exists('/tmp/pipe.trezor.to'): print('Using Emulator (v1=pipe)') elif UDP_ENABLED: print('Using Emulator (v2=udp)') class TrezorTest(object): def setup_method(self, method): wirelink, debuglink = get_transport() self.client = TrezorClientDebugLink(wirelink) self.client.set_debuglink(debuglink) self.client.set_tx_api(tx_api.TxApiBitcoin) # self.client.set_buttonwait(3)
def list_usb(): from trezorlib.transport_hid import HidTransport return HidTransport.enumerate()
def main(): numinputs = 100 sizeinputtx = 10 # 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 print(devices[0][0]) # transport = BridgeTransport(devices[0][0]) transport = HidTransport(devices[0]) txstore = MyTxApiBitcoin() # Creates object for manipulating TREZOR client = TrezorClient(transport) # client.set_tx_api(TxApiTestnet) txstore.set_client(client) txstore.set_publickey(client.get_public_node(client.expand_path("44'/0'/0'"))) print("creating input txs") txstore.create_inputs(numinputs, sizeinputtx) print("go") client.set_tx_api(txstore) # client.set_tx_api(MyTxApiBitcoin()) # 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) outputs = [ proto_types.TxOutputType( amount=0, script_type=proto_types.PAYTOADDRESS, address='p2xtZoXeX5X8BP8JfFhQK2nD3emtjch7UeFm' # op_return_data=binascii.unhexlify('2890770995194662774cd192ee383b805e9a066e6a456be037727649228fb7f6') # address_n=client.expand_path("44'/0'/0'/0/35"), # address='3PUxV6Cc4udQZQsJhArVUzvvVoKC8ohkAj', ), # proto_types.TxOutputType( # amount=0, # script_type=proto_types.PAYTOOPRETURN, # op_return_data=binascii.unhexlify('2890770995194662774cd192ee383b805e9a066e6a456be037727649228fb7f6') # ), # proto_types.TxOutputType( # amount= 8120, # script_type=proto_types.PAYTOADDRESS, # address_n=client.expand_path("44'/1'/0'/1/0"), # address='1PtCkQgyN6xHmXWzLmFFrDNA5vYhYLeNFZ', # address='14KRxYgFc7Se8j7MDdrK5PTNv8meq4GivK', # ), # proto_types.TxOutputType( # amount= 18684 - 2000, # script_type=proto_types.PAYTOADDRESS, # address_n=client.expand_path("44'/0'/0'/0/7"), # # address='1PtCkQgyN6xHmXWzLmFFrDNA5vYhYLeNFZ', # # address='1s9TSqr3PHZdXGrYws59Uaf5SPqavH43z', # ), # proto_types.TxOutputType( # amount= 1000, # script_type=proto_types.PAYTOADDRESS, # # address_n=client.expand_path("44'/0'/0'/0/18"), # # address='1PtCkQgyN6xHmXWzLmFFrDNA5vYhYLeNFZ', # # address='1NcMqUvyWv1K3Zxwmx5sqfj7ZEmPCSdJFM', # ), ] # (signatures, serialized_tx) = client.sign_tx('Testnet', inputs, outputs) (signatures, serialized_tx) = client.sign_tx('Bitcoin', txstore.get_inputs(), txstore.get_outputs()) print('Transaction:', binascii.hexlify(serialized_tx)) client.close()
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):