コード例 #1
0
    def test_initialise_from_mnemonic(self, private_key, mnemonic, env):

        wallet = Wallet.create_wallet_from_mnemonic(mnemonic, env=env)

        assert wallet.private_key == private_key
        assert wallet.public_key_hex == b'02cce2ee4e37dc8c65d6445c966faf31ebfe578a90695138947ee7cab8ae9a2c08'
        assert wallet.address == 'tbnb10a6kkxlf823w9lwr6l9hzw4uyphcw7qzrud5rr'
コード例 #2
0
    def __init__(self, wallet_settings: WalletSettings):

        self._settings = wallet_settings

        w_env = BinanceEnvironment.get_production_env()
        if wallet_settings.env_name == 'TESTNET':
            w_env = BinanceEnvironment.get_testnet_env()

        if wallet_settings.private_key:
            log_init_type = 'private_key'
            self._wallet = Wallet(private_key=wallet_settings.private_key.get_secret_value(), env=w_env)
        elif wallet_settings.mnemonic:
            log_init_type = 'mnemonic'
            self._wallet = Wallet.create_wallet_from_mnemonic(wallet_settings.mnemonic.get_secret_value(), env=w_env)
        else:
            raise Exception(f"Unable to initialise wallet {wallet_settings.name} no private_key or mnemonic set")

        self._http_client: Optional[AsyncHttpApiClient] = None

        logging.info(f"Initialised wallet {wallet_settings.name} with {log_init_type}")