You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
e967cae Use switch on status in RpcWallet (Fabian Jahr)
ba1f128 Return error for ignored passphrase through disable private keys option (Fabian Jahr)
d6649d1 Use strong enum for WalletCreationStatus (Fabian Jahr)
3199610 Place out args at the end for CreateWallet (Fabian Jahr)
Pull request description:
This is a follow-up PR to #16244
The following suggestions are included:
- Usage of `enum class` (bitcoin/bitcoin#16244 (comment))
- Placing out args at the end convention (bitcoin/bitcoin#16244 (comment))
- Return error when passphrase would be ignored because of disabled private keys (including functional test) (bitcoin/bitcoin#16244 (review))
- Make `status` return variable of `CreateWallet` (bitcoin/bitcoin#16244 (comment))
- Using a `switch` statement instead of `if/else` in `RpcWallet` (bitcoin/bitcoin#16244 (comment))
Not included was:
- "new create wallet function [could take] separate option arguments instead of wallet flags" (bitcoin/bitcoin#16244 (review))
- "blank wallet and disable private keys options could be combined into a single option" (bitcoin/bitcoin#16244 (review))
For these last two changes, I was not sure what an ideal solution could look like and/or this might be of slightly larger scope than the other changes, but I would be happy to work on these as well in this PR or another follow-up if I get positive feedback on that. Is there a place in the codebase that handles flags like these in a better way that I can refer to? Nonetheless, I would prefer keeping it in a separate PR unless it is a really simple change.
ACKs for top commit:
jnewbery:
Code review utACK e967cae
MarcoFalke:
ACK e967cae
Tree-SHA512: 3d12880ff95add9e4a5702afa26ef38080b57b216a608c113a4d0a08ba2d61142c027ba0071c6402add45db90383eee0bada12dc42820dc0d602721d7175edd5
// Do not allow a passphrase when private keys are disabled
189
+
if (!passphrase.empty() && (wallet_creation_flags & WALLET_FLAG_DISABLE_PRIVATE_KEYS)) {
190
+
error = "Passphrase provided but private keys are disabled. A passphrase is only used to encrypt private keys, so cannot be used for wallets with private keys disabled.";
Copy file name to clipboardExpand all lines: test/functional/wallet_createwallet.py
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -119,5 +119,8 @@ def run_test(self):
119
119
# Empty passphrase, error
120
120
assert_raises_rpc_error(-16, 'Cannot encrypt a wallet with a blank password', self.nodes[0].createwallet, 'w7', False, False, '')
121
121
122
+
self.log.info('Using a passphrase with private keys disabled returns error')
123
+
assert_raises_rpc_error(-4, 'Passphrase provided but private keys are disabled. A passphrase is only used to encrypt private keys, so cannot be used for wallets with private keys disabled.', self.nodes[0].createwallet, wallet_name='w8', disable_private_keys=True, passphrase='thisisapassphrase')
0 commit comments