async def _create_or_import_wallet(self): choice = await self.app.prompt( prompt=global_config_map.get("wallet").prompt) if choice == "import": private_key = await self.app.prompt( prompt="Your wallet private key >>> ", is_password=True) password = await self.app.prompt( prompt="A password to protect your wallet key >>> ", is_password=True) try: self.acct = import_and_save_wallet(password, private_key) self.app.log("Wallet %s imported into hummingbot" % (self.acct.address, )) except Exception as e: self.app.log(f"Failed to import wallet key: {e}") result = await self._create_or_import_wallet() return result elif choice == "create": password = await self.app.prompt( prompt="A password to protect your wallet key >>> ", is_password=True) self.acct = create_and_save_wallet(password) self.app.log("New wallet %s created" % (self.acct.address, )) else: self.app.log('Invalid choice. Please enter "create" or "import".') result = await self._create_or_import_wallet() return result return self.acct.address
async def _create_or_import_wallet(self, # type: HummingbotApplication ): """ Special handler function that asks the user to either create a new wallet, or import one by entering the private key. """ choice = await self.app.prompt(prompt=global_config_map.get("wallet").prompt) if choice == "import": private_key = await self.app.prompt(prompt="Your wallet private key >>> ", is_password=True) password = in_memory_config_map["password"].value try: self.acct = import_and_save_wallet(password, private_key) self._notify("Wallet %s imported into hummingbot" % (self.acct.address,)) except Exception as e: self._notify(f"Failed to import wallet key: {e}") result = await self._create_or_import_wallet() return result elif choice == "create": password = in_memory_config_map["password"].value self.acct = create_and_save_wallet(password) self._notify("New wallet %s created" % (self.acct.address,)) else: self._notify('Invalid choice. Please enter "create" or "import".') result = await self._create_or_import_wallet() return result return self.acct.address