Exemplo n.º 1
0
    def create_new_coldkey(self, n_words: int = 12, use_password: bool = True):
        # Create directory
        dir_path = os.path.expanduser(
            os.path.join(self.config.wallet.path, self.config.wallet.name))
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)

        # Create Key
        cli_utils.validate_create_path(self.coldkeyfile)
        self._coldkey = cli_utils.gen_new_key(n_words)
        cli_utils.display_mnemonic_msg(self._coldkey)
        cli_utils.write_pubkey_to_text_file(self.coldkeyfile,
                                            self._coldkey.public_key)

        # Encrypt
        if use_password:
            password = cli_utils.input_password()
            print("Encrypting coldkey ... (this might take a few moments)")
            coldkey_json_data = json.dumps(self._coldkey.toDict()).encode()
            coldkey_data = encrypt(coldkey_json_data, password)
            del coldkey_json_data
        else:
            coldkey_data = json.dumps(self._coldkey.toDict()).encode()

        # Save
        cli_utils.save_keys(self.coldkeyfile, coldkey_data)
        cli_utils.set_file_permissions(self.coldkeyfile)
Exemplo n.º 2
0
    def create_new_hotkey(self, n_words: int = 12, use_password: bool = True):
        # Create directory
        dir_path = os.path.expanduser(
            os.path.join(self.config.wallet.path, self.config.wallet.name,
                         "hotkeys"))
        if not os.path.exists(dir_path):
            os.makedirs(dir_path)

        # Create
        cli_utils.validate_create_path(self.hotkeyfile)
        self._hotkey = cli_utils.gen_new_key(n_words)
        cli_utils.display_mnemonic_msg(self._hotkey)

        # Encrypt
        if use_password:
            password = cli_utils.input_password()
            logger.info(
                "Encrypting hotkey ... (this might take a few moments)")
            hotkey_json_data = json.dumps(self._hotkey.toDict()).encode()
            hotkey_data = encrypt(hotkey_json_data, password)
            del hotkey_json_data
        else:
            hotkey_data = json.dumps(self._hotkey.toDict()).encode()

        # Save
        cli_utils.save_keys(self.hotkeyfile, hotkey_data)
        cli_utils.set_file_permissions(self.hotkeyfile)
Exemplo n.º 3
0
    def create_new_hotkey( self, n_words:int = 12):  
        # Create directory 
        dir_path = os.path.expanduser(self.config.wallet.path + "/" + self.config.wallet.name + "/hotkeys/" )
        if not os.path.exists( dir_path ):
            os.makedirs( dir_path )

        # Create
        hotkey_path = cli_utils.validate_create_path( self.hotkeyfile )
        self._hotkey = cli_utils.gen_new_key( n_words )
        cli_utils.display_mnemonic_msg( self._hotkey )
        hotkey_data = json.dumps(self._hotkey.toDict()).encode()

        # Save
        cli_utils.save_keys( self.hotkeyfile, hotkey_data )
        cli_utils.set_file_permissions( self.hotkeyfile )