Bitcoin Forum
May 08, 2024, 10:10:07 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: wallet.dat backup  (Read 543 times)
columbo (OP)
Jr. Member
*
Offline Offline

Activity: 45
Merit: 1


View Profile
November 29, 2017, 05: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!
1715206207
Hero Member
*
Offline Offline

Posts: 1715206207

View Profile Personal Message (Offline)

Ignore
1715206207
Reply with quote  #2

1715206207
Report to moderator
1715206207
Hero Member
*
Offline Offline

Posts: 1715206207

View Profile Personal Message (Offline)

Ignore
1715206207
Reply with quote  #2

1715206207
Report to moderator
Transactions must be included in a block to be properly completed. When you send a transaction, it is broadcast to miners. Miners can then optionally include it in their next blocks. Miners will be more inclined to include your transaction if it has a higher transaction fee.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1715206207
Hero Member
*
Offline Offline

Posts: 1715206207

View Profile Personal Message (Offline)

Ignore
1715206207
Reply with quote  #2

1715206207
Report to moderator
1715206207
Hero Member
*
Offline Offline

Posts: 1715206207

View Profile Personal Message (Offline)

Ignore
1715206207
Reply with quote  #2

1715206207
Report to moderator
xdrpx
Hero Member
*****
Offline Offline

Activity: 616
Merit: 603


View Profile
November 29, 2017, 05: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.
BillyBobZorton
Legendary
*
Offline Offline

Activity: 1204
Merit: 1028


View Profile
November 29, 2017, 07: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.
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6631


Just writing some code


View Profile WWW
November 29, 2017, 09: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.

legend018
Member
**
Offline Offline

Activity: 84
Merit: 10


View Profile
November 29, 2017, 09: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

columbo (OP)
Jr. Member
*
Offline Offline

Activity: 45
Merit: 1


View Profile
November 30, 2017, 07: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?
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6631


Just writing some code


View Profile WWW
November 30, 2017, 04:29:44 PM
 #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.

columbo (OP)
Jr. Member
*
Offline Offline

Activity: 45
Merit: 1


View Profile
December 01, 2017, 08: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?
columbo (OP)
Jr. Member
*
Offline Offline

Activity: 45
Merit: 1


View Profile
December 01, 2017, 03:21:15 PM
 #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?
achow101
Moderator
Legendary
*
Offline Offline

Activity: 3388
Merit: 6631


Just writing some code


View Profile WWW
December 01, 2017, 09: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.

Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!