Author

Topic: Lost a Bitcoin? I found one. (Read 2887 times)

sr. member
Activity: 266
Merit: 250
June 15, 2011, 01:36:42 PM
#11
This is just a guess.  What do you think?  I'm all for squashing bugs when it comes to our money!
You were running 0.3.23, right?
OK, I lied a little in my description of how it occurred, in the interest of simplification.  I actually created the wallet.dat file on LinuxCoin, using the version of Bitcoin that's on their 0.2a release.  Given that it came out on May 6, I don't think that my wallet.dat file was created on 0.3.23 of Bitcoin.

However, the rest of my story is pretty accurate, and the software that I tried loading the wallet.dat file onto was 0.3.23.  Well, it was downloaded today (as the latest release), so I am pretty certain that's the version number, although I am not in a position to check.
legendary
Activity: 1204
Merit: 1015
June 15, 2011, 01:11:19 PM
#10
This is just a guess.  What do you think?  I'm all for squashing bugs when it comes to our money!
You were running 0.3.23, right?
sr. member
Activity: 373
Merit: 250
June 15, 2011, 12:41:29 PM
#9
I experienced the exact same thing when creating my "Savings account" wallet the other night, fixed with the -rescan option.  Definitely a bug in the "check if I need to rescan" code.  Thanks!
sr. member
Activity: 266
Merit: 250
June 15, 2011, 10:42:52 AM
#8
(The answer is that it's in a block that was already received and processed (in step 11), and so Bitcoin isn't going to process it again, unless instructed to.  They aren't really lost, they're hidden in the Block Chain, and your client program isn't going to go look for them, unless you tell it to.  The client program thinks it has already processed all those old blocks.)

It is the 3rd time I see this reported, so the issue is probably real. I say issue because as far as I can see, there is actually code in the client to automatically rescan the few blocks that the wallet is not aware of that are already in the local blockchain.
(init.cpp)

The wallet file keeps track of the last block it has synchronized with.
When I try this experiment with a single wallet and an older copy of this wallet, the rescan of the few new blocks is automatic.

@Joan-
Hmm, boy, you are right.  The code seems to be there.  Here it is, along with my notes in bold:


    CBlockIndex *pindexRescan = pindexBest;                  # Set two values to be EQUAL
    if (GetBoolArg("-rescan"))
        pindexRescan = pindexGenesisBlock;
    else
    {
        CWalletDB walletdb;
        CBlockLocator locator;
        if (walletdb.ReadBestBlock(locator))                      # Some conditional *
            pindexRescan = locator.GetBlockIndex();            # Conditionally set one of the values to something else
    }
    if (pindexBest != pindexRescan)                                # Check to see if the two values are EQUAL
    {
        printf("Rescanning last %i blocks (from block %i)...\n", pindexBest->nHeight - pindexRescan->nHeight, pindexRescan->nHeight);
        nStart = GetTimeMillis();
        ScanForWalletTransactions(pindexRescan);
        printf(" rescan %15"PRI64d"ms\n", GetTimeMillis() - nStart);
    }


So, my deductive skills tell me that the conditional marked with a "*" is not True for me. 
In other words, walletdb.ReadBestBlock(locator) is False when you are using a new wallet.
And it's true when you use an old used wallet (as you did in your experiment).

This is just a guess.  What do you think?  I'm all for squashing bugs when it comes to our money!


Thanks for posting this info. I sent you a small tip for being awesome and helping out the community.
THANK YOU dacoinminster!
legendary
Activity: 1260
Merit: 1031
Rational Exuberance
June 15, 2011, 10:06:03 AM
#7
If you've been messing with your wallet.dat file, and "lose" a bitcoin in the process, this tip might help you out.  (This is probably old news for the long timers, but I think this might benefit someone!)

If you start bitcoin with the -rescan option, the block chain is rescanned looking for any bitcoin transactions that pertain to your current wallet.  So make sure you try that!


Here's what I did to lose, and subsequently find, a bitcoin.

 1. I've been running my client program, where I have say 50 Bitcoins.
 2. I ended my client program
 3. I backed up my wallet.dat file, and then renamed it to wallet_50btc.dat
 4. Start the client program, and generate a fresh new wallet with a new wallet ID, new private keys, etc. 
 5. Copy my new Bitcoin Address to notepad
 6. Terminate the client program
 7. Rename wallet.dat to wallet_0btc.dat
 8. Rename wallet_50.dat to wallet.dat
 9. Start the client program.  All looks good, I have 50 Bitcoins.
 10. Pay 1 BTC to my new Bitcoin Address that I had copied to notepad.
 11. Wait for at least 1 confirmation.  (I wanted to make sure that I got my change!). Now my balance is 1 less, i.e. 49 BTC.
 12. Terminate the client program.
 13. Rename wallet.dat to wallet_49btc.dat
 14. Rename wallet_0btc.dat to wallet.dat
 15. Start the client.  The wallet is empty.  Where'd the 1 BTC go?

 (The answer is that it's in a block that was already received and processed (in step 11), and so Bitcoin isn't going to process it again, unless instructed to.  They aren't really lost, they're hidden in the Block Chain, and your client program isn't going to go look for them, unless you tell it to.  The client program thinks it has already processed all those old blocks.)

 To re-find the lost coin:
 16. terminate the client.
 17. run the client with -rescan option.  After processing all the blocks, the 1 BTC shows up in the client.

Hopefully this helps someone find some lost Bitcoins.  If so, I'll gladly accept a cut!
Reference: https://en.bitcoin.it/wiki/Running_Bitcoin



Thanks for posting this info. I sent you a small tip for being awesome and helping out the community.
full member
Activity: 210
Merit: 100
firstbits: 121vnq
June 15, 2011, 09:35:36 AM
#6
How do you do that, if you use the bitcoin client for Max OSX?

Where can one enter the "-rescan" command?

Thanx

Mac OSX    $HOME/Library/Application Support/Bitcoin/    /Users/username/Library/Application Support/Bitcoin/bitcoin.conf

https://en.bitcoin.it/wiki/Running_Bitcoin#Mac

Well let's see, you linked to the incorrect directory (unless you want to edit that config file so it always runs with rescan and an empty wiki. We can do better Smiley )

Instead of using the application icon, you need to actually go inside of it and run it from the terminal so you can enter a command line argument.

1) Open a terminal
2) Go to Applications/Bitcoin.app/Contents/MacOS/

