Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rescanning uses incorrect date for old transactions #6662

Closed
dooglus opened this issue Sep 11, 2015 · 5 comments
Closed

rescanning uses incorrect date for old transactions #6662

dooglus opened this issue Sep 11, 2015 · 5 comments
Labels

Comments

@dooglus
Copy link
Contributor

dooglus commented Sep 11, 2015

I had a few conflicted transactions in my wallet, so I ran:

bitcoind -zapwallettxes=2

to delete them. After doing so, all my transactions from before January 2014 had a date of January 2014.

Upon checking the source code, I see this line in CWallet::AddToWallet() in wallet/wallet.cpp:

wtx.nTimeSmart = std::max(latestEntry, std::min(blocktime, latestNow));

blocktime is the time I want to see in my transactions, latestNow is much bigger, and so the min() returns the time I want, but latestEntry is January 2014, and so that's the time that is used for all my old transactions.

I'm not entirely clear how the Jan 2014 date is being found, since -zapwallettxes is meant to delete all the transactions and rescan to find them again, but it seems that

TxItems txOrdered = OrderedTxItems(acentries);

is finding a transaction from 2014, even after all transactions have been deleted.

I tried replacing the nTimeSmart = max(min()) code with this:

wtx.nTimeSmart = std::min(blocktime, latestNow);

then re-ran with the -zap flag, and now I see the correct dates next to all of my transactions.

@laanwj laanwj added the Wallet label Sep 22, 2015
@bitcartel
Copy link

Does this still need fixing?

nTimeSmart = std::max(latestEntry, std::min(blocktime, latestNow));

@ryanofsky
Copy link
Contributor

It doesn't look like that line of code has changed since it was added in 2012 c3f95ef.

It sounds like dooglus had to remove the max with latestEntry part to avoid the problem.

@thejohnha
Copy link

I believe this is the issue causing older transactions to have incorrect dates when using the Export function out of the bitcoin-core client (GUI). It would be nice if the export function worked correctly... Many thanks 🙏🙏🙏

@kouloumos
Copy link
Contributor

The logic mentioned here was initially extracted to ComputeTimeSmart with #9369 and the issue was later fixed with #20591. See #11703 (comment) for more details.

@maflcko
Copy link
Member

maflcko commented Aug 5, 2022

Ok, closing for now. Can be reopened if the fix didn't work.

@maflcko maflcko closed this as completed Aug 5, 2022
@bitcoin bitcoin locked and limited conversation to collaborators Aug 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants