Bitcoind and bitcoin-cli Assignment

Great answer man!

I also had this issue at first. I ended up switching to the Bitcoin Core version the course was recorded with.

I got this now. :slight_smile:

  1. To getnewaddress now first it’s necessary to create a wallet because since video was created default wallet isn’t created anymore. Getbalance command is working without any changes.
  2. In result of dumpwallet command we got a file with wallet keys.
  3. In result of dumpprivkey command we got a private key of the defined 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?
    getnewaddress:Returns a new bitcoin address for receiving payments.
    getbalance- returns the server’s total available balance.

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

  3. Try to execute dumpprivkey on an address you generated with **getnewaddress.
    using regtest
    ./bitcoin-cli -regtest dumpprivkey “walletaddress”

1 Like
  1. The getnewddress command returns a new payment address and getbalance returns the corresponding balance.

  2. Try to execute dumpwallet in order to store keys in a file.
    After several attempt with always error code: -8 I finally get the result

./bitcoin-cli -regtest dumpwallet “C:\User\Amiri\dumpwallet\Documents”
error code: -8
error message:
C:\User\Amiri\Documents already exists. If you are sure this is what you want, move it out of the way first
…so then I tried it again…
./bitcoin-cli -regtest dumpwallet “C:\User\Amiri\dumpwallet”
<
“filename”: “C:\User\Amiri\dumpwallet”

  1. Try to execute dumpprivkey on an address you generated with getnewaddress.
    This worked out completely fine… quite easy :grin:
1 Like
  1. The descriptions for the commands getnewaddress and getbalance fits what the commands do.
  2. try to execute dumpwallet in order to store keys in a file.
    ./bitcoin-cli -regtest dumpwallet "test" you can open the file with notepad i found
  3. Try to execute dumpprivkey on an address you generated with getnewaddress.
    ./bitcoin-cli -regtest dumpprivkey "<address>"
1 Like
  1. The commands found getnewaddress and getbalance are in the list. The description fits the execution for what the commands do, but with an adding that when you specify a certain account within your wallet, it returns the data for that wallet. Otherwise the return includes your whole wallet (containing N addresses/accounts)…

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

  3. Try to execute dumpprivkey on an address you generated with getnewaddress.
    In PS execute ./bitcoin-cli -regtest dumpprivkey 2NE1qBMCbBzKeDqjUe19GSeZfmhYqBci6p5

1 Like

1.Returns a new bitcoin address for receiving payments. If [account] is specified payments received with the address will be credited to [account].If [account] is not specified, returns the server’s total available balance.
If [account] is specified, returns the balance in the account.
2. i was able to execute dumpwallet successfully.
3.i generated a new address and was successfull in dumping the private key

1 Like
  1. it does describe what the command does and it is what the action says it does.
    2…/bitcoin-cli -regtest dumpwallet
    3…/bitcoin-cli -regtest dumpprivkey
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?
  • Getnewaddress: Returns a new bitcoin address for receiving payments.
  • Getbalance: Returns the total available balance.
  1. Try to execute dumpwallet in order to store keys in a file.
  • I called it “Dump Wallet”, so it’s going to look like this:
    ./bitcoin-cli -regtest dumpwallet “C:\Users\dgebr\Desktop\Dump Wallet”
  1. Try to execute dumpprivkey on an address you generated with getnewaddress.
  • ./bitcoin-cli -regtest getnewaddress
  • ./bitcoin-cli -regtest dumpprivkey (name new address)
1 Like

For getnewaddress, it returns a new bitcoin address for receiving payments. If [account] is specified payments received with the address will be credited to [account].

For getbalance, there’s a parameter name minconf=1. what does mincof mean? from the name it suggest that it’s some kind of configuration??
For getbalance, if account number is provided it’ll return the balance of that account, otherwise it’ll return the server’s total available balance.

  1. dumpwallet, it exports all wallet private keys to file

  2. dumpprivkey reveals the private key of a particular address

1 Like

