def create_account_from_wif(self, wif: str, password: str, label: str = '') -> Account: private_key = Account.get_private_key_from_wif(wif).hex() salt = get_random_hex_str(16) if len(label) == 0 or label is None: label = uuid.uuid4().hex[0:8] info = self.create_account_info(label, password, salt, private_key) return self.get_account_by_b58_address(info.address_base58, password)
def test_get_private_key_from_wif(self): hex_private_key = utils.get_random_bytes(32).hex() acct = Account(hex_private_key) wif = acct.export_wif() import_key = Account.get_private_key_from_wif(wif) self.assertEqual(hex_private_key, import_key.hex())