mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-27 10:22:34 +00:00
import print function from future
This commit is contained in:
parent
1fe94e7fa5
commit
54c8bfd1d4
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from trezorlib.client import TrezorClient
|
from trezorlib.client import TrezorClient
|
||||||
from trezorlib.transport_hid import HidTransport
|
from trezorlib.transport_hid import HidTransport
|
||||||
|
@ -1,4 +1,6 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
__doc__ = '''
|
__doc__ = '''
|
||||||
Use this script to cross-check that TREZOR generated valid
|
Use this script to cross-check that TREZOR generated valid
|
||||||
mnemonic sentence for given internal (TREZOR-generated)
|
mnemonic sentence for given internal (TREZOR-generated)
|
||||||
@ -42,7 +44,7 @@ def generate_entropy(strength, internal_entropy, external_entropy):
|
|||||||
raise Exception("External entropy too short")
|
raise Exception("External entropy too short")
|
||||||
|
|
||||||
entropy = hashlib.sha256(internal_entropy + external_entropy).digest()
|
entropy = hashlib.sha256(internal_entropy + external_entropy).digest()
|
||||||
entropy_stripped = entropy[:strength / 8]
|
entropy_stripped = entropy[:strength // 8]
|
||||||
|
|
||||||
if len(entropy_stripped) * 8 != strength:
|
if len(entropy_stripped) * 8 != strength:
|
||||||
raise Exception("Entropy length mismatch")
|
raise Exception("Entropy length mismatch")
|
||||||
@ -56,7 +58,7 @@ def main():
|
|||||||
trzr = binascii.unhexlify(input("Please enter TREZOR-generated entropy (in hex): ").strip())
|
trzr = binascii.unhexlify(input("Please enter TREZOR-generated entropy (in hex): ").strip())
|
||||||
word_count = int(input("How many words your mnemonic has? "))
|
word_count = int(input("How many words your mnemonic has? "))
|
||||||
|
|
||||||
strength = word_count * 32 / 3
|
strength = word_count * 32 // 3
|
||||||
|
|
||||||
entropy = generate_entropy(strength, trzr, comp)
|
entropy = generate_entropy(strength, trzr, comp)
|
||||||
|
|
||||||
|
21
signtest.py
Normal file → Executable file
21
signtest.py
Normal file → Executable file
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
from __future__ import print_function
|
||||||
import binascii
|
import binascii
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
@ -78,7 +79,7 @@ class MyTXAPIBitcoin(object):
|
|||||||
i.script_sig = os.urandom(100)
|
i.script_sig = os.urandom(100)
|
||||||
i.sequence = 0xffffffff
|
i.sequence = 0xffffffff
|
||||||
if (nr % 50 == 0):
|
if (nr % 50 == 0):
|
||||||
print nr
|
print(nr)
|
||||||
myout = random.randint(0, txsize-1)
|
myout = random.randint(0, txsize-1)
|
||||||
segwit = 1 #random.randint(0,1)
|
segwit = 1 #random.randint(0,1)
|
||||||
for vout in range(txsize):
|
for vout in range(txsize):
|
||||||
@ -118,8 +119,8 @@ class MyTXAPIBitcoin(object):
|
|||||||
prev_hash=txhash,
|
prev_hash=txhash,
|
||||||
prev_index = myout
|
prev_index = myout
|
||||||
))
|
))
|
||||||
#print binascii.hexlify(txser)
|
#print(binascii.hexlify(txser))
|
||||||
#print binascii.hexlify(txhash)
|
#print(binascii.hexlify(txhash))
|
||||||
self.txs[binascii.hexlify(txhash)] = t
|
self.txs[binascii.hexlify(txhash)] = t
|
||||||
|
|
||||||
self.outputs = [
|
self.outputs = [
|
||||||
@ -137,7 +138,7 @@ class MyTXAPIBitcoin(object):
|
|||||||
|
|
||||||
def get_tx(self, txhash):
|
def get_tx(self, txhash):
|
||||||
t = self.txs[txhash]
|
t = self.txs[txhash]
|
||||||
#print t
|
#print(t)
|
||||||
return t
|
return t
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
@ -149,11 +150,11 @@ def main():
|
|||||||
|
|
||||||
# Check whether we found any
|
# Check whether we found any
|
||||||
if len(devices) == 0:
|
if len(devices) == 0:
|
||||||
print 'No TREZOR found'
|
print('No TREZOR found')
|
||||||
return
|
return
|
||||||
|
|
||||||
# Use first connected device
|
# Use first connected device
|
||||||
print devices[0][0]
|
print(devices[0][0])
|
||||||
# transport = BridgeTransport(devices[0][0])
|
# transport = BridgeTransport(devices[0][0])
|
||||||
transport = HidTransport(devices[0])
|
transport = HidTransport(devices[0])
|
||||||
|
|
||||||
@ -164,14 +165,14 @@ def main():
|
|||||||
# client.set_tx_api(TXAPITestnet())
|
# client.set_tx_api(TXAPITestnet())
|
||||||
txstore.set_client(client)
|
txstore.set_client(client)
|
||||||
txstore.set_publickey(client.get_public_node(client.expand_path("44'/0'/0'")))
|
txstore.set_publickey(client.get_public_node(client.expand_path("44'/0'/0'")))
|
||||||
print "creating input txs"
|
print("creating input txs")
|
||||||
txstore.create_inputs(numinputs, sizeinputtx)
|
txstore.create_inputs(numinputs, sizeinputtx)
|
||||||
print "go"
|
print("go")
|
||||||
client.set_tx_api(txstore)
|
client.set_tx_api(txstore)
|
||||||
# client.set_tx_api(MyTXAPIBitcoin())
|
# client.set_tx_api(MyTXAPIBitcoin())
|
||||||
|
|
||||||
# Print out TREZOR's features and settings
|
# Print out TREZOR's features and settings
|
||||||
print client.features
|
print(client.features)
|
||||||
|
|
||||||
# Get the first address of first BIP44 account
|
# Get the first address of first BIP44 account
|
||||||
# (should be the same address as shown in mytrezor.com)
|
# (should be the same address as shown in mytrezor.com)
|
||||||
@ -215,7 +216,7 @@ def main():
|
|||||||
|
|
||||||
# (signatures, serialized_tx) = client.sign_tx('Testnet', inputs, outputs)
|
# (signatures, serialized_tx) = client.sign_tx('Testnet', inputs, outputs)
|
||||||
(signatures, serialized_tx) = client.sign_tx('Bitcoin', txstore.get_inputs(), txstore.get_outputs())
|
(signatures, serialized_tx) = client.sign_tx('Bitcoin', txstore.get_inputs(), txstore.get_outputs())
|
||||||
print 'Transaction:', binascii.hexlify(serialized_tx)
|
print('Transaction:', binascii.hexlify(serialized_tx))
|
||||||
|
|
||||||
client.close()
|
client.close()
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import config
|
import config
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
sys.path = ['../',] + sys.path
|
sys.path = ['../',] + sys.path
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
import time
|
import time
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
import math
|
import math
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import time
|
import time
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
import common
|
import common
|
||||||
import binascii
|
import binascii
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Use TREZOR as a hardware key for opening EncFS filesystem!
|
Use TREZOR as a hardware key for opening EncFS filesystem!
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
from __future__ import print_function
|
||||||
import os
|
import os
|
||||||
import binascii
|
import binascii
|
||||||
import argparse
|
import argparse
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
from . import messages_pb2 as proto
|
from . import messages_pb2 as proto
|
||||||
from .transport import NotImplementedException
|
from .transport import NotImplementedException
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import math
|
import math
|
||||||
import operator
|
import operator
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
'''PipeTransport implements fake wire transport over local named pipe.
|
'''PipeTransport implements fake wire transport over local named pipe.
|
||||||
Use this transport for talking with trezor simulator.'''
|
Use this transport for talking with trezor simulator.'''
|
||||||
|
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
'''SerialTransport implements wire transport over serial port.'''
|
'''SerialTransport implements wire transport over serial port.'''
|
||||||
|
|
||||||
# Local serial port loopback: socat PTY,link=COM8 PTY,link=COM9
|
# Local serial port loopback: socat PTY,link=COM8 PTY,link=COM9
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
|
from __future__ import print_function
|
||||||
|
|
||||||
'''SocketTransport implements TCP socket interface for Transport.'''
|
'''SocketTransport implements TCP socket interface for Transport.'''
|
||||||
|
|
||||||
import socket
|
import socket
|
||||||
|
Loading…
Reference in New Issue
Block a user