Hi~
I just have some questions about restoring a wallet. Most users had showed how to use Bitcoin core, but few focus on how to restore the wallet. I've read the book "grokking Bitcoin", where Kalle said that we should keep wallet.dat file safe. My try is as following:
First I create a test wallet:
$ bitcoin-cli createwallet testwallet false false -passphrase=test111 false false true false
Next, I started to backup the wallet and kept it safe. This step seemed that the passphrase was not necessary.
$ bitcoin-cli -rpcwallet=testwallet backupwallet ~/testwallet.dat
Get an adress for someone who would send me some bitcoins:
$ bitcoin-cli -rpcwallet="testwallet" -named getnewaddress address_type=bech32
bc1q7y3uj...unpn9
# Get private key
$ bitcoin-cli -rpcwallet="testwallet" dumpprivkey "bc1q7y3uj...unpn9"
KzqZ3UoP...98K
Supposed that I've got the pay, but suddenly my server was exploded. I decided to restore the wallet in a new Linux server. After install Bitcoin core software completely, I created a new wallet:
$ bitcoin-cli createwallet testwallet2 false false -passphrase=test444 false false true false
Unlock it for 120s:
$ bitcoin-cli -rpcwallet=testwallet2 walletpassphrase -passphrase=test444 120
Restored the wallet:
$ bitcoin-cli -rpcwallet=testwallet2 importwallet <testwallet.dat>
# without any error information
However, it seemed that the wallet could not access the private key
$ bitcoin-cli -rpcwallet="testwallet2" dumpprivkey "bc1q7y3uj...unpn9"
error code: -4
error message:
Private key for address bc1q7y3uj...unpn9 is not known
Here are some questions:
a. Was I do the right thing to restore the wallet?
b. If I was right, it means that anyone (hackers of my servers, for example) who own the testwallet.dat file could get all the bitcoins. In the importwallet step, I didn't need to use any passphrase (test111) of the previous wallet. It seemed not very safe, because my server may be easy to be cracked. So I guess I was wrong, but I have no idea how to do this. Any suggestions?
My Bitcoin core version is :
"version": 220000,
"subversion": "/Satoshi:22.0.0/"