Bitcoin Forum
December 07, 2016, 04:27:28 PM *
News: To be able to use the next phase of the beta forum software, please ensure that your email address is correct/functional.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: [SOLVED]Lost some Bitcoins, what did I do wrong?  (Read 1506 times)
jamoes
Member
**
Offline Offline

Activity: 89


View Profile
June 11, 2011, 06:52:23 AM
 #1

I seemed to have lost some bitcoins, only 0.01, so not really a big deal, but this scares me. I'd like to get a better understanding of exactly where I went wrong. Here's the steps I followed:

1. Closed my Bitcoin client.
2. Copied wallet.dat to wallet-savings.dat
3. Transferred 0.01 BTC from my BTC Guild account to an address from wallet.dat.
4. Copied wallet-savings.dat over wallet.dat.
5. Opened up my Bitcoin client, and waited until the transaction showed up. After the blockchain caught up, the transaction, and the 0.01 BTC were there.
6. Closed my bitcoin client, and copied wallet-savings.dat over wallet.dat.
7. Re-opened my bitcoin client - this time the transaction never showed up. It's been a few hours now, and the transaction still isn't there - I seem to have lost that 0.01 BTC forever.

Obviously, step 6 was where I went wrong. I should never have just overwritten my wallet.dat. However, I did it somewhat intentionally, since I figured that the transaction should show up again, and I wanted to test that hypothesis.

So, what happened? If restoring from backup in step 4 didn't mess anything up, why did it break when I overwrote it the second time?

Thanks for any help. I'd really like to understand this so I don't mess anything up when dealing with larger amount of bitcoins.
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1481128048
Hero Member
*
Offline Offline

Posts: 1481128048

View Profile Personal Message (Offline)

Ignore
1481128048
Reply with quote  #2

1481128048
Report to moderator
1481128048
Hero Member
*
Offline Offline

Posts: 1481128048

View Profile Personal Message (Offline)

Ignore
1481128048
Reply with quote  #2

1481128048
Report to moderator
1481128048
Hero Member
*
Offline Offline

Posts: 1481128048

View Profile Personal Message (Offline)

Ignore
1481128048
Reply with quote  #2

1481128048
Report to moderator
nazgulnarsil
Full Member
***
Offline Offline

Activity: 224


View Profile
June 11, 2011, 07:02:13 AM
 #2

explain what's getting copied more clearly.
FreeMoney
Legendary
*
Offline Offline

Activity: 1246


Strength in numbers


View Profile WWW
June 11, 2011, 07:09:32 AM
 #3

I don't get it. Shouldn't 6 have done nothing at all? What were you hoping to do?

Play Bitcoin Poker at sealswithclubs.eu. We're active and open to everyone.
jamoes
Member
**
Offline Offline

Activity: 89


View Profile
June 11, 2011, 07:09:53 AM
 #4

explain what's getting copied more clearly.

Step 2 was this command:
cp ~/Library/Application\ Support/Bitcoin/wallet.dat ~/Library/Application\ Support/Bitcoin/wallet-savings.dat

Step 4 was this command:
cp ~/Library/Application\ Support/Bitcoin/wallet-savings.dat ~/Library/Application\ Support/Bitcoin/wallet.dat

And Step 6 was also this command:
cp ~/Library/Application\ Support/Bitcoin/wallet-savings.dat ~/Library/Application\ Support/Bitcoin/wallet.dat
jamoes
Member
**
Offline Offline

Activity: 89


View Profile
June 11, 2011, 07:10:38 AM
 #5

I don't get it. Shouldn't 6 have done nothing at all? What were you hoping to do?

Yeah, exactly, Stop 6 shouldn't have done anything I thought. I was really surprised when I opened up the client and the transaction was gone.

edit: What is was hoping to do was experiment. I wanted to confirm that the transaction would indeed show up again.
Dude65535
Full Member
***
Offline Offline

Activity: 126


View Profile
June 11, 2011, 07:49:49 AM
 #6

try bitcoin.exe -rescan and see if that helps.

1DCj8ZwGZXQqQhgv6eUEnWgsxo8BTMj3mT
jamoes
Member
**
Offline Offline

Activity: 89


View Profile
June 11, 2011, 07:58:49 AM
 #7

try bitcoin.exe -rescan and see if that helps.

I deleted the whole blockchain, and it's re-downloading now. I suspect -rescan would have had the same effect, but just been faster.

From what it sound like, this should bring back my transaction. I'll report back here when I have the results. Thanks for your help!
jamoes
Member
**
Offline Offline

Activity: 89


View Profile
June 11, 2011, 08:39:04 AM
 #8

Re-downloading the blockchain worked! (so did -rescan, which I tried from a different computer, and it was much faster).

I'd consider my experiment a success, since I now have a better understanding of how the bitcoin client actually finds transactions. Thanks for your help!
joan
Jr. Member
*
Offline Offline

Activity: 56



View Profile
June 11, 2011, 08:48:47 AM
 #9

From what I understand:
- The few transactions pertaining to addresses in your wallet (shown in the UI) are stored in the wallet.dat file itself.
- They are only stored when the block containing them is downloaded. Upon download, the block is parsed and wallet updated on the fly with the new TX.
- On step 5, your client download the block with the TX. Updates wallet.dat.
- On step 6, your re-erase the wallet with the old copy. But the block with the TX has already been downloaded and consolidated in blkindex.dat and blk0001.dat.
- The client doesn't realize that the wallet.dat doesn't know about the TX in blocks already downloaded. The UI only shows the TX history found in the old wallet.dat.
- The -rescan option allows the client to rescan the blocks and update the wallet.dat with transaction it's involved in.

jamoes
Member
**
Offline Offline

Activity: 89


View Profile
June 11, 2011, 09:05:34 AM
 #10

From what I understand:
- The few transactions pertaining to addresses in your wallet (shown in the UI) are stored in the wallet.dat file itself.
- They are only stored when the block containing them is downloaded. Upon download, the block is parsed and wallet updated on the fly with the new TX.
- On step 5, your client download the block with the TX. Updates wallet.dat.
- On step 6, your re-erase the wallet with the old copy. But the block with the TX has already been downloaded and consolidated in blkindex.dat and blk0001.dat.
- The client doesn't realize that the wallet.dat doesn't know about the TX in blocks already downloaded. The UI only shows the TX history found in the old wallet.dat.
- The -rescan option allows the client to rescan the blocks and update the wallet.dat with transaction it's involved in.



This sounds exactly correct based on what I experienced. Thanks for the detailed explanation.

I think a good solution would be to have wallet.dat also store the most recent block that it has knowledge of, this way when the client boots up, it knows how many blocks need to be rescanned, and it can rescan those automatically (not that I'd expect the devs to actually implement this - just an idea off the top of my head). Either way, I'm just happy to have a better understanding, and happy that it's not so easy to lose bitcoins!
joan
Jr. Member
*
Offline Offline

Activity: 56



View Profile
June 11, 2011, 09:32:49 AM
 #11

I think a good solution would be to have wallet.dat also store the most recent block that it has knowledge of, this way when the client boots up, it knows how many blocks need to be rescanned, and it can rescan those automatically (not that I'd expect the devs to actually implement this - just an idea off the top of my head). Either way, I'm just happy to have a better understanding, and happy that it's not so easy to lose bitcoins!

Hmm, after reading the source a bit more, it looks like this behavior is implemented already. There is a "bestblock" entry in the wallet.dat, and upon client initialization, it is compared to the bestblock of the blkindex.dat. If the wallet is missing some, a partial rescan is triggered.
So in the end, it should have worked right away…
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!