Bitcoind and bitcoin-cli Assignment

Welcome to this assignment. Try to complete the tasks below. Feel free to discuss and ask questions in this thread.

  1. We have already used some commands in previous lectures, let’s find them in the list and verify how they are described. Can you find getnewaddress and getbalance in the list? Does the description fir what the commands do?
  2. Try to execute dumpwallet in order to store keys in a file.
  3. Try to execute dumpprivkey on an address you generated with getnewaddress.
1 Like
  1. We have already used some commands in previous lectures, let’s find them in the list and verify how they are described. Can you find getnewaddress and getbalance in the list? Does the description fir what the commands do?

    The description confirms what the commands do but also specify extra parameters to use with the commands.

    also with the following line you can get info about any command:
    ./bitcoin-cli -regtest help <command>
    for ex: ./bitcoin-cli -regtest help getbalance

  2. Try to execute dumpwallet in order to store keys in a file.
    ./bitcoin-cli -regtest dumpwallet "<path and filename>"

  3. Try to execute dumpprivkey on an address you generated with getnewaddress.
    ./bitcoin-cli -regtest dumpprivkey <address>

1 Like

1. We have already used some commands in previous lectures, let’s find them in the list and verify how they are described. Can you find getnewaddress and getbalance in the list? Does the description fit what the commands do?

They’re listed alphabetically and the description does match the action.

2. Try to execute dumpwallet in order to store keys in a file.
./bitcoin-cli -regtest dumpwallet “mykeys”

3. Try to execute dumpprivkey on an address you generated with getnewaddress.
./bitcoin-cli -regtest dumpprivkey [address]

@Capaburro listed a help feature which is very… well… helpful. Thanks

Even though the dumpwallet command was executed and even when run a second time provides information that the file exists and cannot be overwritten, I cannot find the actual file in the /daemon directory… strange. Any suggestion??

  1. Yes they’re on the list with extra description about using an optional [account] parameter.

  2. > .\bitcoin-cli.exe -regtest dumpwallet "test_dumped_keys" The dumped file test_dumped_keys has a long list of the keys, around 2000 in fact, probably pre-generated by the -regtest mode.

  3. The private key is successfully printed to the console

> .\bitcoin-cli.exe -regtest getnewaddress
2N7CmzJhfLkD3bejEkZZgLqNGZv9PJGuXLm
> .\bitcoin-cli.exe -regtest dumpprivkey 2N7CmzJhfLkD3bejEkZZgLqNGZv9PJGuXLm
cMb7PBygXHH1zZ...
  1. Here are the commands taken from the list that I remember from previous lectures, and their description:
  • getbalance
    Returns the server’s total available balance. If an account is specified, returns the balance in the account.

  • getnewaddress
    Returns a new bitcoin address for receiving payments.

  • listunspent
    Returns array of unspent transaction inputs in the wallet.

Yes, getnewaddress and getbalance are in the list, and the description fits the examples in the videos. I just wonder why the term “array” is used, as well as “transaction inputs” instead of simply “transactions”.

  1. I executed dumpwallet in order to export private keys in a txt file I called “wallet”.

./bitcoin-cli -regtest dumpwallet "C:\Users\...\Documents\wallet.txt"

Under the message # extended private masterkey, I got a long key (more than 100 chars) which looks like a private key.

Then further below there are a lot of lines with hundreds of hashes and addresses…

  1. When I execute dumpprivkey on the bitcoin address I generated, I get a new hash, longer than the previous hash (52 chars). According to the list, it should be the private key corresponding to the address.
  1. We have already used some commands in previous lectures, let’s find them in the list and verify how they are described. Can you find getnewaddress and getbalance in the list? Does the description fir what the commands do?
  1. Try to execute dumpprivkey on an address you generated with getnewaddress.

2019-04-29%2018_06_59-

  1. Try to execute dumpwallet in order to store keys in a file.

2019-04-29%2018_14_10-

If you are having trouble using dumpwallet on Windows like I did:
error code: -8
error message:
Cannot open wallet dump file

this is what worked for me:
./bitcoin-cli -regtest dumpwallet “C:\Users\YOURUSER\Desktop\wallet”

  1. getnewaddress - “Returns a new bitcoin address for receiving payments.”
    getbalance - “returns the balance in the account.”
    2.bitcoin-cli -regtest dumpwallet [dumpedwalletfilename.txt]
  2. bitcoin-cli -regtest dumpprivkey [publickey]