1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-16 11:28:14 +00:00

eth: EthereumGetAddress returns address as a string

This commit is contained in:
Tomas Susanka 2019-01-25 16:16:43 +01:00
parent 02abf11798
commit 3387b157a7

View File

@ -14,19 +14,20 @@ async def get_address(ctx, msg, keychain):
node = keychain.derive(msg.address_n) node = keychain.derive(msg.address_n)
seckey = node.private_key() seckey = node.private_key()
public_key = secp256k1.publickey(seckey, False) # uncompressed public_key = secp256k1.publickey(seckey, False) # uncompressed
address = sha3_256(public_key[1:], keccak=True).digest()[12:] address_bytes = sha3_256(public_key[1:], keccak=True).digest()[12:]
if len(msg.address_n) > 1: # path has slip44 network identifier
network = networks.by_slip44(msg.address_n[1] & 0x7FFFFFFF)
else:
network = None
address = ethereum_address_hex(address_bytes, network)
if msg.show_display: if msg.show_display:
if len(msg.address_n) > 1: # path has slip44 network identifier
network = networks.by_slip44(msg.address_n[1] & 0x7FFFFFFF)
else:
network = None
hex_addr = ethereum_address_hex(address, network)
desc = address_n_to_str(msg.address_n) desc = address_n_to_str(msg.address_n)
while True: while True:
if await show_address(ctx, hex_addr, desc=desc): if await show_address(ctx, address, desc=desc):
break break
if await show_qr(ctx, hex_addr, desc=desc): if await show_qr(ctx, address, desc=desc):
break break
return EthereumAddress(address=address) return EthereumAddress(address)