Skip to content

Conversation

theStack
Copy link
Contributor

@theStack theStack commented Aug 26, 2021

This PR is based on #22787 ("refactor: actual immutable pointing"), which should be reviewed first. (merged by now)

It aims to make the CWallet shared pointers actually immutable also for the dumpprivkey and dumpwallet RPC methods. For doing that, some more preparations are needed; we need a const-counterpart to the helper EnsureLegacyScriptPubKeyMan that accepts a const CWallet pointer and accordingly also returns a const LegacyScriptPubKeyMan instance. The metadata lookup in dumpwallet is changed to not need a mutable ScriptPubKeyMan instance by avoiding using the operator[] in its mapKeyMetadata map, which also avoids repeated lookups.

@DrahtBot
Copy link
Contributor

DrahtBot commented Aug 26, 2021

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #11803 (Bugfix: RPC/Wallet: Include HD key metadata in dumpwallet by luke-jr)

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.

@theStack
Copy link
Contributor Author

theStack commented Oct 2, 2021

Rebased on #22787 again (which in turn rebased on master recently).

@theStack
Copy link
Contributor Author

Rebased on #22787 again (which in turn rebased on master recently).

@laanwj
Copy link
Member

laanwj commented Nov 10, 2021

Concept ACK, making const-wallet operations take const pointers is a good precaution.

Code review ACK d150fe3

This also enables working with a const ScriptPubKeyMan which was
previously not possible due to std::map::operator[] not being const.
@maflcko
Copy link
Member

maflcko commented Nov 10, 2021

Maybe rebase once more for fun?

@theStack theStack force-pushed the 202108-refactor-const_correctness_for_further_dump_methods branch from 199d1b3 to d150fe3 Compare November 10, 2021 16:22
@theStack
Copy link
Contributor Author

Maybe rebase once more for fun?

Done 🙃

@laanwj laanwj merged commit e7feb73 into bitcoin:master Nov 10, 2021
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Nov 10, 2021
…ump{privkey,wallet}

d150fe3 refactor: use `CWallet` const shared pointers in dump{privkey,wallet} RPCs (Sebastian Falbesoner)
ec2792d refactor: use const `LegacyScriptPubKeyMan` references in dump{privkey,wallet} RPCs (Sebastian Falbesoner)
29905c0 refactor: avoid multiple key->metadata lookups in dumpwallet RPC (Sebastian Falbesoner)

Pull request description:

  ~~This PR is based on bitcoin#22787 ("refactor: actual immutable pointing"), which should be reviewed first.~~ (merged by now)

  It aims to make the CWallet shared pointers actually immutable also for the `dumpprivkey` and `dumpwallet` RPC methods. For doing that, some more preparations are needed; we need a const-counterpart to the helper `EnsureLegacyScriptPubKeyMan` that accepts a const CWallet pointer and accordingly also returns a const `LegacyScriptPubKeyMan` instance. The metadata lookup in `dumpwallet` is changed to not need a mutable `ScriptPubKeyMan` instance by avoiding using the `operator[]` in its mapKeyMetadata map, which also avoids repeated lookups.

ACKs for top commit:
  laanwj:
    Code review ACK d150fe3

Tree-SHA512: 90ac05e21f40c6d0ebb479a71c545da2fd89940b9ca3409d9f932abc983bf8830d34c45086e68880d0d1e994846fbefee7534eec142ff4268e0fa28a1a411d36
@bitcoin bitcoin locked and limited conversation to collaborators Nov 10, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants