コード例 #1
0
 def test_new_password_process(self):
     # empty folder, new password is required
     self.assertFalse(Security.any_encryped_files())
     self.assertTrue(Security.new_password_required())
     # login will pass with any password
     result = Security.login("a")
     self.assertTrue(result)
     Security.update_secure_config("new_key", "new_value")
     self.assertTrue(os.path.exists(f"{temp_folder}encrypted_new_key.json"))
     self.assertTrue(Security.encrypted_file_exists("new_key"))
コード例 #2
0
 async def connection_df(self  # type: HummingbotApplication
                         ):
     columns = [
         "Exchange", "  Keys Added", "  Keys Confirmed",
         "  Connector Status"
     ]
     data = []
     failed_msgs = {}
     network_timeout = float(
         global_config_map["other_commands_timeout"].value)
     try:
         err_msgs = await asyncio.wait_for(
             UserBalances.instance().update_exchanges(reconnect=True),
             network_timeout)
     except asyncio.TimeoutError:
         self._notify(
             "\nA network error prevented the connection table to populate. See logs for more details."
         )
         raise
     for option in sorted(OPTIONS):
         keys_added = "No"
         keys_confirmed = 'No'
         status = get_connector_status(option)
         if option == "ethereum":
             eth_address = global_config_map["ethereum_wallet"].value
             if eth_address is not None and eth_address in Security.private_keys(
             ):
                 keys_added = "Yes"
                 err_msg = UserBalances.validate_ethereum_wallet()
                 if err_msg is not None:
                     failed_msgs[option] = err_msg
                 else:
                     keys_confirmed = 'Yes'
         elif option == "celo":
             celo_address = global_config_map["celo_address"].value
             if celo_address is not None and Security.encrypted_file_exists(
                     "celo_password"):
                 keys_added = "Yes"
                 err_msg = await self.validate_n_connect_celo(True)
                 if err_msg is not None:
                     failed_msgs[option] = err_msg
                 else:
                     keys_confirmed = 'Yes'
         else:
             api_keys = (await Security.api_keys(option)).values()
             if len(api_keys) > 0:
                 keys_added = "Yes"
                 err_msg = err_msgs.get(option)
                 if err_msg is not None:
                     failed_msgs[option] = err_msg
                 else:
                     keys_confirmed = 'Yes'
         data.append([option, keys_added, keys_confirmed, status])
     return pd.DataFrame(data=data, columns=columns), failed_msgs
コード例 #3
0
 async def connect_exchange(self,  # type: HummingbotApplication
                            exchange):
     self.app.clear_input()
     self.placeholder_mode = True
     self.app.hide_input = True
     if exchange == "kraken":
         self._notify("Reminder: Please ensure your Kraken API Key Nonce Window is at least 10.")
     exchange_configs = [c for c in global_config_map.values()
                         if c.key in settings.CONNECTOR_SETTINGS[exchange].config_keys and c.is_connect_key]
     to_connect = True
     if Security.encrypted_file_exists(exchange_configs[0].key):
         await Security.wait_til_decryption_done()
         api_key_config = [c for c in exchange_configs if "api_key" in c.key]
         if api_key_config:
             api_key_config = api_key_config[0]
             api_key = Security.decrypted_value(api_key_config.key)
             prompt = f"Would you like to replace your existing {exchange} API key {api_key} (Yes/No)? >>> "
         else:
             prompt = f"Would you like to replace your existing {exchange_configs[0].key} (Yes/No)? >>> "
         answer = await self.app.prompt(prompt=prompt)
         if self.app.to_stop_config:
             self.app.to_stop_config = False
             return
         if answer.lower() not in ("yes", "y"):
             to_connect = False
     if to_connect:
         for config in exchange_configs:
             await self.prompt_a_config(config)
             if self.app.to_stop_config:
                 self.app.to_stop_config = False
                 return
             Security.update_secure_config(config.key, config.value)
         api_keys = await Security.api_keys(exchange)
         network_timeout = float(global_config_map["other_commands_timeout"].value)
         try:
             err_msg = await asyncio.wait_for(
                 UserBalances.instance().add_exchange(exchange, **api_keys), network_timeout
             )
         except asyncio.TimeoutError:
             self._notify("\nA network error prevented the connection to complete. See logs for more details.")
             self.placeholder_mode = False
             self.app.hide_input = False
             self.app.change_prompt(prompt=">>> ")
             raise
         if err_msg is None:
             self._notify(f"\nYou are now connected to {exchange}.")
         else:
             self._notify(f"\nError: {err_msg}")
     self.placeholder_mode = False
     self.app.hide_input = False
     self.app.change_prompt(prompt=">>> ")
