wallet RPC to double-check the calculated balance #28898

issue maflcko openend this issue on November 17, 2023
  1. maflcko commented at 8:58 am on November 17, 2023: member

    Please describe the feature you’d like to see added.

    Sometimes a user may put in the wrong birthdate when calling importdescriptors.

    Adding a checkbalance RPC (or a check argument to the getbalances RPC) to check that the calculated balance is correct by re-calculating it in a different way may be a solution. It could iterate over the utxo set for the check and then instruct for a rescan to restore missing transaction history and balance, if two different balances were calculated.

    #28897

    Describe the solution you’d like

    No response

    Describe any alternatives you’ve considered

    No response

    Please leave any additional context

    No response

  2. maflcko added the label Feature on Nov 17, 2023
  3. maflcko added the label Wallet on Nov 17, 2023
  4. maflcko added the label RPC/REST/ZMQ on Nov 17, 2023
  5. fjahr commented at 5:37 pm on November 23, 2023: contributor
    Allowing to call importdescriptors with the same descriptor but a different birthdate may also be a solution? Are users only interested in spendable outputs or may they also be interested in their transaction history in general?
  6. furszy commented at 9:17 pm on November 23, 2023: member
    An alternative/parallel course of action could be making rescanblockchain much faster. Removing the need for additional RPC calls to identify any missing tx. <start_shill> The user can build the block filter index in 5-10 minutes using #26966 (per Sjors’s benchmark). And, with it, rescanblockchain performs at a completely different speed level. <end_shill>
  7. maflcko commented at 8:56 am on November 24, 2023: member

    An alternative/parallel course of action could be making rescanblockchain much faster. Removing the need for additional RPC calls to identify any missing tx.

    I don’t think this is an alternative, because the rescan won’t find the txs if the birthdate is wrong, see also #28897? Moreover, on hardware without parallel cores, building the block filter index is not going to be sped up. Finally, on wallets with a sufficient number of keys, the blockfilter rescan may take longer than a “traditional” rescan, or at least time in the same magnitude.

  8. furszy commented at 2:23 pm on November 24, 2023: member

    the rescan won’t find the txs if the birthdate is wrong

    The birth time check resides on the ‘block connected’ event handler. It does not affect the rescanblockchain functionality. Users can utilize it to identify missing transactions.

    see also #28897

    Fixed it few days ago, see #28920.

    Moreover, on hardware without parallel cores, building the block filter index is not going to be sped up

    That’s true, but it’s not a reason not to do it. The entire node is multi-threaded, and the user will need to call rescanblockchain sooner or later to obtain the latest wallet state (use missing tx outputs, see the final balance, etc.)

    I’m not going against your proposed changes (the getbalances scan_utxoset=true sounds good for me). But, just as a clarification; the user will still need to call rescanblockchain after calling getbalances to detect the transaction(s) history and any other possible branches of it. For instance, could be a case where the spendable utxo is part of a chain of transactions, so the wallet will need to scan the chain backwards. Which could also cause the wallet to surpass the look-ahead window (the 1k key pool), which could make the wallet identify other transactions along the way.

  9. S3RK commented at 3:43 pm on November 25, 2023: contributor

    Allowing to call importdescriptors with the same descriptor but a different birthdate may also be a solution? Are users only interested in spendable outputs or may they also be interested in their transaction history in general?

    This is already possible btw.

    Can we always double-check balance after importdescriptors? Why ask users to call a second RPC manually if we can do it automatically for them?


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-12-23 09:12 UTC

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