Skip to content

Conversation

@S3RK
Copy link
Contributor

@S3RK S3RK commented Nov 11, 2020

Rationale: expose and promote descriptor wallets in more places; make cli tool more consistent with createwallet rpc.

Add -descriptors parameter which is off by default. When specified it will create a new descriptors wallet with sqlite backend, which is consistent with createwallet rpc.

This PR is based on a suggestion from ryanofsky #19137 (comment)

Example:

$ ./src/bitcoin-wallet  -wallet=fewty -descriptors create
Topping up keypool...
Wallet info
===========
Name: fewty
Format: sqlite
Descriptors: yes
Encrypted: no
HD (hd seed available): yes
Keypool Size: 6000
Transactions: 0
Address Book: 0
$ ./src/bitcoin-wallet  -wallet=fewty create
Topping up keypool...
Wallet info
===========
Name: fewty
Format: bdb
Descriptors: no
Encrypted: no
HD (hd seed available): yes
Keypool Size: 2000
Transactions: 0
Address Book: 0

@DrahtBot
Copy link
Contributor

DrahtBot commented Nov 11, 2020

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

Conflicts

Reviewers, 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.

@Sjors
Copy link
Member

Sjors commented Nov 12, 2020

Concept ACK. cc @achow101

spk_man->SetupGeneration(false);
} else {
wallet_instance->SetupDescriptorScriptPubKeyMans();
}
Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Member

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.

Copy link
Contributor Author

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?

Copy link
Contributor

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!

@achow101
Copy link
Member

Concept ACK, could use some tests.

Copy link
Contributor

@ryanofsky ryanofsky left a 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);
Copy link
Contributor

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();
}
Copy link
Contributor

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!

@achow101
Copy link
Member

achow101 commented Dec 2, 2020

ACK 173cc9b

@ryanofsky
Copy link
Contributor

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?

Copy link
Member

@maflcko maflcko left a 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 -

@maflcko maflcko merged commit 69f1ee1 into bitcoin:master Dec 16, 2020
sidhujag pushed a commit to syscoin/syscoin that referenced this pull request Dec 17, 2020
@S3RK S3RK deleted the wallet_tool_create_descriptors branch December 26, 2020 15:45
laanwj added a commit to bitcoin-core/gui that referenced this pull request May 19, 2021
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
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 27, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 27, 2021
luke-jr pushed a commit to bitcoinknots/bitcoin that referenced this pull request Jun 27, 2021
@bitcoin bitcoin locked as resolved and limited conversation to collaborators Feb 15, 2022
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.

7 participants