Author

Topic: wallet.dat backup (Read 569 times)

staff
Activity: 3458
Merit: 6793
Just writing some code
December 01, 2017, 04:42:32 PM
#10
Thank you. If I generated a witnessaddress and do not know the public key used to generate it, how do I spend funds that are on witnessaddress if I move wallet.dat to another core?
The private and public keys are stored in your wallet. The software will allow you to spend from the witness address.

Also, will my wallet.dat hold the private keys of all my regular addresses? Even if I used the wallet.dat to generate let's say 5, 10 or 25 thousand regular addresses?
Yes. It always does. Keys are never removed from the wallet.dat file unless it is corrupted.

And I suppose that if I have the public and private key of a regular address, I can always regenerate the segwit address and spend all funds that are on that specific segwit address, right? Will the "bitcoin-cli addwitnessaddress 1myregularaddress..." command always generate the same segwit address?
Yes.
jr. member
Activity: 45
Merit: 1
December 01, 2017, 10:21:15 AM
#9
Also, will my wallet.dat hold the private keys of all my regular addresses? Even if I used the wallet.dat to generate let's say 5, 10 or 25 thousand regular addresses?

And I suppose that if I have the public and private key of a regular address, I can always regenerate the segwit address and spend all funds that are on that specific segwit address, right? Will the "bitcoin-cli addwitnessaddress 1myregularaddress..." command always generate the same segwit address?
jr. member
Activity: 45
Merit: 1
December 01, 2017, 03:03:59 AM
#8
Thank you. If I generated a witnessaddress and do not know the public key used to generate it, how do I spend funds that are on witnessaddress if I move wallet.dat to another core?
staff
Activity: 3458
Merit: 6793
Just writing some code
November 30, 2017, 11:29:44 AM
#7
One question: How to enable HD mode?
In Bitcoin Core 0.13.0+, HD wallets are enabled by default and created by default. If your wallet was created in a version of Bitcoin Core 0.13.0+ and you did not start Bitcoin Core with -usehd=0, then your wallet is a HD wallet.

And another one: what do you mean by this: "older backups will not know about those witness addresses (the scripts themselves must be added to the wallet) and addwitnessaddress will need to be called again on every single address generated." So, if my wallet.dat has funds on a single witnessaddress and I move the wallet.dat to another node, I won't see there the witness address? If so, do I have to remember the non witness address I used to generate a specific witness address?
No, the addresses will follow the wallet file, not the software.

Suppose you make a backup, then generate a new address and use addwitnessaddress on it, and then receive coins at both the witness address and the regular address. If you were to restore the backup, you will see the coins that were sent to the regular address, but not the ones sent to the witness address. Furthermore, you wouldn't see the witness address in your wallet and would have to call addwitnessaddress again to add it to your wallet. Then you may also need to rescan. This should be fixed when full segwit wallet support is completed in Bitcoin Core.
jr. member
Activity: 45
Merit: 1
November 30, 2017, 02:40:30 AM
#6
If I have an encrypted wallet.dat file under bitcoin core, and I frequently use the getnewaddress and addwitnessaddress commands, how often should I backup the wallet.dat file?
If you are using the latest Bitcoin Core, then you should make a new backup every 1000 addresses. That is the default keypool size and you should make a new backup whenever the keypool runs out. This should be done regardless of HD or non-HD wallet, and even more so because you are using addwitnessaddress.

Also, you will need to unlock your wallet every 1000 addresses so that the keypool can be refreshed.

This was the case with the old format, as far as I know, since bip32 was introduced (I think this is the bip for the current HD format) then you no longer need to be making backups each time, but I don't know how this would be the case to be honest.

Even if HD mode is enabled, and you make receive a transaction with a newly generated key, how can a former HD enabled wallet.dat know that this transaction was received, if the key was never generated? same goes for sent coins. This confuses me a great deal. I think it has something to do with pre-generated addresses that you don't see but already are there or something along the lines... it's weird to think for a non coder. I would like achow101 to explain this in laymans.

My advice is that even if you are using HD mode, you keep making backups and don't delete previous backups, just rename them.
You should keep making backups regularly. What HD wallets do is that you can still use old backups and still generate the private keys that are not in the keypool at the time of backup.

The wallet contains a field which has the latest block height that the wallet is synced up to (as in it has the transactions for the wallet up to that block height). So when restoring, Bitcoin Core will know where it should begin rescanning the blockchain to get any new transactions.

Because OP is also using addwitnessaddress, older backups will not know about those witness addresses (the scripts themselves must be added to the wallet) and addwitnessaddress will need to be called again on every single address generated.

