Skip to content

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

Closed

Description

@achow101

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.

Activity

  1. maflcko commented on May 1, 2023

    @maflcko
    Member

    Is this still an issue with a recent version of Bitcoin Core? If yes, what are the steps to reproduce?

  2. josibake commented on May 1, 2023

    @josibake
    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

  3. maflcko commented on May 22, 2023

    @maflcko
    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.

  4. maflcko commented on May 22, 2023

    @maflcko
    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?

  5. sipa commented on May 22, 2023

    @sipa
    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.

  6. maflcko commented on May 22, 2023

    @maflcko
    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?

  7. sipa commented on May 22, 2023

    @sipa
    Member

    @MarcoFalke Oh, I see! That's a different matter.

  8. instagibbs commented on Nov 16, 2023

    @instagibbs
    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?

  9. instagibbs commented on Nov 16, 2023

    @instagibbs
    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

  10. locked and limited conversation to collaborators on Nov 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions