wallet: remove unused DummySignTx and CKeyPool from GetReservedDestination #25881

pull furszy wants to merge 2 commits into bitcoin:master from furszy:2022_wallet_clean_ckeypool changing 3 files +14 −27
  1. furszy commented at 1:55 AM on August 20, 2022: member

    Grouped few simple cleanups, found them while was doing other stuff (similar to #25526).

    1. No need to return a CKeyPool on GetReservedDestination.
    2. Removed CKeyPool constructors from wallet.cpp as them should only be part of the legacy spkm.
    3. Remove unused CWallet::DummySignTx.
  2. DrahtBot added the label Wallet on Aug 20, 2022
  3. DrahtBot commented at 6:21 AM on August 20, 2022: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    Stale ACK aureleoules, w0xlt, fanquake

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #27865 (wallet: Track no-longer-spendable TXOs separately by achow101)

    If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

  4. aureleoules commented at 9:26 AM on August 22, 2022: contributor

    ACK ce81b9a4fa821e92813e62d15d0b1ce5131e0a2e.

    c88092403d42d15714f6cd72a39528859c8c2725: verified that the keypool argument can be removed without altering the behavior of the code 310f25e42a98c05c467c03b8df761c00f16ab214: looks better and is the prefered way for initializing class members :+1: ce81b9a4fa821e92813e62d15d0b1ce5131e0a2e: verified that this overloaded function is unused

  5. w0xlt approved
  6. fanquake requested review from achow101 on Aug 22, 2022
  7. in src/wallet/wallet.cpp:2601 in c88092403d outdated
    2472 | -        auto op_address = m_spk_man->GetReservedDestination(type, internal, nIndex, keypool);
    2473 | +        auto op_address = m_spk_man->GetReservedDestination(type, internal, nIndex);
    2474 |          if (!op_address) return op_address;
    2475 |          address = *op_address;
    2476 | -        fInternal = keypool.fInternal;
    2477 | +        fInternal = internal;
    


    achow101 commented at 6:44 PM on August 23, 2022:

    I'm pretty sure that this is actually incorrect.

    internal and keypool.fInternal will not always be the same. For wallets before HD chain split, internal=true will still result in keypool.fInternal=false. Later, ReserveDestination.fInternal is used by ReturnDestination in order to put the kepool data back into the correct keypool set, and the correct set is determined by the value of ReserveDestionation.fInternal.

    With a pre-split wallet or wallets with a pre-split keypool, with this change we will end up placing returned destinations to the internal keypool where they should go into the external keypool or the pre-split keypool. Since we decide which set to fetch new keypool keys from by using the feature flags, for such wallets we will not choose the internal keypool as the flags indicate that is not supported. Thus with such wallets, we are just throwing away change addresses rather than correctly returning them to the keypool.


    furszy commented at 1:45 PM on August 24, 2022:

    hmm true, good catch. The code is quite entangled there.

    You know, the legacy version of ReturnDestination should be checking whether the wallet is pre-split or not to return the key to the proper place as ReserveKeyFromKeyPool is doing.. and not just place it into the internal pool directly if the internal flag is true.

    Another thing that looks like an existent bug is what happens when the wallet takes the last key from the pre-split keypool:

    1. ReserveKeyFromKeyPool will erase the last key index from set_pre_split_keypool. Leaving the set empty.
    2. As set_pre_split_keypool is empty, ReturnDestination will not return the index to set_pre_split_keypool and wrongly push it inside setExternalKeyPool (because before return the index into the pre-split set we are checking that the set is not empty).
  8. DrahtBot added the label Needs rebase on Oct 13, 2022
  9. fanquake commented at 5:05 PM on December 6, 2022: member

    @furszy what are the next steps here? This has two ACKs, but they can be discarded, given the issue pointed out by achow. Are you planning up updating this to drop that commit (c88092403d42d15714f6cd72a39528859c8c2725), or follow up with different changes? If you're not actively working on this at the moment, do you want to turn this into a draft until it's ready for review again?

  10. furszy commented at 5:50 PM on December 6, 2022: member

    @furszy what are the next steps here? This has two ACKs, but they can be discarded, given the issue pointed out by achow. Are you planning up updating this to drop that commit (c880924), or follow up with different changes? If you're not actively working on this at the moment, do you want to turn this into a draft until it's ready for review again?

    yeah, IIRC I found an existent bug in the legacy wallet while was checking achow's comment (https://github.com/bitcoin/bitcoin/pull/25881#discussion_r953824206).

    Will move it to draft until I'm able to get back to it. I don't think that the other two cleanup commits alone worth enough to ping reviewers.

  11. furszy marked this as a draft on Dec 6, 2022
  12. wallet: don't return CKeyPool on GetReservedDestination ddb415426b
  13. wallet: initialize CKeyPool members in the header
    removing the constructors from wallet.cpp
    56d4e97a7e
  14. furszy force-pushed on Mar 31, 2023
  15. DrahtBot removed the label Needs rebase on Apr 2, 2023
  16. DrahtBot added the label CI failed on May 30, 2023
  17. DrahtBot removed the label CI failed on May 31, 2023
  18. furszy commented at 3:44 PM on December 3, 2023: member

    Closing it for now. Have other PRs with more priority than this one.

  19. furszy closed this on Dec 3, 2023

  20. bitcoin locked this on Dec 2, 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: 2026-04-16 00:13 UTC

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