8000 wallet: remove unused DummySignTx and CKeyPool from GetReservedDestination by furszy · Pull Request #25881 · bitcoin/bitcoin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

wallet: remove unused DummySignTx and CKeyPool from GetReservedDestination #25881

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from

Conversation

furszy
Copy link
Member
@furszy furszy commented Aug 20, 2022

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.

@DrahtBot
Copy link
Contributor
DrahtBot commented Aug 20, 2022

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

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.

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.

Copy link
Contributor
@aureleoules aureleoules left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK ce81b9a.

c880924: verified that the keypool argument can be removed without altering the behavior of the code
310f25e: looks better and is the prefered way for initializing class members 👍
ce81b9a: verified that this overloaded function is unused

Copy link
Contributor
@w0xlt w0xlt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK ce81b9a

@fanquake fanquake requested a review from achow101 August 22, 2022 14:02
Comment on lines -2475 to +2601
fInternal = keypool.fInternal;
fInternal = internal;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Member Author
@furszy furszy Aug 24, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

@fanquake
Copy link
Member
fanquake commented Dec 6, 2022

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

@furszy
Copy link
Member Author
furszy commented Dec 6, 2022

@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 (#25881 (comment)).

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.

@furszy furszy marked this pull request as draft December 6, 2022 17:50
@furszy
Copy link
Member Author
furszy commented Dec 3, 2023

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

@furszy furszy closed this Dec 3, 2023
@bitcoin bitcoin locked and limited conversation to collaborators Dec 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0