mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
eth: add get public key
This commit is contained in:
parent
701b603419
commit
7288700b86
22
trezorctl
22
trezorctl
@ -1060,6 +1060,28 @@ def ethereum_get_address(connect, address, show_display):
|
||||
return "0x%s" % address.hex()
|
||||
|
||||
|
||||
@cli.command(help="Get Ethereum public node of given path.")
|
||||
@click.option(
|
||||
"-n", "--address", required=True, help="BIP-32 path, e.g. m/44'/60'/0'/0/0"
|
||||
)
|
||||
@click.option("-d", "--show-display", is_flag=True)
|
||||
@click.pass_obj
|
||||
def ethereum_get_public_node(connect, address, show_display):
|
||||
client = connect()
|
||||
address_n = tools.parse_path(address)
|
||||
result = ethereum.get_public_node(client, address_n, show_display=show_display)
|
||||
return {
|
||||
"node": {
|
||||
"depth": result.node.depth,
|
||||
"fingerprint": "%08x" % result.node.fingerprint,
|
||||
"child_num": result.node.child_num,
|
||||
"chain_code": result.node.chain_code.hex(),
|
||||
"public_key": result.node.public_key.hex(),
|
||||
},
|
||||
"xpub": result.xpub,
|
||||
}
|
||||
|
||||
|
||||
@cli.command(
|
||||
help='Sign (and optionally publish) Ethereum transaction. Use TO as destination address or set TO to "" for contract creation.'
|
||||
)
|
||||
|
@ -30,6 +30,13 @@ def get_address(client, n, show_display=False, multisig=None):
|
||||
return client.call(proto.EthereumGetAddress(address_n=n, show_display=show_display))
|
||||
|
||||
|
||||
@expect(proto.EthereumPublicKey)
|
||||
def get_public_node(client, n, show_display=False):
|
||||
return client.call(
|
||||
proto.EthereumGetPublicKey(address_n=n, show_display=show_display)
|
||||
)
|
||||
|
||||
|
||||
@session
|
||||
def sign_tx(
|
||||
client,
|
||||
|
@ -46,3 +46,7 @@ class TestMsgEthereumGetaddress(TrezorTest):
|
||||
ethereum.get_address(self.client, [H_(44), H_(60), 0, 9999999]).hex()
|
||||
== "6b909b50d88c9a8e02453a87b3662e3e7a5e0cf1"
|
||||
)
|
||||
assert (
|
||||
ethereum.get_address(self.client, [H_(44), H_(6060), 0, 9999999]).hex()
|
||||
== "98b8e926bd224764de2a0e4f4cbe1521474050af"
|
||||
)
|
||||
|
@ -0,0 +1,32 @@
|
||||
# This file is part of the Trezor project.
|
||||
#
|
||||
# Copyright (C) 2012-2018 SatoshiLabs and contributors
|
||||
#
|
||||
# This library is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License version 3
|
||||
# as published by the Free Software Foundation.
|
||||
#
|
||||
# This library is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the License along with this library.
|
||||
# If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
|
||||
|
||||
import pytest
|
||||
|
||||
from trezorlib import ethereum
|
||||
from trezorlib.tools import H_
|
||||
|
||||
from .common import TrezorTest
|
||||
|
||||
|
||||
@pytest.mark.ethereum
|
||||
class TestMsgEthereumGetPublicKey(TrezorTest):
|
||||
def test_ethereum_getpublickey(self):
|
||||
self.setup_mnemonic_nopin_nopassphrase()
|
||||
assert (
|
||||
ethereum.get_public_node(self.client, [H_(44), H_(60), H_(0)]).xpub
|
||||
== "xpub6D54vV8eUYHMVBZCnz4SLjuiQngXURVCGKKGoJrWUDRegdMByLTJKfRs64q3UKiQCsSHJPtCQehTvERczdghS7gb8oedWSyNDtBU1zYDJtb"
|
||||
)
|
Loading…
Reference in New Issue
Block a user