One question: How to enable HD mode?
And another one: what do you mean by this: "older backups will not know about those witness addresses (the scripts themselves must be added to the wallet) and addwitnessaddress will need to be called again on every single address generated." So, if my wallet.dat has funds on a single witnessaddress and I move the wallet.dat to another node, I won't see there the witness address? If so, do I have to remember the non witness address I used to generate a specific witness address?
member
Activity: 84
Merit: 10
November 29, 2017, 04:36:05 PM
#5
The current bitcoin core is deterministic and the docs say you only need to back it up once.  Here is a link. There is also another link in there with specific information on backing up the .dat file

https://en.bitcoin.it/w/index.php?title=Securing_your_wallet&redirect=no#Backing_up_your_wallet

staff
Activity: 3458
Merit: 6793
Just writing some code
November 29, 2017, 04:05:46 PM
#4
If I have an encrypted wallet.dat file under bitcoin core, and I frequently use the getnewaddress and addwitnessaddress commands, how often should I backup the wallet.dat file?
If you are using the latest Bitcoin Core, then you should make a new backup every 1000 addresses. That is the default keypool size and you should make a new backup whenever the keypool runs out. This should be done regardless of HD or non-HD wallet, and even more so because you are using addwitnessaddress.

Also, you will need to unlock your wallet every 1000 addresses so that the keypool can be refreshed.

This was the case with the old format, as far as I know, since bip32 was introduced (I think this is the bip for the current HD format) then you no longer need to be making backups each time, but I don't know how this would be the case to be honest.

Even if HD mode is enabled, and you make receive a transaction with a newly generated key, how can a former HD enabled wallet.dat know that this transaction was received, if the key was never generated? same goes for sent coins. This confuses me a great deal. I think it has something to do with pre-generated addresses that you don't see but already are there or something along the lines... it's weird to think for a non coder. I would like achow101 to explain this in laymans.

My advice is that even if you are using HD mode, you keep making backups and don't delete previous backups, just rename them.
You should keep making backups regularly. What HD wallets do is that you can still use old backups and still generate the private keys that are not in the keypool at the time of backup.

The wallet contains a field which has the latest block height that the wallet is synced up to (as in it has the transactions for the wallet up to that block height). So when restoring, Bitcoin Core will know where it should begin rescanning the blockchain to get any new transactions.

Because OP is also using addwitnessaddress, older backups will not know about those witness addresses (the scripts themselves must be added to the wallet) and addwitnessaddress will need to be called again on every single address generated.
legendary
Activity: 1204
Merit: 1028
November 29, 2017, 02:12:35 PM
#3
If you generate new addresses, new private keys for those addresses are created and hence you will need to backup your wallet.dat file everytime you do that and a transaction happens on one of those addresses to safeguard against missing funds. You can and should automate backups of the .dat file by using a cron script or if on windows create a scheduled task to backup to a secure location which only you can access to and no network access is available.

The idea with the backup here is to ensure that if a transaction happens on the addresses you generate (may it be the segwit address or legacy) you should make your backups to ensure that you have the latest wallet.dat file which contains the private keys to it.

This was the case with the old format, as far as I know, since bip32 was introduced (I think this is the bip for the current HD format) then you no longer need to be making backups each time, but I don't know how this would be the case to be honest.

Even if HD mode is enabled, and you make receive a transaction with a newly generated key, how can a former HD enabled wallet.dat know that this transaction was received, if the key was never generated? same goes for sent coins. This confuses me a great deal. I think it has something to do with pre-generated addresses that you don't see but already are there or something along the lines... it's weird to think for a non coder. I would like achow101 to explain this in laymans.

My advice is that even if you are using HD mode, you keep making backups and don't delete previous backups, just rename them.
hero member
Activity: 616
Merit: 603
November 29, 2017, 12:33:55 PM
#2
If you generate new addresses, new private keys for those addresses are created and hence you will need to backup your wallet.dat file everytime you do that and a transaction happens on one of those addresses to safeguard against missing funds. You can and should automate backups of the .dat file by using a cron script or if on windows create a scheduled task to backup to a secure location which only you can access to and no network access is available.

The idea with the backup here is to ensure that if a transaction happens on the addresses you generate (may it be the segwit address or legacy) you should make your backups to ensure that you have the latest wallet.dat file which contains the private keys to it.
jr. member
Activity: 45
Merit: 1
November 29, 2017, 12:26:25 PM
#1
If I have an encrypted wallet.dat file under bitcoin core, and I frequently use the getnewaddress and addwitnessaddress commands, how often should I backup the wallet.dat file?

Thank you!
Jump to: