コード例 #1
0
ファイル: security.py プロジェクト: CoinAlpha/hummingbot
 def decrypt_all(cls):
     cls._secure_configs.clear()
     cls._private_keys.clear()
     cls._decryption_done.clear()
     encrypted_files = list_encrypted_file_paths()
     for file in encrypted_files:
         cls.decrypt_file(file)
     wallets = list_wallets()
     for wallet in wallets:
         cls.unlock_wallet(wallet)
     cls._decryption_done.set()
コード例 #2
0
 async def _one_password_config(
         self,  # type: HummingbotApplication
 ):
     """
     Special handler function to handle one password unlocking all secure conf variable and wallets
         - let a user creates a new password if there is no existing encrypted_files or key_files.
         - verify the entered password is valid by trying to unlock files.
     """
     encrypted_files = list_encrypted_file_paths()
     wallets = list_wallets()
     password_valid = False
     err_msg = "Invalid password, please try again."
     if not encrypted_files and not wallets:
         password = await self.app.prompt(
             prompt="Enter your new password >>> ", is_password=True)
         re_password = await self.app.prompt(
             prompt="Please reenter your password >>> ", is_password=True)
         if password == re_password:
             password_valid = True
         else:
             err_msg = "Passwords entered do not match, please try again."
     else:
         password = await self.app.prompt(prompt="Enter your password >>> ",
                                          is_password=True)
         if encrypted_files:
             try:
                 decrypt_file(encrypted_files[0], password)
                 password_valid = True
             except ValueError as err:
                 if str(err) != "MAC mismatch":
                     raise err
         else:
             for wallet in wallets:
                 try:
                     unlock_wallet(public_key=wallet, password=password)
                     password_valid = True
                     break
                 except ValueError as err:
                     if str(err) != "MAC mismatch":
                         raise err
     if password_valid:
         return password
     else:
         self._notify(err_msg)
         return await self._one_password_config()
コード例 #3
0
 async def list_encrypted(
         self,  # type: HummingbotApplication
 ):
     encrypted_files = list_encrypted_file_paths()
     if len(encrypted_files) == 0:
         self._notify("There is no encrypted file in your conf folder.")
         return
     self.placeholder_mode = True
     self.app.toggle_hide_input()
     in_memory_config_map.get(
         "password").value = await self._one_password_config()
     password = in_memory_config_map.get("password").value
     coro = AsyncCallScheduler.shared_instance().call_async(
         partial(self._list_all_encrypted, encrypted_files, password),
         timeout_seconds=30)
     safe_ensure_future(coro)
     self.app.change_prompt(prompt=">>> ")
     self.app.toggle_hide_input()
     self.placeholder_mode = False
コード例 #4
0
ファイル: security.py プロジェクト: vinhtran91/beaxy-bot
 def login(cls, password):
     encrypted_files = list_encrypted_file_paths()
     wallets = list_wallets()
     if encrypted_files:
         try:
             decrypt_file(encrypted_files[0], password)
         except ValueError as err:
             if str(err) == "MAC mismatch":
                 return False
             raise err
     elif wallets:
         try:
             unlock_wallet(wallets[0], password)
         except ValueError as err:
             if str(err) == "MAC mismatch":
                 return False
             raise err
     Security.password = password
     coro = AsyncCallScheduler.shared_instance().call_async(cls.decrypt_all, timeout_seconds=30)
     safe_ensure_future(coro)
     return True
コード例 #5
0
ファイル: security.py プロジェクト: CoinAlpha/hummingbot
 def any_encryped_files():
     encrypted_files = list_encrypted_file_paths()
     return len(encrypted_files) > 0
コード例 #6
0
ファイル: security.py プロジェクト: CoinAlpha/hummingbot
 def new_password_required():
     encrypted_files = list_encrypted_file_paths()
     wallets = list_wallets()
     return len(encrypted_files) == 0 and len(wallets) == 0