Bitcoin Forum
April 25, 2024, 05:03:33 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Can't import keys - unexpected token 'importprivkey'  (Read 164 times)
webchris (OP)
Member
**
Offline Offline

Activity: 142
Merit: 10


View Profile WWW
December 23, 2017, 04:22:12 AM
 #1

I have exported/dumped private keys from multiple wallets and I'm trying to import them into one wallet. There are too many to do them one at a time. I am attempting to import them using a batch file but it seems "importprivkey" is not part of the bitcoind daemon anymore, or I am missing something.

I am running Bitcoin Core 0.15.1.

My batch file looks like this:

Code:
"C:\Program Files\Bitcoin\daemon\bitcoind.exe" importprivkey MYPRIVATEKEYHERE label-1 false
"C:\Program Files\Bitcoin\daemon\bitcoind.exe" importprivkey MYPRIVATEKEYHERE label-2 false

The error I get is:
Error: Command line contains unexpected token 'importprivkey', see bitcoind -h for a list of options.


When I try bitcoind -h I see no importprivkey option anywhere.

Any help would be greatly appreciated!

Join a Safe Shared LUX Masternode -> https://www.luxmasternode.com
The forum was founded in 2009 by Satoshi and Sirius. It replaced a SourceForge forum.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
December 23, 2017, 06:01:23 AM
 #2

bitcoind is not the program to interact with Bitcoin Core from the command line. You want to use bitcoin-cli instead.

webchris (OP)
Member
**
Offline Offline

Activity: 142
Merit: 10


View Profile WWW
December 23, 2017, 06:51:06 PM
 #3

Thanks for the reply! So I switched my batch file to use bitcoin-cli instead of bitcoind and I'm no longer getting the errors as before. Though, it doesn't actually add keys to my Bitcoin Core wallet. I'm clearly missing a step.

So here's what I'm doing. I have Bitcoin Core on my Windows PC. I have tried this with it closed and open, same results. I have to run bitcoind in one command prompt (to get bitcoin-cli to work). I run a command like this in a batch:

Code:
"C:\Program Files\Bitcoin\daemon\bitcoin-cli.exe" importprivkey "MYKEYHERE" "label1" false

It gives no error. When I open/check Bitcoin Core, there are no additional addresses added. I know I could add them individually using Core's console, but I need a batch file since I have many addresses to add and wouldn't be able to do them one-by-one.

Join a Safe Shared LUX Masternode -> https://www.luxmasternode.com
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
December 23, 2017, 07:09:10 PM
 #4

I have to run bitcoind in one command prompt (to get bitcoin-cli to work).
Yes, you must have Bitcoin Core (bitcoind or bitcoin-qt) running in order for bitcoin-cli to work. It is a tool that interacts with Bitcoin Core through the command line.

When I open/check Bitcoin Core, there are no additional addresses added.
Where are checking to see if there are addresses?

I know I could add them individually using Core's console, but I need a batch file since I have many addresses to add and wouldn't be able to do them one-by-one.
You could use the importmulti command instead. That allows you to import multiple things (private keys, addresses, etc.) in one command.

webchris (OP)
Member
**
Offline Offline

Activity: 142
Merit: 10


View Profile WWW
December 23, 2017, 07:20:32 PM
 #5

Where are checking to see if there are addresses?

When I open Core, I check "File / Sending Address" and "File / Receiving Addresses".

So this is interesting. I dumped my wallet using the command line (bitcoin-cli) and it shows my newly added keys. So I tested adding more and dumping, and they are adding. But, my wallet.dat file has not been modified (size and data modified unchanged). Is it possible bitcoin-cli is accessing/editing a different wallet than Bitcoin Core GUI?

Join a Safe Shared LUX Masternode -> https://www.luxmasternode.com
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 3374
Merit: 6535


Just writing some code


View Profile WWW
December 23, 2017, 07:26:05 PM
 #6

Is it possible bitcoin-cli is accessing/editing a different wallet than Bitcoin Core GUI?
No, bitcoin-cli does not access anything. It interacts with bitcoind or bitcoin-qt so it "accesses" whatever the running instance of one of this is using.

It is possible that bitcoind is accessing a different wallet from bitcoin-qt. The first time you ran bitcoin-qt, it should have asked you to choose a data directory. If you have changed it from the default, then your wallet file and all of the blockchain data will not be in the default datadir. However if you start bitcoind without the -datadir option, then it will use the default datadir which means that it will be using a different wallet and downloading the blockchain again. To check your datadir, open bitcoin-qt and go to Help > Debug Console > Information. It will say what the datadir is. If it is not C:\Users\<username>\AppData\Roaming\Bitcoin, then you are using a custom datadir and when you use bitcoind it will not be using that datadir.

If you are using a custom datadir, bitcoin-cli will need to have the -datadiir option set so that it also uses the same datadir to get the information it needs in order to access Bitcoin Core's RPC server.

webchris (OP)
Member
**
Offline Offline

Activity: 142
Merit: 10


View Profile WWW
December 24, 2017, 03:16:35 PM
 #7

Thank you achow101! That was my problem. When I installed Bitcoin Core I set the data dir to a custom directory. When I run bitcoind, it uses the default directory in C:\Users.

Join a Safe Shared LUX Masternode -> https://www.luxmasternode.com
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!