rescanning uses incorrect date for old transactions #6662

issue dooglus openend this issue on September 11, 2015
  1. dooglus commented at 6:34 pm on September 11, 2015: contributor

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

    0bitcoind -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:

    0wtx.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

    0TxItems 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:

    0wtx.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.

  2. laanwj added the label Wallet on Sep 22, 2015
  3. ryanofsky commented at 4:39 pm on August 31, 2017: contributor

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

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

  4. thejohnha commented at 2:38 pm on September 29, 2020: none
    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 🙏🙏🙏
  5. kouloumos commented at 8:00 pm on August 4, 2022: 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.
  6. MarcoFalke commented at 6:24 am on August 5, 2022: member
    Ok, closing for now. Can be reopened if the fix didn’t work.
  7. MarcoFalke closed this on Aug 5, 2022

  8. bitcoin locked this on Aug 5, 2023

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-11-17 15:12 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me