Its the minimal number of confirmations required for the tx to be summed up in getbalance,

1 Like

so what will happen if I set it to 0? and is there a upper limit to this number, practical and theoretical wise?

It would include txs in the mempool

what do you mean by this?
so if I use 0 instead of 1 in mincof, it’ll include txs in mempool??

It will include unconfirmed txs in the addresses total balance

  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?

A//
getnewaddress: Returns a new bitcoin address for receiving payments.
getbalance: Returns the balance in the account
Returns the servers total available balance

  1. Try to execute dumpwallet in order to store keys in a file.
    A// succesfully
    PS C:\Program Files\Bitcoin\daemon> ./bitcoin-cli -regtest dumpwallet “C:\Users\kenny Jafet Escobar\OneDrive\Desktop\Dump”
    {
    “filename”: “C:\Users\kenny Jafet Escobar\OneDrive\Desktop\Dump”
    }
  2. Try to execute dumpprivkey on an address you generated with getnewaddress.

A// PS C:\Program Files\Bitcoin\daemon> ./bitcoin-cli -regtest getnewaddress
bcrt1qgjrrfvlj9c2dvex7gu37q0kdcshswpxq2jk7t8
PS C:\Program Files\Bitcoin\daemon> ./bitcoin-cli -regtest dumpprivkey “bcrt1qgjrrfvlj9c2dvex7gu37q0kdcshswpxq2jk7t8”
cPE57hyQZBBPzjiv55ypdsorqxk1DEzM3dKZ6QbyTivU5CmJFQpo
PS C:\Program Files\Bitcoin\daemon>

1 Like

Hi All :grinning:

I am using bitcoin core version 23

  1. The API has evolved and the latest description for getnewaddress and getbalance can be found here:

https://developer.bitcoin.org/reference/rpc/getnewaddress.html

https://developer.bitcoin.org/reference/rpc/getbalance.html

For instance the new getnewaddress has a parameter to choose between legacy and bech32 address formats.

  1. I am still a bit confused with loading / dumping wallets

I first created a wallet with default options

>./bitcoin-cli -regtest createwallet "mywallet"

when using dumpwallet i had the following error:

error code: -4
error message:
This type of wallet does not support this command

I created a new wallet with the following options:

>./bitcoin-cli -regtest createwallet 'beerkitty' false false "" false false true

descriptors: false

Now dumping from the new wallet works:

./bitcoin-cli -regtest -rpcwallet="beerkitty" dumpwallet "/home/parallels/Documents/dump3.txt"
{
  "filename": "/home/parallels/Documents/dump3.txt"
}

  1. dumping the private key also works
>./bitcoin-cli -regtest getnewaddress
bcrt1qtywjm6j4p9670curwe520e003upqkuzxmxgaxy
>./bitcoin-cli -regtest dumpprivkey bcrt1qtywjm6j4p9670curwe520e003upqkuzxmxgaxy
cMpRkNbw78vduxbgkiDimVUUBZof9b8ha1SjvoaNEBEW1A3G4yxG
1 Like
  1. Yes they can be found I the bitcoin API call list and they describe correctly what the commands do.
    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.
  2. bitcoin-cli -regtest dumpwallet “filename”
  3. bitcoin-cli -regtest dumpprivkey “bitcoinaddress”
1 Like

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. error

  2. .\bitcoin-cli.exe -regtest dumpprivkey bcrt1qxy4avrzzgll4pk4rzwkvz0nzsy65yzhkwxlytp /// Revealed cN9L8mU2Jnu4DqWw7M68Wu53z2mJnv6goxwTYzEotzegvQg6SFB5

1 Like
  1. getnewaddress - Returns a new bitcoin address for receiving payments. If address is specified payments received with the address will be credited to the address.
    getbalance - If address is not specified, returns the server’s total available balance. If address is specified, returns the balance in the address.
  2. dumpwallet [filename] writes all wallet private keys to the specified file
  3. dumprivkey [bitcoinaddress] writes the private key of the specified bitcoin address to the console
1 Like