2024-01-26 11:16:55 +00:00
|
|
|
from common import * # isort:skip
|
2019-07-31 15:02:41 +00:00
|
|
|
|
|
|
|
from trezor.crypto.curve import secp256k1
|
|
|
|
|
2019-08-26 16:47:49 +00:00
|
|
|
if not utils.BITCOIN_ONLY:
|
2020-09-23 10:31:07 +00:00
|
|
|
from apps.binance.helpers import address_from_public_key
|
2019-08-26 16:47:49 +00:00
|
|
|
|
|
|
|
|
|
|
|
@unittest.skipUnless(not utils.BITCOIN_ONLY, "altcoin")
|
2019-07-31 15:02:41 +00:00
|
|
|
class TestBinanceAddress(unittest.TestCase):
|
|
|
|
def test_privkey_to_address(self):
|
2023-06-28 10:46:29 +00:00
|
|
|
# source of test data - binance javascript SDK
|
2019-07-31 15:02:41 +00:00
|
|
|
privkey = "90335b9d2153ad1a9799a3ccc070bd64b4164e9642ee1dd48053c33f9a3a05e9"
|
|
|
|
expected_address = "tbnb1hgm0p7khfk85zpz5v0j8wnej3a90w709zzlffd"
|
|
|
|
|
|
|
|
pubkey = secp256k1.publickey(unhexlify(privkey), True)
|
|
|
|
address = address_from_public_key(pubkey, "tbnb")
|
|
|
|
|
|
|
|
self.assertEqual(address, expected_address)
|
|
|
|
|
|
|
|
|
2023-06-28 10:46:29 +00:00
|
|
|
if __name__ == "__main__":
|
2019-07-31 15:02:41 +00:00
|
|
|
unittest.main()
|