Bitcoind and bitcoin-cli Assignment

Some commands did, but the ones in the assignment haven’t really changed much. :slight_smile:

You can always use the help command: bitcoin-cli help <COMMANDNAME>

1 Like

feels a lot linux-like, which I like.

1 Like
  1. I use regnet for the test and both getnewaddress and getbalance worked perfecly.

  2. I use command line ./bitcoin-cli -regtest dumpwallet mykeys and regtest create a file name mykeys and succesfully copy all my wallet private key in it.I didn’t know that it would create a file by itself. Just by curiosity the file is 512 KB is this normal?

3.I use ./bitcoin-cli -regtest dumpprivkey with the new address i generated and it give a different address (my private wallet key).

1 Like

Hmmm, never checked its size tbh :stuck_out_tongue: it should grow as you use the wallet and generates more addresses. At first you should have 100 keys inside, you can check by opening it with a text editor.

  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?

I had expected that “bitcoin-cli -help” itself would return a list and description of the commands. But I’ve seen no way to get this list out of bitcoin-cli. So it looks like we have to look after the commands and their description online.

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

I did so but don’t understand the content of the file yet. It cointains roughly 4000 lines. I had expected only a handful, maybe one per “getnewaddress” command I’ve made.
Probably I’ll understand better later in the course.

  1. Try to execute dumpprivkey on an address you generated with getnewaddress.

Worked fine. Here’s my private key on the mainnet:
(just joking)

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? — yes
  2. Try to execute dumpwallet in order to store keys in a file. — makes text file with all private keys, this could be used for a paper wallet
  3. Try to execute dumpprivkey on an address you generated with getnewaddress. — this could be used for a paper wallet of the specific address
1 Like

1.)
Yes think the description fits.

2.)
./bitcoin-cli -regtest dumpwallet filename
This exports a human readable file. This includes the private masterkey, all private keys and public keys.

3.)
./bitcoin-cli -regtest dumpprivkey bcrt1…
This shows the private key of the requested 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 for 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.Yes description is what the commands do, and also it says on getbalance command that if the account is not specified it will show the servers total available balance.

  1. dumpwallet -> ./bitcoin-cli -regtest dumpwallet “D:\test.txt” = exports all private keys into "test.txt

  2. dumpprivkey-> ./bitcoin-cli -regtest dumpprivkey “address” -> shows the private key to this wallet address

2 Likes

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 for what the commands do?

Found them and they work as predicted.

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

3 Try to execute dumpprivkey on an address you generated with getnewaddress.
./bitcoin-cli -regtest dumpprivkey $(./bitcoin-cli -regtest getnewaddress)

1 Like
  1. getnewaddress:
    Returns a new bitcoin address for receiving payments. If [account] is specified payments received with the address will be credited to [account].

getbalance:
If [account] is not specified, returns the server’s total available balance.
If [account] is specified, returns the balance in the account.

  1. Done
  2. Done
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 for what the commands do?
    getnewaddress
    If [account] is not specified, returns the server’s total available balance.
    If [account] is specified, returns the balance in the account.
    getbalance
    Returns a new bitcoin address for receiving payments. If [account] is specified payments received with the address will be credited to [account].

  2. Try to execute dumpwallet in order to store keys in a file.
    Done

  3. Try to execute dumpprivkey on an address you generated with getnewaddress.
    Done

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 for what the commands do?
    Yes we can find the commands in the list and they are doing exactly what their descriptions is describing/

  2. Try to execute dumpwallet in order to store keys in a file.
    bitcoin-cli -regtest dumpwallet test

  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?
  • it describes what the commands do and how to set parameters
  1. Try to execute dumpwallet in order to store keys in a file.
  • ./bitcoin-cli -regtest dumpwallet <wallet_name>
  1. Try to execute dumpprivkey on an address you generated with getnewaddress.
  • ./bitcoin-cli -regtest getnewaddress
  • ./bitcoin-cli -regtest dumpprivkey <key_address>
1 Like
  1. getnewaddress - “Returns a new bitcoin address for receiving payments.”
    getbalance - “returns the balance in the account.”
    2.bitcoin-cli -regtest dumpwallet “C:\Users…”
  2. bitcoin-cli -regtest dumpprivkey [publickey]
1 Like

The parameter for dumpwallet is the filename where you want to dump the wallet keys. You can use the help command to get help with any command you want bitcoin-cli help dumpwallet :slight_smile:

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 for what the commands do?

‘getbalance’ is interesting as it can be used to get the balance of a specific address instead of the server’s general/overall balance which is default. A minimum confirmation can also be specified.

‘getnewaddress’ can also have a specified account to which a new address can be attributed.

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

I could not store wallet in a file : PS C:\Program Files\Bitcoin\daemon> ./bitcoin-cli -regtest dumpwallet "test" error code: -8 error message: Cannot open wallet dump file

Tried ./bitcoin-cli help dumpwallet but I was returned this message : Make sure the bitcoind server is running and that you are connecting to the correct RPC port.

  1. Try to execute dumpprivkey on an address you generated with getnewaddress.

This command returns the private key from the freshly generated address (or any address that’s input)

1 Like
  1. yes, the description explains what the commands actually do

  2. ./bitcoin-cli -regtest dumpwallet “testfilename”

  3. ./bitcoin-cli -regtest dumpprivkey

1 Like

You have to specify a path in the user folder, Program files doesn’t allow writing unless you open the console as an administrator.

Thank you @Alko89 very useful! :raised_hands:

  1. seems straight forward
  2. ./bitcoin-cli -regtest -rpcwallet=regtestwallet dumpwallet c:\temp\test.dmp
  3. ./bitcoin-cli -regtest -rpcwallet=regtestwallet dumpprivkey
1 Like