コード例 #4
0
ファイル: connect_command.py プロジェクト: vyfirm/hummingbot
 async def connect_exchange(
         self,  # type: HummingbotApplication
         exchange):
     self.app.clear_input()
     self.placeholder_mode = True
     self.app.hide_input = True
     if exchange == "kraken":
         self._notify(
             "Reminder: Please ensure your Kraken API Key Nonce Window is at least 10."
         )
     exchange_configs = [
         c for c in global_config_map.values()
         if c.key in settings.CONNECTOR_SETTINGS[exchange].config_keys
         and c.is_connect_key
     ]
     to_connect = True
     if Security.encrypted_file_exists(exchange_configs[0].key):
         await Security.wait_til_decryption_done()
         api_key_config = [
             c for c in exchange_configs if "api_key" in c.key
         ][0]
         api_key = Security.decrypted_value(api_key_config.key)
         answer = await self.app.prompt(
             prompt=
             f"Would you like to replace your existing {exchange} API key "
             f"{api_key} (Yes/No)? >>> ")
         if self.app.to_stop_config:
             self.app.to_stop_config = False
             return
         if answer.lower() not in ("yes", "y"):
             to_connect = False
     if to_connect:
         for config in exchange_configs:
             await self.prompt_a_config(config)
             if self.app.to_stop_config:
                 self.app.to_stop_config = False
                 return
             Security.update_secure_config(config.key, config.value)
         api_keys = await Security.api_keys(exchange)
         err_msg = await UserBalances.instance().add_exchange(
             exchange, **api_keys)
         if err_msg is None:
             self._notify(f"\nYou are now connected to {exchange}.")
         else:
             self._notify(f"\nError: {err_msg}")
     self.placeholder_mode = False
     self.app.hide_input = False
     self.app.change_prompt(prompt=">>> ")
コード例 #5
0
 async def connection_df(self  # type: HummingbotApplication
                         ):
     columns = [
         "Exchange", "  Keys Added", "  Keys Confirmed",
         "  Connector Status"
     ]
     data = []
     failed_msgs = {}
     err_msgs = await UserBalances.instance().update_exchanges(
         reconnect=True)
     for option in sorted(OPTIONS):
         keys_added = "No"
         keys_confirmed = 'No'
         status = get_connector_status(option)
         if option == "ethereum":
             eth_address = global_config_map["ethereum_wallet"].value
             if eth_address is not None and eth_address in Security.private_keys(
             ):
                 keys_added = "Yes"
                 err_msg = UserBalances.validate_ethereum_wallet()
                 if err_msg is not None:
                     failed_msgs[option] = err_msg
                 else:
                     keys_confirmed = 'Yes'
         elif option == "celo":
             celo_address = global_config_map["celo_address"].value
             if celo_address is not None and Security.encrypted_file_exists(
                     "celo_password"):
                 keys_added = "Yes"
                 err_msg = await self.validate_n_connect_celo(True)
                 if err_msg is not None:
                     failed_msgs[option] = err_msg
                 else:
                     keys_confirmed = 'Yes'
         else:
             api_keys = (await Security.api_keys(option)).values()
             if len(api_keys) > 0:
                 keys_added = "Yes"
                 err_msg = err_msgs.get(option)
                 if err_msg is not None:
                     failed_msgs[option] = err_msg
                 else:
                     keys_confirmed = 'Yes'
         data.append([option, keys_added, keys_confirmed, status])
     return pd.DataFrame(data=data, columns=columns), failed_msgs
コード例 #6
0
 async def connect_exchange(
         self,  # type: HummingbotApplication
         exchange):
     self.app.clear_input()
     self.placeholder_mode = True
     self.app.hide_input = True
     exchange_configs = [
         c for c in global_config_map.values()
         if exchange in c.key and c.is_connect_key
     ]
     to_connect = True
     if Security.encrypted_file_exists(exchange_configs[0].key):
         await Security.wait_til_decryption_done()
         api_key_config = [
             c for c in exchange_configs if "api_key" in c.key
         ][0]
         api_key = Security.decrypted_value(api_key_config.key)
         answer = await self.app.prompt(
             prompt=
             f"Would you like to replace your existing {exchange} API key "
             f"...{api_key[-4:]} (Yes/No)? >>> ")
         if answer.lower() not in ("yes", "y"):
             to_connect = False
     if to_connect:
         for config in exchange_configs:
             await self.prompt_a_config(config)
             Security.update_secure_config(config.key, config.value)
         api_keys = (await Security.api_keys(exchange)).values()
         err_msg = await UserBalances.instance().add_exchange(
             exchange, *api_keys)
         if err_msg is None:
             self._notify(f"\nYou are now connected to {exchange}.")
         else:
             self._notify(f"\nError: {err_msg}")
     self.placeholder_mode = False
     self.app.hide_input = False
     self.app.change_prompt(prompt=">>> ")