Bitcoin Forum

Bitcoin => Bitcoin Technical Support => Topic started by: Arsenal on May 03, 2011, 10:08:08 PM



Title: Bitcoin -rescan questions
Post by: Arsenal on May 03, 2011, 10:08:08 PM
Someone told me that if I decrypt my wallet.dat and put it back in its original location that the BTC balance the client says could differ from the useable number of BTC in that wallet.dat unless I use -rescan or redownload the entire block chain.

My questions are:
1. After I use -rescan would there be any situation where the client would display a balance different from the number of BTC I could actually spend/use?
2. How long does -rescan take or is there a way to display its progress other than watching the LED's on the front of my case?
3. Is there anyway to know if my current downloaded blockchain is corrupted or incorrect in any way?
4. Is there any reason not to start bitcoin with -rescan?

Thanks.


Title: Re: Bitcoin -rescan questions
Post by: BitterTea on May 03, 2011, 10:10:06 PM
You may not need to use -rescan anymore. As of the latest version (0.3.21, I think) the client stores the index of the last scanned block in the wallet. Once the client starts (or is it before?), it will automatically rescan all block after the stored index, finding any transactions not already in the wallet.


Title: Re: Bitcoin -rescan questions
Post by: theymos on May 04, 2011, 02:26:53 AM
-rescan is apparently broken for 0-confirmation transactions. In cases where a 0-confirmation transaction gets stuck, you'll have to delete the block database files. It'll be obvious when this happens.


Title: Re: Bitcoin -rescan questions
Post by: BitterTea on May 04, 2011, 03:16:19 AM
Yep, I've had that happen a few times. Probably because I was switching between wallets so running with -rescan all the time.


Title: Re: Bitcoin -rescan questions
Post by: Pieter Wuille on May 05, 2011, 12:36:45 PM
-rescan is apparently broken for 0-confirmation transactions. In cases where a 0-confirmation transaction gets stuck, you'll have to delete the block database files. It'll be obvious when this happens.

Rescan is for searching the block chain for transactions that are from or to one of your addresses. A 0-confirmation transaction is one that never made it into the block chain. This could be because it was never transmitted, because it was ignored by miners for a while, or because it conflicts somehow with other transactions. If deleting and redownloading the block chain does make a difference, there is something seriously wrong, and we have a bug to fix.


Title: Re: Bitcoin -rescan questions
Post by: theymos on May 05, 2011, 12:40:42 PM
If deleting and redownloading the block chain does make a difference, there is something seriously wrong, and we have a bug to fix.

That's what I mean. Once a transaction gets stuck at 0 confirmations (in the block chain, but not detected by the client), deleting the block database will help, but -rescan won't.

I haven't had this happen to me, but I've read several cases of it on the forum.


Title: Re: Bitcoin -rescan questions
Post by: AvL42 on October 07, 2012, 03:07:02 PM
While this topic is a bit aged, I hope that someone still "watches" it...

It's not clear to me, what -rescan actually does:
  Does it scan the local copy of the blockchain in order to update
       any wrong/missing transactions in the wallet,
  or does it verify the local copy of the blockchain itself through the net?

I've got some transactions in the wallet that were never confirmed,
and the bitcoin client doesn't ever seem to "forget" about them, nor
allow me to manually purge them.

Since the transactions were never confirmed, I don't expect my local
blockchain to be wrong with respect to these transactions, so wouldn't
want to risk wasting almost 4GB extra traffic.

Is -rescan the right tool for my problem, or is there some tool to
purge table-lines from the wallet.dat at the command-line(linux), or is
calling dumpprivkey on all my addresses, then removing the wallet
and importprivkey'ing them into the new wallet the only way to fix it?


Title: Re: Bitcoin -rescan questions
Post by: Pieter Wuille on October 07, 2012, 03:08:29 PM
-rescan scans the local block chain copy for transactions that are missing from the wallet.

It does not remove transactions from the wallet which are in conflict with it.


Title: Re: Bitcoin -rescan questions
Post by: nomnomnom on October 07, 2012, 10:18:12 PM
Hello,

I've got some transactions in the wallet that were never confirmed,
and the bitcoin client doesn't ever seem to "forget" about them, nor
allow me to manually purge them.

one time I fixed a wallet like this, by deleting all transactions with pywallet (https://github.com/jackjack-jj/pywallet)
Start it with the --web option then scroll down to delete keys, select tx and type all. Afterwards start bitcoin with the -rescan option.

But please make backups first in case something goes wrong. Related thread: https://bitcointalk.org/index.php?topic=105041.0


Title: Re: Bitcoin -rescan questions
Post by: Werner on October 08, 2012, 07:07:45 AM
just learned that rescan aso can fix my problem. thank!