wallet: Imports with pre-existing balance somtimes don’t have any balance after a rescan #19808

issue achow101 openend this issue on August 25, 2020
  1. achow101 commented at 8:32 pm on August 25, 2020: member

    This bug has been around for a while (at least 0.17 from what I remember) but I guess no one opened an issue for it. I also have been unable to debug this at all.

    Sometimes, when importing public keys and scripts which already have a balance, the balance is not detected after the import’s rescan finishes. This has particularly occurred with the use of importmulti (but I suspect it should happen with the other import commands, I just don’t use those). Even with the timestamp set correctly and with repeated rescans afterwards using rescanblockchain, no balance is found. However later transactions involving those keys and scripts are found.

    Attempts to debug this have not been successful as this does not appear to be reproducible (attempts to intentionally reproduce this have failed).

    It is possible that this is due to user error (perhaps some timestamp thing), but if that is the case, we should probably remove this footgun.

    This issue was also described in an importmulti related PR some time ago. I’m trying to find that comment.

  2. achow101 added the label Bug on Aug 25, 2020
  3. pinheadmz assigned josibake on Apr 27, 2023
  4. maflcko commented at 8:26 am on May 1, 2023: member
    Is this still an issue with a recent version of Bitcoin Core? If yes, what are the steps to reproduce?
  5. josibake commented at 8:29 am on May 1, 2023: member

    If yes, what are the steps to reproduce?

    I am attempting to reproduce this week, will post by the end of the week if I’m successful. If I can’t reproduce, we can probably close

  6. maflcko added the label Wallet on May 22, 2023
  7. maflcko commented at 2:42 pm on May 22, 2023: member

    Closing due to lack of interest, progress and direction.

    Pull requests with improvements are always welcome. Moreover, it is possible to re-open this issue or create a new issue referencing it, if there is fresh interest.

  8. maflcko closed this on May 22, 2023

  9. maflcko commented at 2:46 pm on May 22, 2023: member
    On a related note, what about adding a checkbalance RPC (or a check argument to the getbalances RPC) to check that the cached balance is correct? It could iterate over the utxo set for the check and then instruct for a rescan to restore missing transaction history and balance?
  10. sipa commented at 2:52 pm on May 22, 2023: member

    On a related note, what about adding a checkbalance RPC (or a check argument to the getbalances RPC) to check that the cached balance is correct? It could iterate over the utxo set for the check and then instruct for a rescan to restore missing transaction history and balance?

    I don’t like that, conceptually. The balance should be correct, and if there are (reproducible) bugs related to that, they should be fixed. Exposing “is the software behaving correctly” RPCs shouldn’t be needed if we’re confident in the correctness, and adding one anyway makes it hard to reason about expectations for users (when should they turn it on?).

    A consistency check, as in an optionally-enabled check that always runs (like -checkmempool and friends) independent from RPC arguments, for debugging purposes, however seems reasonable.

  11. maflcko commented at 3:03 pm on May 22, 2023: member
    The check wouldn’t be used to check that the software is behaving properly, but that the user is behaving properly. For example, when calling importdescriptors, the burden is on the user to supply the correct rescan parameters and the check RPC could help to check that, no?
  12. sipa commented at 3:06 pm on May 22, 2023: member
    @MarcoFalke Oh, I see! That’s a different matter.
  13. instagibbs commented at 3:58 pm on November 16, 2023: member

    I think I hit a version of this on 26.0 rc2.

    It seems to have found transactions from 2023 in blocks, but nothing prior, leaving everything else “unconfirmed”.

    edit: ah sorry, this is from a reindex, I’m rescanning as we speak to see if the funds re-appear.

    edit2: rescan is resolving in found funds. Is the reindex issue unrelated? Is there another issue?

  14. maflcko reopened this on Nov 16, 2023

  15. instagibbs commented at 5:13 pm on November 16, 2023: member

    sorry, my issue is unrelated since a rescan fixed it:

    https://github.com/bitcoin/bitcoin/blob/master/src/wallet/wallet.cpp#L1466

    I suspect my wallet birth date is newer than historical transactions my wallet has, causing it to miss things on reindex, which is a bit odd, but unrelated to this issue

  16. maflcko closed this on Nov 17, 2023

  17. bitcoin locked this on Nov 16, 2024

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-24 18:12 UTC

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