Bitcoin Forum
December 03, 2016, 12:36:48 AM *
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: Lost a Bitcoin? I found one.  (Read 2595 times)
jerfelix
Sr. Member
****
Offline Offline

Activity: 266


View Profile
June 15, 2011, 11: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

Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
1480725408
Hero Member
*
Offline Offline

Posts: 1480725408

View Profile Personal Message (Offline)

Ignore
1480725408
Reply with quote  #2

1480725408
Report to moderator
1480725408
Hero Member
*
Offline Offline

Posts: 1480725408

View Profile Personal Message (Offline)

Ignore
1480725408
Reply with quote  #2

1480725408
Report to moderator
elements
Full Member
***
Offline Offline

Activity: 182


View Profile
June 15, 2011, 12:14:08 PM
 #2

How do you do that, if you use the bitcoin client for Max OSX?

Where can one enter the "-rescan" command?

Thanx

»A common mistake that people make when trying to design something completely foolproof was to underestimate the ingenuity of complete fools.« - Douglas Adams
Use the trusted German Bitcoin exchange: https://www.bitcoin.de/de/r/5wcwts
Tips & donations: BTC : 1MAQYNLp2VJ9wWhPYg5BnrbUGzdhGXopZw | CGB: 5bgQivyHJcSWTgvLfVW87Zj23M7mcFCVBF
cbeast
Donator
Legendary
*
Offline Offline

Activity: 1722

Let's talk governance, lipstick, and pigs.


View Profile
June 15, 2011, 01:09:51 PM
 #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

Any significantly advanced cryptocurrency is indistinguishable from Ponzi Tulips.
clonedone
Full Member
***
Offline Offline

Activity: 126



View Profile
June 15, 2011, 01:32:35 PM
 #4

cool nice tip!
i would have panicked if that happened to me lol

joan
Jr. Member
*
Offline Offline

Activity: 56



View Profile
June 15, 2011, 01:41:08 PM
 #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.
lemonginger
Full Member
***
Offline Offline

Activity: 210


firstbits: 121vnq


View Profile
June 15, 2011, 02:35:36 PM
 #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

dacoinminster
Legendary
*
Offline Offline

Activity: 1106


Rational Exuberance


View Profile WWW
June 15, 2011, 03:06:03 PM
 #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.

jerfelix
Sr. Member
****
Offline Offline

Activity: 266


View Profile
June 15, 2011, 03:42:52 PM
 #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!
Ricochet
Sr. Member
****
Offline Offline

Activity: 373



View Profile
June 15, 2011, 05: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!
Maged
Legendary
*
Offline Offline

Activity: 1260


View Profile
June 15, 2011, 06: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?

jerfelix
Sr. Member
****
Offline Offline

Activity: 266


View Profile
June 15, 2011, 06: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.
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!