BitShares Forum

Main => General Discussion => Topic started by: clayop on October 04, 2014, 06:35:42 am

Title: How to import account to CLI client?
Post by: clayop on October 04, 2014, 06:35:42 am
I attempted to "wallet_import_private_key [PrivKey] [account name]" but it gave me the error message as follow,

current_account.valid(): You must create an account before importing a key

How can I resolve this problem? Any clues?
Title: Re: How to import account to CLI client?
Post by: pc on October 04, 2014, 08:07:35 am
wallet_import_private_key has 4 arguments:
Code: [Select]
(wallet closed) >>> help wallet_import_private_key
Usage:
wallet_import_private_key <wif_key> [account_name] [create_new_account] [rescan]
Loads the private key into the specified account. Returns which account it was actually imported to.

Parameters:
  wif_key (wif_private_key, required): A private key in bitcoin Wallet Import Format (WIF)
  account_name (account_name, optional, defaults to null): the name of the account the key should be imported into, if null then the key must belong to an active account
  create_new_account (bool, optional, defaults to false): If true, the wallet will attempt to create a new account for the name provided rather than import the key into an existing account
  rescan (bool, optional, defaults to false): If true, the wallet will rescan the blockchain looking for transactions that involve this private key


So, to import the key into an existing account you have to do what you have already tried.
If you want to create a new account with an existing key, you have to set the third argument to true (and usually also the fourth).
Title: Re: How to import account to CLI client?
Post by: clayop on October 04, 2014, 05:20:40 pm
wallet_import_private_key has 4 arguments:
Code: [Select]
(wallet closed) >>> help wallet_import_private_key
Usage:
wallet_import_private_key <wif_key> [account_name] [create_new_account] [rescan]
Loads the private key into the specified account. Returns which account it was actually imported to.

Parameters:
  wif_key (wif_private_key, required): A private key in bitcoin Wallet Import Format (WIF)
  account_name (account_name, optional, defaults to null): the name of the account the key should be imported into, if null then the key must belong to an active account
  create_new_account (bool, optional, defaults to false): If true, the wallet will attempt to create a new account for the name provided rather than import the key into an existing account
  rescan (bool, optional, defaults to false): If true, the wallet will rescan the blockchain looking for transactions that involve this private key


So, to import the key into an existing account you have to do what you have already tried.
If you want to create a new account with an existing key, you have to set the third argument to true (and usually also the fourth).

Great thanks!!!
Title: Re: How to import account to CLI client?
Post by: clayop on October 04, 2014, 08:29:33 pm
One more problem... I successfully import my account, but it seems not to be synced. (I import registered account but my account information reports that the account is not registered.
Title: Re: How to import account to CLI client?
Post by: Riverhead on October 04, 2014, 08:39:35 pm
Did you try wallet_account_register?
Title: Re: How to import account to CLI client?
Post by: clayop on October 04, 2014, 08:47:37 pm
Yes, but it doesn't work.

The situation is:
-I have one windows GUI wallet and one linux CLI wallet.
-Both have the same account with the same public Key
-While the account on windows GUI is registered, the account on linux CLI is not registered.

Bug??
Title: Re: How to import account to CLI client?
Post by: Riverhead on October 04, 2014, 08:52:44 pm
Try doing a wallet_regenerate_keys. It should be registered.
Title: Re: How to import account to CLI client?
Post by: clayop on October 04, 2014, 09:13:21 pm
Try doing a wallet_regenerate_keys. It should be registered.

I found the problem... I was on the wrong version. (Although I followed the instruction. Do I have to more?)

Here are commands I did

Code: [Select]
sudo apt-get update
sudo apt-get install cmake git libreadline-dev uuid-dev g++ libdb++-dev libdb-dev zip libssl-dev openssl build-essential python-dev autotools-dev libicu-dev libbz2-dev libboost-dev libboost-all-dev
git clone https://github.com/dacsunlimited/bitsharesx.git
cd bitsharesx
git submodule init
git submodule update
cmake .
make