1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-03 03:50:58 +00:00

remove remaining usages of expand_path

This commit is contained in:
matejcik 2018-05-28 15:47:57 +02:00
parent c10c3f7fd9
commit 8410151810
5 changed files with 17 additions and 9 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from trezorlib.client import TrezorClient from trezorlib.client import TrezorClient
from trezorlib.transport import get_transport from trezorlib.transport import get_transport
from trezorlib.tools import parse_path
def main(): def main():
@ -15,7 +16,7 @@ def main():
# Get the first address of first BIP44 account # Get the first address of first BIP44 account
# (should be the same address as shown in wallet.trezor.io) # (should be the same address as shown in wallet.trezor.io)
bip32_path = client.expand_path("44'/0'/0'/0/0") bip32_path = parse_path("44'/0'/0'/0/0")
address = client.get_address('Bitcoin', bip32_path) address = client.get_address('Bitcoin', bip32_path)
print('Bitcoin address:', address) print('Bitcoin address:', address)

View File

@ -10,16 +10,16 @@ from urllib.parse import urlparse
from trezorlib.client import TrezorClient from trezorlib.client import TrezorClient
from trezorlib.transport import get_transport from trezorlib.transport import get_transport
from trezorlib.tools import parse_path
# Return path by BIP-32 # Return path by BIP-32
def getPath(client): BIP32_PATH = parse_path("10016h/0")
return client.expand_path("10016'/0")
# Deriving master key # Deriving master key
def getMasterKey(client): def getMasterKey(client):
bip32_path = getPath(client) bip32_path = BIP32_PATH
ENC_KEY = 'Activate TREZOR Password Manager?' ENC_KEY = 'Activate TREZOR Password Manager?'
ENC_VALUE = unhexlify('2d650551248d792eabf628f451200d7f51cb63e46aadcbb1038aacb05e8c8aee2d650551248d792eabf628f451200d7f51cb63e46aadcbb1038aacb05e8c8aee') ENC_VALUE = unhexlify('2d650551248d792eabf628f451200d7f51cb63e46aadcbb1038aacb05e8c8aee2d650551248d792eabf628f451200d7f51cb63e46aadcbb1038aacb05e8c8aee')
key = hexlify(client.encrypt_keyvalue( key = hexlify(client.encrypt_keyvalue(
@ -99,7 +99,7 @@ def getDecryptedNonce(client, entry):
ENC_KEY = 'Unlock %s for user %s?' % (item, entry['username']) ENC_KEY = 'Unlock %s for user %s?' % (item, entry['username'])
ENC_VALUE = entry['nonce'] ENC_VALUE = entry['nonce']
decrypted_nonce = hexlify(client.decrypt_keyvalue( decrypted_nonce = hexlify(client.decrypt_keyvalue(
getPath(client), BIP32_PATH,
ENC_KEY, ENC_KEY,
unhexlify(ENC_VALUE), unhexlify(ENC_VALUE),
False, False,

View File

@ -14,6 +14,13 @@ from trezorlib.tx_api import TxApiBitcoin
from trezorlib.transport import get_transport from trezorlib.transport import get_transport
# This script has survived unmodified through several significant changes
# of the trezorlib library. While we want to have something like this,
# we're waiting on a couple more changes in order to implement this a little more cleanly.
# Wait for trezorlib v1.0.
raise Exception("This code is too old to run. Sorry.")
def hash160(x): def hash160(x):
h = hashlib.new("ripemd160") h = hashlib.new("ripemd160")
h.update(hashlib.sha256(x).digest()) h.update(hashlib.sha256(x).digest())

View File

@ -162,7 +162,7 @@ class TestMsgNEMSignTx(TrezorTest):
self.setup_mnemonic_nopin_nopassphrase() self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), { tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 76809215, "timeStamp": 76809215,
"amount": 3000000, "amount": 3000000,
"fee": 1000000, "fee": 1000000,
@ -191,7 +191,7 @@ class TestMsgNEMSignTx(TrezorTest):
self.setup_mnemonic_nopin_nopassphrase() self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), { tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 76809215, "timeStamp": 76809215,
"amount": 2000000, "amount": 2000000,
"fee": 1000000, "fee": 1000000,
@ -219,7 +219,7 @@ class TestMsgNEMSignTx(TrezorTest):
def test_nem_signtx_multiple_mosaics(self): def test_nem_signtx_multiple_mosaics(self):
self.setup_mnemonic_nopin_nopassphrase() self.setup_mnemonic_nopin_nopassphrase()
tx = self.client.nem_sign_tx(self.client.expand_path("m/44'/1'/0'/0'/0'"), { tx = self.client.nem_sign_tx(parse_path("m/44'/1'/0'/0'/0'"), {
"timeStamp": 76809215, "timeStamp": 76809215,
"amount": 2000000, "amount": 2000000,
"fee": 1000000, "fee": 1000000,

View File

@ -207,7 +207,7 @@ class TestMsgSigntxSegwitNative(TrezorTest):
script_type=proto.OutputScriptType.PAYTOADDRESS, script_type=proto.OutputScriptType.PAYTOADDRESS,
) )
out2 = proto.TxOutputType( out2 = proto.TxOutputType(
# address_n=self.client.expand_path("44'/1'/0'/0/0"), # address_n=parse_path("44'/1'/0'/0/0"),
# script_type=proto.OutputScriptType.PAYTOP2SHWITNESS, # script_type=proto.OutputScriptType.PAYTOP2SHWITNESS,
address='2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc', address='2N6UeBoqYEEnybg4cReFYDammpsyDw8R2Mc',
script_type=proto.OutputScriptType.PAYTOADDRESS, script_type=proto.OutputScriptType.PAYTOADDRESS,