-
Notifications
You must be signed in to change notification settings - Fork 38.8k
wallettool: add parameter to create descriptors wallet #20365
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
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
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. |
|
Concept ACK. cc @achow101 |
| spk_man->SetupGeneration(false); | ||
| } else { | ||
| wallet_instance->SetupDescriptorScriptPubKeyMans(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a followup, we should de-duplicate this logic with the setup in CWallet::Create.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is what I was thinking too. The main challenge is that CWallet::Create requires a chain object which is used in quite a few places. Other than that it does what we need. I have a few ideas how to deal with it:
a) create dummy chain object that would return only zero/null values
b) make chain argument optional and check every time before using it
c) chip away a piece of CWallet::Create that could be used without chain into a separate function
@achow101 What do you think is the best option in your opinion?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #20365 (comment)
Offhand (c) sounds great, (b) would be also be good, and it would be nice to avoid (a). The CWallet class is huge and to the extent you can pull out more functionality into standalone functions that's a good thing. Especially any functionality that does not require access to a chain state and a running node is a good candidate for being pulled out of CWallet.
Commit be164f9 from #15719 is kind of related (best viewed with git log -p -n1 -w --color-moved=dimmed_zebra be164f9cf89b123f03b926aa980996919924ee64 since github display doesn't detect moved code). It moves some online functionality out of CWallet::Create into a new CWallet::AttachChain method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @ryanofsky. The best option I think is to break apart CWallet::Create and refactor pieces of it into standalone functions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ryanofsky @achow101 thanks for the advice and the reference. I'll start working on the refactoring in separate PR as I think it's better not to mix things up.
I've extended functional tests to cover for the new parameter. Any comments on this PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #20365 (comment)
@ryanofsky @achow101 thanks for the advice and the reference. I'll start working on the refactoring in separate PR as I think it's better not to mix things up.
I've extended functional tests to cover for the new parameter. Any comments on this PR?
Looks good!
|
Concept ACK, could use some tests. |
ryanofsky
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code review ACK 173cc9b. This seems pretty nicely implemented now, with opportunities to clean up more and dedup later
| argsman.AddArg("-datadir=<dir>", "Specify data directory", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS); | ||
| argsman.AddArg("-wallet=<wallet-name>", "Specify wallet name", ArgsManager::ALLOW_ANY | ArgsManager::NETWORK_ONLY, OptionsCategory::OPTIONS); | ||
| argsman.AddArg("-debug=<category>", "Output debugging information (default: 0).", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST); | ||
| argsman.AddArg("-descriptors", "Create descriptors wallet. Only for create", ArgsManager::ALLOW_BOOL, OptionsCategory::OPTIONS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In commit "wallettool: add param to create descriptors wallet" (345e88e)
It would be good to have enforcement in ExecuteWalletToolFunc that option is only allowed for create command so existing "info" and "salvage" commands don't start accepting but ignoring this option now, and so future commands like "createfromdump" don't start accepting it in the future. Something like the following should be sufficient for now (could generalize later):
if (gArgs.IsArgSet("-descriptors") && command != "create") {
tfm::format(std::cerr, "Invalid parameter %s\n", "-descriptors");
return false;
}| spk_man->SetupGeneration(false); | ||
| } else { | ||
| wallet_instance->SetupDescriptorScriptPubKeyMans(); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: #20365 (comment)
@ryanofsky @achow101 thanks for the advice and the reference. I'll start working on the refactoring in separate PR as I think it's better not to mix things up.
I've extended functional tests to cover for the new parameter. Any comments on this PR?
Looks good!
|
ACK 173cc9b |
|
Seems like this might be ready for merge. This is a straightforward change just adding a wallet tool create option. Does it need more review than it's had? |
maflcko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK 173cc9b 🌠
Show signature and timestamp
Signature:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
Concept ACK 173cc9b7be335b5dd2cc1bb112dfa6ec5c13ec12 🌠
-----BEGIN PGP SIGNATURE-----
iQGzBAEBCgAdFiEE+rVPoUahrI9sLGYTzit1aX5ppUgFAlwqrYAACgkQzit1aX5p
pUjIpQwAlXytp2z5vbVReXA/veIXFvDMMsHQCJBIpjvM61YRxzJjRe7YkSGePpn9
Fbzo63khb6/kxkof6JHlCXh8yJTUAXh+UHnB2idQIguB1tmVfkNRECSlK1mPqupW
mVSUespLsvufihKzMWbwcLsMUc4l1YoYd+6BbcmdS3I/FAK1SnAgYi9dxYDpoB9c
VYXu2ddaA6YQHtCbgMM6HgFlKmbfgTLeWiakt6jf2KaUr/PzoX8TBS0HOTQR2xpp
ePtZ25tVsp0BhyyZqeuYShofWeK2a0TaQPXam0+cMzMzGh2xF4p+hqfcwI4qFHX5
nLQUlfVgPDjU8O5MA892s+VXNPn47XacFhNa2Bnb3FuYA6ipJ5SVIm6bKArA/GD5
ZXfw4O9JdLE8yIb72GP0pDUcWDIsvdP2kfTR4HxScyjfPJZ4RwbtYTV34gBJrJkA
yi0iMGPHJefSur8nrzKSgsarSQZ4yIT2NyDz87XRx0vYcp4IwpakSXHcnZDYX8ZN
i5P+w8Tc
=pMsr
-----END PGP SIGNATURE-----
Timestamp of file with hash 6bb35783fc2ba72a28707a449591029618cd6ad829e5c0b8651fa1f1655dab27 -
489ebb7 wallet: make chain optional for CWallet::Create (Ivan Metlushko) d73ae93 CWallet::Create move chain init message up into calling code (Ivan Metlushko) 44c430f refactor: Add CWallet:::AttachChain method (Russell Yanofsky) e2a47ce refactor: move first run detection to client code (Ivan Metlushko) Pull request description: This is a followup for bitcoin/bitcoin#20365 (comment) First part of a refactoring with overall goal to simplify `CWallet` and de-duplicate code with `wallettool` **Rationale**: split `CWallet::Create` and create `CWallet::AttachChain`. `CWallet::AttachChain` takes chain as first parameter on purpose. In future I suggest we can remove `chain` from `CWallet` constructor. The second commit is based on be164f9cf89b123f03b926aa980996919924ee64 from #15719 (thanks ryanofsky) cc ryanofsky achow101 ACKs for top commit: ryanofsky: Code review ACK 489ebb7. Only changes since last review were adding a const variable declaration, and implementing suggestion not to move feerate option checks to AttachChain. Thanks for updates and fast responses! Tree-SHA512: 00235abfe1b00874c56c449adcab8a36582424abb9ba27440bf750af8f3f217b68c11ca74eb30f78a2109ad1d9009315480effc78345e16a3074a1b5d8128721
Github-Pull: bitcoin#20365 Rebased-From: 6d3af3a
Github-Pull: bitcoin#20365 Rebased-From: 345e88e
Github-Pull: bitcoin#20365 Rebased-From: 173cc9b
Rationale: expose and promote descriptor wallets in more places; make cli tool more consistent with
createwalletrpc.Add
-descriptorsparameter which is off by default. When specified it will create a new descriptors wallet with sqlite backend, which is consistent withcreatewalletrpc.This PR is based on a suggestion from ryanofsky #19137 (comment)
Example: