Ejemplo n.º 1
0
 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
Ejemplo n.º 2
0
 async def export_keys(self,  # type: HummingbotApplication
                       ):
     await Security.wait_til_decryption_done()
     if not Security.any_secure_configs():
         self.notify("There are no keys to export.")
         return
     self.placeholder_mode = True
     self.app.hide_input = True
     if await self.check_password():
         self.notify("\nWarning: Never disclose API keys or private keys. Anyone with your keys can steal any "
                     "assets held in your account.")
         self.notify("\nAPI keys:")
         for key, cm in Security.all_decrypted_values().items():
             for el in cm.traverse(secure=False):
                 if el.client_field_data is not None and el.client_field_data.is_secure:
                     self.notify(f"{el.attr}: {el.printable_value}")
     self.app.change_prompt(prompt=">>> ")
     self.app.hide_input = False
     self.placeholder_mode = False
 async def _test_existing_password(self):
     # check the 2 encrypted files exist
     self.assertTrue(
         os.path.exists(f"{temp_folder}encrypted_test_key_1.json"))
     self.assertTrue(
         os.path.exists(f"{temp_folder}encrypted_test_key_2.json"))
     self.assertTrue(Security.any_encryped_files())
     self.assertFalse(Security.new_password_required())
     # login fails with incorrect password
     result = Security.login("b")
     self.assertFalse(result)
     # login passes with correct password
     result = Security.login("a")
     self.assertTrue(result)
     # right after logging in, the decryption shouldn't finished yet
     self.assertFalse(Security.is_decryption_done())
     await Security.wait_til_decryption_done()
     self.assertEqual(len(Security.all_decrypted_values()), 2)
     config_value = Security.decrypted_value("test_key_1")
     self.assertEqual("test_value_1", config_value)
     Security.update_secure_config("test_key_1", "new_value")
     self.assertEqual("new_value", Security.decrypted_value("test_key_1"))