Bitcoind and bitcoin-cli Assignment

Thanks for the help! it worked :slight_smile:

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

Yes, the descriptions fit for what the commands do.

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

./bitcoin-cli -regtest dumpwallet “C:\Users\Name\desktop\wallet”

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

Executed dumpprivkey on a new address I generated with getnewaddress and I received the private key correlated to the public key.

1 Like

A.1. Commands in the previous lectures: getnewaddress and getbalance.

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

A.2. Execute dumpwallet in order to store keys in a file.

Return:
Capture1
Error code: -1. error message: dumpwallet “filename”.

A.3. Execute dumpprivkey on an address you generated with getnewaddress

Return:
Capture2
Error code: -1. Error message: dumpprivkey “address”.

With dumpwallet you have to provide a file to dump the wallet to and dumpprivkey requires an address. :slight_smile:

1 Like

Thanks Ales,

I assume that the course will cover those topics: dumpwallet and dumpprivkey as well as when & how to implement those parameters.

I look forward to the upcoming tutorials.

:vulcan_salute:

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

Yes, it does!

  1. Try to execute dumpwallet in order to store keys in a file.
    I did. It generate a text file with tons of alphanumeric codes.

  2. Try to execute dumpprivkey on an address you generated with getnewaddress.
    I did. It generated a private key

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 = a new btc wallet address tied to the same private key
    get balance = shows available balance at the address

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

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

1 Like
  1. With getbalance you can request a specific wallet or equest the balance of the whole server. With getnewaddress you can get a random one or you can name the new wallet.
  2. … dumpwallet “c:…\testwallet” The program then creates the file and dumps the information in the file.
    3.dumpprivkey shows you the private key assosiated with the address.
1 Like

I don’t understand where the file is for the dumpwallet command. Please someone help.

You should have specified the path to the file yourself. If you just set the file name without the path it should be in the same folder as your console is located atm. You can print the current path with the pwd command, or dir on dos. :slight_smile:

  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. 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. Try to execute dumpwallet in order to store keys in a file.

./bitcoin-cli -regtest dumpwallet “C:\Users\Joe\Desktop\Test folder”

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

./bitcoin-cli -regtest dumpprivkey bcrt1q022w3uady8gjws6fnuxwvfwvj4req3ghyzs9kl

cRq3ygMasqM7PvVeQmAd6RpYZPSyMcqh2Log2bSZNCwUpwhQeaNV

1 Like

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 they are in the list but not generate 1 command, to generate a new block?

  1. Try to execute dumpwallet in order to store keys in a file.
    ./bitcoin-cli -regtest dumpwallet "<path and wallet_ filename>" This will export all wallets private keys to file
  2. Try to execute dumpprivkey on an address you generated with getnewaddress.
    ./bitcoin-cli -regtest dumpprivkey <address> This will show the private key to given address
1 Like
  1. Yes I could find them, yes.

  2. Done

  3. Done

1 Like

Assignment: bitcoind & bitcoin-cli

  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, I can find these commands in the list.
    The description for getnewbaddress says, Returns a new bitcoin address for receiving payments. If [account] is specified payments received with the address will be credited to [account].
    For getbalance it says, If [account] is not specified, returns the server’s total available balance.
    If [account] is specified, returns the balance in the account.

  2. Try to execute dumpwallet in order to store keys in a file.
    ./bitcoin-cli -regtest dumpwallet [filename]
    Exports all wallet private keys to a file.

  3. Try to execute dumpprivkey on an address you generated with getnewaddress.
    ./bitcoin-cli -regtest dumpprivkey [bitcoinaddress]
    Will show the private key for this specific address.

1 Like
  1. …does it match? yes apparently…

  2. simple enough…

  3. got it.

not sure what answers i’m supposed to leave here, but basically i could do these things easily enough, so i figure i’m done.

  1. Yes. But in the latest version, you have to create a wallet first with:
bitcoin-cli -regtest createwallet "<wallet name>"

Then you can do, assuming that the wallet name is “testwallet”,

bitcoin-cli -regtest -rpcwallet=testwallet getnewaddress
bitcoin-cli -regtest -rpcwallet=testwallet getbalance

Note:
-rpcwallet=testwallet is required when you create more than one wallet.
And make sure to load wallet first if you restart local node:

bitcoin-cli -regtest loadwallet "testwallet"
  1. The command created a new file with list of transactions.

Use this if you have multiple wallet:

bitcoin-cli -regtest -rpcwallet=testwallet dumpwallet "testwallet"
  1. It revealed the private key of the address.

But if you try to do this with an address that doesn’t belong to its wallet, you will get an error:

> bitcoin-cli -regtest -rpcwallet=testwallet1 dumpwallet "bcrt1qfug8e52vz4a2e3pxhcxkm3tgxc9k8y0srx2q00"
error code: -18
error message:
Requested wallet does not exist or is not loaded
2 Likes

Very nice answers, good job! :raised_hands:

Homework Template:

Truls-Magnus Lokrheim - Assignment Submission, Bitcoind & Bitcoin-cli

Question 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?
Answer: Affirmative, the commands; getnewaddress and getbalance fit the description of their actions.

Question 2: Try to execute dumpwallet in order to store keys in a file.
Answer: After executing the dumpwallet protocol, I was successfully met with this code.

PS C:\Bitcoin\daemon> ./bitcoin-cli -regtest dumpwallet keywallet
{
"filename": "C:\\Bitcoin\\daemon\\keywallet"
}

Question 3: Try to execute dumpprivkey on an address you generated with getnewaddress.
Answer: After executing the dumpprivkey protocol, I was successfully met with this code.

PS C:\Bitcoin\daemon> ./bitcoin-cli -regtest getnewaddress
2Mz7uzizHZFWNz41fox7A9AotMyo88zNFu4

PS C:\Bitcoin\daemon> ./bitcoin-cli -regtest dumpprivkey 2Mz7uzizHZFWNz41fox7A9AotMyo88zNFu4
cTGV8ySu8VopnoFx4EHoP62dXqgr8Rqg1kjsHKJ4r8M6ATy65VAR

1 Like
  1. Yes, they are correct.
  2. ./bitcoin-cli -regtest dumpwallet “C:\Users\Lemon\OneDrive\moralis academy\software\bitcore\practice\walletdump.txt”
  3. ./bitcoin-cli -regtest getnewaddress
    ./bitcoin-cli -regtest dumpprivkey “2N57qhAHRcthYy72gvdwrTyDHo7zrSDasmV”
1 Like
  1. Yes

  2. ./bitcoin-cli -regtest dumpwallet regdumpkeys

  3. ./bitcoin-cli -regtest dumpprivkey 2MxmiY7ySMYNLUGb8gNvB9Fuvs2GPUCQz9p

1 Like