Title: Race Conditions Between Transactions and Wallet Backup Post by: RobShaver on February 21, 2011, 08:18:44 PM I'm new to Bitcoin ... this is the first day I've read about it after hearing Steve Gibson's Feb 10 web cast about it. (You can find it here: http://www.grc.com/securitynow.htm (http://www.grc.com/securitynow.htm))
Is sounds really clever and useful. I'm rooting for it's success. I've read the Bitcoin web sites and searched this forum but haven't found this issue addressed. From what I've read I understand that I am responsible for safeguarding my Bitcoin wallet. That seems good and reasonable. So my questions are: 1. In the FAQ it says, "You need to make a backup of the wallet after every transaction, as the old backup file will be partially or fully invalid." After I've made a Bitcoin transaction, at what point do I know that my wallet is up to date and completely valid? How long does a transaction take and how do I know it's done? 2. If I make a large transaction and my hard drive crashes at some point during it, is there the potential for me to loose the value in that transaction? In other words, is there a possibility of a race condition between initiation of a transaction and a crash that requires me to use my backup wallet? 3. It seems likely, from what I've read that, if my disk becomes unrecoverable after a transaction has completed but before I've completed a backup of the Bitcoin wallet, that the value of that transaction is lost forever. Or is this only true when I become the new owner of a Bitcoin but not true when I transfer ownership to another? 4. Is there any commit/rollback protocol in Bitcoin to permit the whole transaction to include a Bitcoin wallet backup to be completed before committing the transaction? Unless I'm missing something and it already has it, until the Bitcoin system integrates some kind of commit/rollback system to permit automated backup of the Bitcoin wallet, it is not a complete and robust system. Disk-mirroring would be a partial solution. Peace, Rob:-] Title: Re: Race Conditions Between Transactions and Wallet Backup Post by: N12 on February 21, 2011, 08:29:54 PM 1. Your wallet contains your private keys to all the addresses you generate. Every address contains a certain amount of BTC. If you lose the private key to addresses (old wallet), you will lose the BTC associated with them. There is a standard keypool out of 100, meaning that there are 100 addresses generated already, you just don’t see them in the UI. To be 100% sure, just make encrypted backups and update them everytime you do a transaction.
2. When you make a transaction, it is immediately sent to other nodes and it is validated every block generation, so I don’t see a possibility for this. Either the transaction is sent or it is not. 3. Bitcoins have no serial address or anything like this, they aren’t units. They are just stored in addresses in the system. 4. You mean automatic backups by the client? Not at this point. Have a look at blockexplorer (http://blockexplorer.com/) to understand the system a bit further. Each block contains the history of all transactions since the last block. Title: Re: Race Conditions Between Transactions and Wallet Backup Post by: ribuck on February 21, 2011, 08:35:18 PM Rob, if you backup by using the "backupwallet" API call, the backup is safely interleaved with any transactions that may occur.
If you backup the wallet.dat file by copying it somewhere, you should stop the bitcoin client before you copy the wallet, then restart the client afterwards. Title: Re: Race Conditions Between Transactions and Wallet Backup Post by: riX on February 21, 2011, 08:48:06 PM What many fail to realize is that there is only need for a wallet backup if you send bitcoins, not when you receive them.
When you send some bitcoins, one or more new bitcoin adresses are created and added to your wallet, to which some additional bitcoins might get sent! As Blitzboom wrote, the wallet contains a list of 100 new addresses, so in theory you could make up to 100 transaction before this would matter. This is a feature that is specific to the official client, not to the bitcoin protocol. You could patch the client not to send anything except what you tell it. That would however reduce the anonymity and make it easier to track the flow of bitcoins through the network. Title: Re: Race Conditions Between Transactions and Wallet Backup Post by: theymos on February 21, 2011, 09:06:34 PM See https://en.bitcoin.it/wiki/Securing_your_wallet
Title: Re: Race Conditions Between Transactions and Wallet Backup Post by: theGECK on February 21, 2011, 09:57:36 PM What many fail to realize is that there is only need for a wallet backup if you send bitcoins, not when you receive them. When you send some bitcoins, one or more new bitcoin adresses are created and added to your wallet, to which some additional bitcoins might get sent! As Blitzboom wrote, the wallet contains a list of 100 new addresses, so in theory you could make up to 100 transaction before this would matter. This is a feature that is specific to the official client, not to the bitcoin protocol. You could patch the client not to send anything except what you tell it. That would however reduce the anonymity and make it easier to track the flow of bitcoins through the network. I've been trying to figure out where all these new addresses are coming from. Would it be possible to prevent the client from doing that, or to send from a specific address? This way an address could become associated as "mine" and be trusted, much like people receiving to a specific address continually. Title: Re: Race Conditions Between Transactions and Wallet Backup Post by: RobShaver on February 21, 2011, 10:19:17 PM After reading https://en.bitcoin.it/wiki/Securing_your_wallet (https://en.bitcoin.it/wiki/Securing_your_wallet), as theymos suggested, it seems that:
1. You start out with a pool of 100 Bitcoin addresses. 2. Each time you do a transaction that uses an address, a new one is generated to replenish the pool. 3. Each transaction may cause several addresses to be used. 4. As long as you backup the wallet before all keys that have been used, your backup is complete and you won't loose anything. It says on the page from the above link, "So if you create a backup, do more than 100 things that cause a new key to be used, and then restore from the backup, some Bitcoins will be lost." This indicates to me that there is no race condition. Thanks for your quick answers. Peace, Rob:-] Title: Re: Race Conditions Between Transactions and Wallet Backup Post by: theymos on February 21, 2011, 10:22:11 PM 3. Each transaction may cause several addresses to be used. Only sends use an address, and each send can only use 0 or 1 address. Title: Re: Race Conditions Between Transactions and Wallet Backup Post by: Hal on February 21, 2011, 10:26:44 PM 1. In the FAQ it says, "You need to make a backup of the wallet after every transaction, as the old backup file will be partially or fully invalid." Sounds like that FAQ entry is obsolete and should be updated.Title: Re: Race Conditions Between Transactions and Wallet Backup Post by: RobShaver on February 21, 2011, 10:27:05 PM What many fail to realize is that there is only need for a wallet backup if you send bitcoins, not when you receive them. When you send some bitcoins, one or more new bitcoin adresses are created and added to your wallet, to which some additional bitcoins might get sent! As Blitzboom wrote, the wallet contains a list of 100 new addresses, so in theory you could make up to 100 transaction before this would matter. This is a feature that is specific to the official client, not to the bitcoin protocol. You could patch the client not to send anything except what you tell it. That would however reduce the anonymity and make it easier to track the flow of bitcoins through the network. I've been trying to figure out where all these new addresses are coming from. Would it be possible to prevent the client from doing that, or to send from a specific address? This way an address could become associated as "mine" and be trusted, much like people receiving to a specific address continually. This has been answered elsewhere but, if I'm understanding this stuff, your Bitcoin client creates the addresses itself. Each address has a public and a private key associated with them. The fact that you and only you have the private key makes them, by definition, yours. (Possession is 100% of the Bitcoin law:) You can use a single address over and over if you want but that makes your transactions easier to track. If you're after anonymity then this reduces it. Title: Re: Race Conditions Between Transactions and Wallet Backup Post by: ribuck on February 22, 2011, 11:24:58 AM Quote Only sends use an address, and each send can only use 0 or 1 address. And, of course, clicking "New..." in the client uses 1 address. |