(if you didn't know that you could step into apps, now you do)

3) now type ./bitcoin -rescan

Bitcoin should open up and rescan the block chain for your transactions

jr. member
Activity: 56
Merit: 1
June 15, 2011, 08:41:08 AM
#5
(The answer is that it's in a block that was already received and processed (in step 11), and so Bitcoin isn't going to process it again, unless instructed to.  They aren't really lost, they're hidden in the Block Chain, and your client program isn't going to go look for them, unless you tell it to.  The client program thinks it has already processed all those old blocks.)

It is the 3rd time I see this reported, so the issue is probably real. I say issue because as far as I can see, there is actually code in the client to automatically rescan the few blocks that the wallet is not aware of that are already in the local blockchain.
(init.cpp)

The wallet file keeps track of the last block it has synchronized with.
When I try this experiment with a single wallet and an older copy of this wallet, the rescan of the few new blocks is automatic.
full member
Activity: 350
Merit: 100
June 15, 2011, 08:32:35 AM
#4
cool nice tip!
i would have panicked if that happened to me lol
donator
Activity: 1736
Merit: 1014
Let's talk governance, lipstick, and pigs.
June 15, 2011, 08:09:51 AM
#3
How do you do that, if you use the bitcoin client for Max OSX?

Where can one enter the "-rescan" command?

Thanx

Mac OSX    $HOME/Library/Application Support/Bitcoin/    /Users/username/Library/Application Support/Bitcoin/bitcoin.conf

https://en.bitcoin.it/wiki/Running_Bitcoin#Mac
full member
Activity: 182
Merit: 100
June 15, 2011, 07:14:08 AM
#2
How do you do that, if you use the bitcoin client for Max OSX?

Where can one enter the "-rescan" command?

Thanx
sr. member
Activity: 266
Merit: 250
June 15, 2011, 06:55:52 AM
#1
If you've been messing with your wallet.dat file, and "lose" a bitcoin in the process, this tip might help you out.  (This is probably old news for the long timers, but I think this might benefit someone!)

If you start bitcoin with the -rescan option, the block chain is rescanned looking for any bitcoin transactions that pertain to your current wallet.  So make sure you try that!


Here's what I did to lose, and subsequently find, a bitcoin.

 1. I've been running my client program, where I have say 50 Bitcoins.
 2. I ended my client program
 3. I backed up my wallet.dat file, and then renamed it to wallet_50btc.dat
 4. Start the client program, and generate a fresh new wallet with a new wallet ID, new private keys, etc. 
 5. Copy my new Bitcoin Address to notepad
 6. Terminate the client program
 7. Rename wallet.dat to wallet_0btc.dat
 8. Rename wallet_50.dat to wallet.dat
 9. Start the client program.  All looks good, I have 50 Bitcoins.
 10. Pay 1 BTC to my new Bitcoin Address that I had copied to notepad.
 11. Wait for at least 1 confirmation.  (I wanted to make sure that I got my change!). Now my balance is 1 less, i.e. 49 BTC.
 12. Terminate the client program.
 13. Rename wallet.dat to wallet_49btc.dat
 14. Rename wallet_0btc.dat to wallet.dat
 15. Start the client.  The wallet is empty.  Where'd the 1 BTC go?

 (The answer is that it's in a block that was already received and processed (in step 11), and so Bitcoin isn't going to process it again, unless instructed to.  They aren't really lost, they're hidden in the Block Chain, and your client program isn't going to go look for them, unless you tell it to.  The client program thinks it has already processed all those old blocks.)

 To re-find the lost coin:
 16. terminate the client.
 17. run the client with -rescan option.  After processing all the blocks, the 1 BTC shows up in the client.

Hopefully this helps someone find some lost Bitcoins.  If so, I'll gladly accept a cut!
Reference: https://en.bitcoin.it/wiki/Running_Bitcoin

Jump to: