async def export_keys( self, # type: HummingbotApplication ): if not Security.any_encryped_files() and not Security.any_wallets(): self._notify("There are no keys to export.") return await Security.wait_til_decryption_done() self.placeholder_mode = True self.app.hide_input = True if await self.check_password(): await Security.wait_til_decryption_done() self._notify( "\nWarning: Never disclose API keys or private keys. Anyone with your keys can steal any " "assets held in your account.") if Security.all_decrypted_values(): self._notify("\nAPI keys:") for key, value in Security.all_decrypted_values().items(): self._notify(f"{key}: {value}") if Security.private_keys(): self._notify("\nEthereum wallets:") for key, value in Security.private_keys().items(): self._notify( f"Public address: {key}\nPrivate Key: {value.hex()}") self.app.change_prompt(prompt=">>> ") self.app.hide_input = False self.placeholder_mode = False
async def connection_df(self # type: HummingbotApplication ): columns = ["Exchange", " Keys Added", " Keys Confirmed"] data = [] failed_msgs = {} err_msgs = await UserBalances.instance().update_exchanges( reconnect=True) for option in sorted(OPTIONS): keys_added = "No" keys_confirmed = 'No' 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' 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]) return pd.DataFrame(data=data, columns=columns), failed_msgs
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
def validate_ethereum_wallet() -> Optional[str]: if global_config_map.get("ethereum_wallet").value is None: return "Ethereum wallet is required." if global_config_map.get("ethereum_rpc_url").value is None: return "ethereum_rpc_url is required." if global_config_map.get("ethereum_wallet").value not in Security.private_keys(): return "Ethereum private key file does not exist or corrupts." try: UserBalances.ethereum_balance() except Exception as e: return str(e) return None