示例#1
0
    def regenerate_hotkey(self, mnemonic: str, 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)

        # Regenerate
        cli_utils.validate_create_path(self.hotkeyfile)
        self._hotkey = cli_utils.validate_generate_mnemonic(mnemonic)

        # 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)
示例#2
0
    def regenerate_coldkey(self, mnemonic: str, use_password: bool):
        # 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)

        # Regenerate
        self._coldkey = cli_utils.validate_generate_mnemonic(mnemonic)
        cli_utils.write_pubkey_to_text_file(self.coldkeyfile,
                                            self._coldkey.public_key)

        # Encrypt
        if use_password:
            password = cli_utils.input_password()
            logger.info("Encrypting key ... (this might take a few moments)")
            json_data = json.dumps(self._coldkey.toDict()).encode()
            coldkey_data = encrypt(json_data, password)
            del 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)
示例#3
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()
            logger.info(
                "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)
示例#4
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()
            print("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)
示例#5
0
    def regenerate_hotkey( self, mnemonic: str ):
        # 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 )

        # Regenerate
        self._hotkey = cli_utils.validate_generate_mnemonic( mnemonic )
        
        # Save
        hotkey_data = json.dumps(self._hotkey.toDict()).encode()
        cli_utils.save_keys( self.hotkeyfile, hotkey_data )
        cli_utils.set_file_permissions( self.hotkeyfile )
示例#6
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 )