def test_ethereum_getaddress(self): self.setup_mnemonic_nopin_nopassphrase() assert (hexlify(ethereum.get_address( self.client, [])) == b"1d1c328764a41bda0492b66baa30c4a339ff85ef") assert (hexlify(ethereum.get_address( self.client, [1])) == b"437207ca3cf43bf2e47dea0756d736c5df4f597a") assert (hexlify(ethereum.get_address( self.client, [0, H_(1)])) == b"e5d96dfa07bcf1a3ae43677840c31394258861bf") assert (hexlify(ethereum.get_address( self.client, [H_(9), 0])) == b"f68804ac9eca9483ab4241d3e4751590d2c05102") assert (hexlify(ethereum.get_address( self.client, [0, 9999999])) == b"7a6366ecfcaf0d5dcc1539c171696c6cdd1eb8ed")
def __derive_account(self, index: int = None, hd_path: Address = None) -> str: """Resolves a trezorlib HD path into a checksum address and returns it.""" if not hd_path: if index is None: raise ValueError("No index or HD path supplied.") # TODO: better error handling here hd_path = self.__get_address_path(index=index) address = ethereum.get_address(client=self.__client, n=hd_path, show_display=False) # TODO: show display? return address
def test_ethereum_getaddress(self, client): assert ( ethereum.get_address(client, [H_(44), H_(60)]) == "0xE025dfbE2C53638E547C6487DED34Add7b8Aafc1" ) assert ( ethereum.get_address(client, [H_(44), H_(60), 1]) == "0xeD46C856D0c79661cF7d40FFE0C0C5077c00E898" ) assert ( ethereum.get_address(client, [H_(44), H_(60), 0, H_(1)]) == "0x6682Fa7F3eC58581b1e576268b5463B4b5c93839" ) assert ( ethereum.get_address(client, [H_(44), H_(60), H_(9), 0]) == "0xFb3BE0F9717fF5fCF3C58EB49a9Ed67F1BD89D4E" ) assert ( ethereum.get_address(client, [H_(44), H_(60), 0, 9999999]) == "0x6b909b50d88c9A8E02453A87b3662E3e7a5E0CF1" ) assert ( ethereum.get_address(client, [H_(44), H_(6060), 0, 9999999]) == "0x98b8e926bd224764De2A0E4f4CBe1521474050AF" ) # Wanchain SLIP44 id assert ( ethereum.get_address(client, [H_(44), H_(5718350), H_(0)]) == "0x4d643B1b556E14A27143a38bcE61230FFf5AFca8" )
def test_ethereum_getaddress(self): self.setup_mnemonic_nopin_nopassphrase() assert ( ethereum.get_address(self.client, [H_(44), H_(60)]) == "0xE025dfbE2C53638E547C6487DED34Add7b8Aafc1" ) assert ( ethereum.get_address(self.client, [H_(44), H_(60), 1]) == "0xeD46C856D0c79661cF7d40FFE0C0C5077c00E898" ) assert ( ethereum.get_address(self.client, [H_(44), H_(60), 0, H_(1)]) == "0x6682Fa7F3eC58581b1e576268b5463B4b5c93839" ) assert ( ethereum.get_address(self.client, [H_(44), H_(60), H_(9), 0]) == "0xFb3BE0F9717fF5fCF3C58EB49a9Ed67F1BD89D4E" ) assert ( ethereum.get_address(self.client, [H_(44), H_(60), 0, 9999999]) == "0x6b909b50d88c9A8E02453A87b3662E3e7a5E0CF1" ) assert ( ethereum.get_address(self.client, [H_(44), H_(6060), 0, 9999999]) == "0x98b8e926bd224764De2A0E4f4CBe1521474050AF" )
def test_ethereum_getaddress(self): self.setup_mnemonic_nopin_nopassphrase() assert (ethereum.get_address( self.client, [H_(44), H_(60) ]).hex() == "e025dfbe2c53638e547c6487ded34add7b8aafc1") assert (ethereum.get_address( self.client, [H_(44), H_(60), 1 ]).hex() == "ed46c856d0c79661cf7d40ffe0c0c5077c00e898") assert (ethereum.get_address( self.client, [H_(44), H_(60), 0, H_(1) ]).hex() == "6682fa7f3ec58581b1e576268b5463b4b5c93839") assert (ethereum.get_address( self.client, [H_(44), H_(60), H_(9), 0 ]).hex() == "fb3be0f9717ff5fcf3c58eb49a9ed67f1bd89d4e") assert (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")
def unlock_trezor(self, device_path, derivation_path): """Unlock a Trezor for signing transactions to this network. :param device_path: Device path of the Trezor :param derivation_path: Derivation path of the key to use :return: True if success, else False """ try: device = get_transport(device_path, prefix_search=False) except Exception: try: device = get_transport(device_path, prefix_search=True) except Exception: logger.exception('Failed to find Trezor device on path %s', device_path) return False self.trezor = TrezorClient(transport=device, ui=ClickUI()) self.address_n = parse_path(derivation_path) self.address = self.normalize_address( trezoreth.get_address(self.trezor, self.address_n).hex()) return True
def test_ethereum_getaddress(self): self.setup_mnemonic_nopin_nopassphrase() assert (ethereum.get_address( self.client, [H_(44), H_(60)]) == "0xE025dfbE2C53638E547C6487DED34Add7b8Aafc1") assert (ethereum.get_address( self.client, [H_(44), H_(60), 1 ]) == "0xeD46C856D0c79661cF7d40FFE0C0C5077c00E898") assert (ethereum.get_address( self.client, [H_(44), H_(60), 0, H_(1) ]) == "0x6682Fa7F3eC58581b1e576268b5463B4b5c93839") assert (ethereum.get_address( self.client, [H_(44), H_(60), H_(9), 0 ]) == "0xFb3BE0F9717fF5fCF3C58EB49a9Ed67F1BD89D4E") assert (ethereum.get_address( self.client, [H_(44), H_(60), 0, 9999999 ]) == "0x6b909b50d88c9A8E02453A87b3662E3e7a5E0CF1") assert (ethereum.get_address( self.client, [H_(44), H_(6060), 0, 9999999 ]) == "0x98b8e926bd224764De2A0E4f4CBe1521474050AF")
def test_getaddress(client: Client, parameters, result): address_n = parse_path(parameters["path"]) assert ethereum.get_address(client, address_n) == result["address"]
device = get_transport() client = TrezorClient(transport=device, ui=ui.ClickUI()) fw = client.features fw_min = min_version[fw.model] py_min = (3,6,0) tl_min = [0,12,0] if (fw_min > (fw.major_version, fw.minor_version,fw.patch_version) or tl_min > [int(i) for i in lib_version.split('.')] or py_min > py_ver): m = "Requires at least Python rev {}, trezorlib rev {}, and FW rev {}" print(m.format(py_min, tl_min, fw_min)) exit(1) w3 = Web3() address_n = tools.parse_path(address) from_address = ethereum.get_address(client, address_n) if token_address: #ERC20 KungFu min_abi = [ { "name": "transfer", "type": "function", "constant": False, "inputs": [ {"name": "_to", "type": "address"}, {"name": "_value", "type": "uint256"}, ], "outputs": [{"name": "", "type": "bool"}], } ] contract = w3.eth.contract(address=token_address, abi=min_abi)
def test_ethereum_getaddress(client, path, address): address_n = parse_path(path) assert ethereum.get_address(client, address_n) == address