mirror of
https://github.com/trezor/trezor-firmware.git
synced 2024-12-27 08:38:07 +00:00
update tools to use the new transport API
also drop some python2 compatibility things
This commit is contained in:
parent
ff80ca1b82
commit
967d479a19
@ -16,21 +16,15 @@ import hashlib
|
|||||||
import binascii
|
import binascii
|
||||||
|
|
||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.device import TrezorDevice
|
from trezorlib.transport import enumerate_devices
|
||||||
|
|
||||||
# Python2 vs Python3
|
|
||||||
try:
|
|
||||||
input = raw_input
|
|
||||||
except NameError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def wait_for_devices():
|
def wait_for_devices():
|
||||||
devices = TrezorDevice.enumerate()
|
devices = enumerate_devices()
|
||||||
while not len(devices):
|
while not len(devices):
|
||||||
sys.stderr.write("Please connect TREZOR to computer and press Enter...")
|
sys.stderr.write("Please connect TREZOR to computer and press Enter...")
|
||||||
input()
|
input()
|
||||||
devices = TrezorDevice.enumerate()
|
devices = enumerate_devices()
|
||||||
|
|
||||||
return devices
|
return devices
|
||||||
|
|
||||||
|
@ -1,21 +1,11 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.device import TrezorDevice
|
from trezorlib.transport import get_transport
|
||||||
|
|
||||||
|
|
||||||
def main():
|
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
|
# Use first connected device
|
||||||
transport = devices[0]
|
transport = get_transport()
|
||||||
|
|
||||||
# Creates object for manipulating TREZOR
|
# Creates object for manipulating TREZOR
|
||||||
client = TrezorClient(transport)
|
client = TrezorClient(transport)
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
from trezorlib.debuglink import DebugLink
|
from trezorlib.debuglink import DebugLink
|
||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.transport_hid import HidTransport
|
from trezorlib.transport import enumerate_devices
|
||||||
import binascii
|
import binascii
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -16,8 +14,8 @@ sectorlens = [0x4000, 0x4000, 0x4000, 0x4000,
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# List all connected TREZORs on USB
|
# List all debuggable TREZORs
|
||||||
devices = HidTransport.enumerate()
|
devices = [device for device in enumerate_devices() if hasattr(device, 'find_debug')]
|
||||||
|
|
||||||
# Check whether we found any
|
# Check whether we found any
|
||||||
if len(devices) == 0:
|
if len(devices) == 0:
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
from trezorlib.debuglink import DebugLink
|
from trezorlib.debuglink import DebugLink
|
||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.transport_hid import HidTransport
|
from trezorlib.transport import enumerate_devices
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# usage examples
|
# usage examples
|
||||||
@ -16,8 +14,8 @@ import sys
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# List all connected TREZORs on USB
|
# List all debuggable TREZORs
|
||||||
devices = HidTransport.enumerate()
|
devices = [device for device in enumerate_devices() if hasattr(device, 'find_debug')]
|
||||||
|
|
||||||
# Check whether we found any
|
# Check whether we found any
|
||||||
if len(devices) == 0:
|
if len(devices) == 0:
|
||||||
|
@ -1,16 +1,14 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
from trezorlib.debuglink import DebugLink
|
from trezorlib.debuglink import DebugLink
|
||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.transport_hid import HidTransport
|
from trezorlib.transport import enumerate_devices
|
||||||
import binascii
|
import binascii
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
# List all connected TREZORs on USB
|
# List all debuggable TREZORs
|
||||||
devices = HidTransport.enumerate()
|
devices = [device for device in enumerate_devices() if hasattr(device, 'find_debug')]
|
||||||
|
|
||||||
# Check whether we found any
|
# Check whether we found any
|
||||||
if len(devices) == 0:
|
if len(devices) == 0:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
from __future__ import print_function
|
|
||||||
import binascii
|
import binascii
|
||||||
import hashlib
|
import hashlib
|
||||||
import mnemonic
|
import mnemonic
|
||||||
@ -16,12 +15,6 @@ __doc__ = '''
|
|||||||
without an internet connection).
|
without an internet connection).
|
||||||
'''
|
'''
|
||||||
|
|
||||||
# Python2 vs Python3
|
|
||||||
try:
|
|
||||||
input = raw_input
|
|
||||||
except NameError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
|
|
||||||
def generate_entropy(strength, internal_entropy, external_entropy):
|
def generate_entropy(strength, internal_entropy, external_entropy):
|
||||||
'''
|
'''
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from __future__ import print_function
|
|
||||||
|
|
||||||
from binascii import hexlify, unhexlify
|
from binascii import hexlify, unhexlify
|
||||||
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
from cryptography.hazmat.primitives.ciphers import Cipher, algorithms, modes
|
||||||
from cryptography.hazmat.backends import default_backend
|
from cryptography.hazmat.backends import default_backend
|
||||||
@ -9,14 +6,10 @@ import hmac
|
|||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
try:
|
from urllib.parse import urlparse
|
||||||
from urllib.parse import urlparse
|
|
||||||
except:
|
|
||||||
from urlparse import urlparse
|
|
||||||
input = raw_input
|
|
||||||
|
|
||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.transport_hid import HidTransport
|
from trezorlib.transport import get_transport
|
||||||
|
|
||||||
# Return path by BIP-32
|
# Return path by BIP-32
|
||||||
def getPath(client):
|
def getPath(client):
|
||||||
@ -124,12 +117,13 @@ def printEntries(entries):
|
|||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
devices = HidTransport.enumerate()
|
try:
|
||||||
if not devices:
|
transport = get_transport()
|
||||||
print('TREZOR is not plugged in. Please, connect TREZOR and retry.')
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
return
|
return
|
||||||
|
|
||||||
client = TrezorClient(devices[0])
|
client = TrezorClient(transport)
|
||||||
|
|
||||||
print()
|
print()
|
||||||
print('Confirm operation on TREZOR')
|
print('Confirm operation on TREZOR')
|
||||||
|
@ -8,21 +8,14 @@ from __future__ import print_function
|
|||||||
import io
|
import io
|
||||||
import sys
|
import sys
|
||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.device import TrezorDevice
|
from trezorlib.transport import get_transport
|
||||||
|
|
||||||
|
|
||||||
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 main():
|
def main():
|
||||||
client = get_client()
|
try:
|
||||||
if not client:
|
client = TrezorClient(get_transport())
|
||||||
print('No TREZOR connected')
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
return
|
return
|
||||||
|
|
||||||
arg1 = sys.argv[1] # output file
|
arg1 = sys.argv[1] # output file
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from __future__ import print_function
|
|
||||||
import binascii
|
import binascii
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
@ -12,8 +11,7 @@ import hashlib
|
|||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.tx_api import TxApiTestnet
|
from trezorlib.tx_api import TxApiTestnet
|
||||||
from trezorlib.tx_api import TxApiBitcoin
|
from trezorlib.tx_api import TxApiBitcoin
|
||||||
from trezorlib.transport_hid import HidTransport
|
from trezorlib.transport import get_transport
|
||||||
from trezorlib.transport_bridge import BridgeTransport
|
|
||||||
|
|
||||||
|
|
||||||
def hash160(x):
|
def hash160(x):
|
||||||
@ -152,16 +150,13 @@ def main():
|
|||||||
numinputs = 100
|
numinputs = 100
|
||||||
sizeinputtx = 10
|
sizeinputtx = 10
|
||||||
|
|
||||||
# List all connected TREZORs on USB
|
# Use first connected device
|
||||||
devices = HidTransport.enumerate()
|
try:
|
||||||
|
transport = get_transport()
|
||||||
# Check whether we found any
|
except Exception as e:
|
||||||
if len(devices) == 0:
|
print(e)
|
||||||
print('No TREZOR found')
|
|
||||||
return
|
return
|
||||||
|
|
||||||
# Use first connected device
|
|
||||||
transport = devices[0]
|
|
||||||
print(transport)
|
print(transport)
|
||||||
|
|
||||||
txstore = MyTxApiBitcoin()
|
txstore = MyTxApiBitcoin()
|
||||||
|
Loading…
Reference in New Issue
Block a user