Did you provide the path to the file where to dump the keys?
Just tried it there and got this
[mark@centos8 ~]$ bitcoin-cli -regtest dumpwallet “/home/mark/dumptest”
error code: -8
error message:
/home/mark/dumptest already exists. If you are sure this is what you want, move it out of the way first
Does dumptest file already exist?
yes, I made it specifically for this exercise
its path is;
/home/mark/dumptest
[mark@centos8 ~]$ ls -l dumptest
-rw-rw-rw-. 1 mark mark 0 Dec 13 19:42 dumptest
The CLI will create a file on its own, you just have to provide a path (and name) of the new file. Like ./dump.txt
, maybe this also works without the ./
haven’t tried its good practice to provide it
YOU. ARE. GOOD.
Thanks very much.
Thats why when I got the ;
/home/mark/dumptest already exists. If you are sure this is what you want, move it out of the way first error, I didnt understand why.
Thanks very much again.
- getbalance - If [account] is not specified, returns the server’s total available balance.
If [account] is specified, returns the balance in the account.
getnewaddress - Returns a new bitcoin address for receiving payments. If [account] is specified payments received with the address will be credited to [account]. - done
- done
Bitcoin[d | -cli] Assignment 
-
Can you find getnewaddress and getbalance in the list? Does the description fit for what the commands do?
Both commands are pretty self-explanatory… and the wiki descriptions merely confirm that. Nice to know there is an account parameter, though. -
Try to execute dumpwallet in order to store keys in a file.
Please cf. screenshot below. -
Try to execute dumpprivkey on an address you generated with getnewaddress.
Please cf. screenshot below.
Works really well on GNU/Linux as well
This is gonna be fun!
You can also check each command with the help
command: bitcoin-cli help <COMMAND>
.
It works even better
- 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. - Try to execute dumpwallet in order to store keys in a file.
You specify the file to dump the keys too. It tells you the “extended private masterkey” at the top. Then a huge list of private keys and the corresponding address. Most are labeled for reserve. Some are normal addresses, some are used for change, and some are labeled as script addresses. - Try to execute dumpprivkey on an address you generated with getnewaddress.
It prints the private key corresponding to the address in the console.
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
dumpwallet created a new file in my directory that contained a large number of private ketys
dumprivkey returned a private key corresponding to the getnewaddress that i created in the earlier exercise
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. 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.
Try to execute dumpwallet in order to store keys in a file.
A dump file with a long list of addresses was written to the file specified.
Try to execute dumpprivkey on an address you generated with getnewaddress.
This command displays the private key for the address used
-
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. -
dumpwallet [filename] writes all wallet private keys to the specified file
-
dumprivkey [bitcoinaddress] writes the private key of the specified bitcoin address to the console
- 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. 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. - Try to execute dumpwallet in order to store keys in a file.
Creates a file with:
- header metadata
- extended private masterkey
- all the private and public(address) keys that can be derived from the masterkey
- Try to execute dumpprivkey on an address you generated with getnewaddress.
Prints to screen the corresponding private key of the requested adddress.
Checked in the dumpwallet file, both the address and private key returned by dumpprivkey are on the same line in the file.
I have a question here:
Let’s say I run a node, and offer a wallet app service.
User X creates a wallet and uses an address to make some transactions.
As maintainer/runner of the node, am I able to see User X’s private keys via dumpprivkey?
Looks to me like yes, which means User X doesn’t own his private keys.
I’m not sure about that, dumpwallet
should dump all private keys, because the bitcoin-core wallet is not a HD (hierarchical deterministic) wallet. Unless they changed it with a recent update.
No because the user will generate keys in his own wallet and connect to your node using an SPV (most probably). Even in case you don’t implement SPV functionality on the users wallet, the user will have its own private keys stored on his device and would only use your node to broadcast txs. But it would make tracking the users balance a bit more tricky.
There are also other ways you could design a wallet, like having a username and password and store the users private keys on your side, this would give you control of their keys. I wouldn’t use it though.
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 basically
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.
- Try to execute dumpwallet in order to store keys in a file.
yes its working I need to specify where I will create the file
./bitcoin-cli -regtest dumpwallet “E:\Importante\Programas creados imagenes iso etc\Bitcoin\Wallet_private_keys”
I have a question here this file is like a json archive or some file to save my pair of public and private keys? - Try to execute dumpprivkey on an address you generated with getnewaddress
its working
PS C:\Program Files\Bitcoin\daemon> ./bitcoin-cli -regtest dumpprivkey bcrt1q5sunlxj3qjanh3aa4np8jcxne9sv7j7r2tg5y0 cNQQBWduSWmcdbGuniaEn3dhWwKEsonAAuraTzT1xXqPRTuAN8CA
Its just a regular txt file with each key printed in a new line. You can open it with any text editor.
You can use it to backup the keys but you can also just store the wallet.dat file as well. You must back them up regularly because they are not HD wallets
Well, it was harder that I though since most commands are not the same anymore.
-
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 think they to represent well their name, but one should make a distinction between a wallet and an address. -
Try to execute dumpwallet in order to store keys in a file.
It writes all the private keys in a file. Basically a paper wallet. -
Try to execute dumpprivkey on an address you generated with getnewaddress.
Create a “paper wallet” for a specific address that the wallet owns.