bitcoin/src/wallet
Andrew Chow 2095f19db9
Merge bitcoin/bitcoin#24859: wallet: Change wallet validation order
6f29409ad1 test: Add a test that creates a wallet with invalid parameters (w0xlt)
0359d9b6a3 Change wallet validation order (w0xlt)

Pull request description:

  In the current code, the database is created before the last validation, which checks that passphrase is set and private keys are disabled.

  Therefore, if this validation fails, it will result in an empty database and the user will not be able to recreate a wallet with the same name and with the correct parameters.

  Behavior on the master branch:
  ```
  $ ./src/bitcoin-cli -regtest -named createwallet wallet_name="invalid_wallet_01" disable_private_keys=true passphrase="passphrase"
  error code: -4
  error message:
  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.

  $ ./src/bitcoin-cli -regtest -named createwallet wallet_name="invalid_wallet_01"
  error code: -4
  error message:
  Wallet file verification failed. Failed to create database path '/home/w/.bitcoin/regtest/wallets/invalid_wallet'. Database already exists.
  ```

  Behavior on the PR branch:
  ```
  $ ./src/bitcoin-cli -regtest -named createwallet wallet_name="invalid_wallet_02" disable_private_keys=true passphrase="passphrase"
  error code: -4
  error message:
  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.

  $ ./src/bitcoin-cli -regtest -named createwallet wallet_name="invalid_wallet_02"
  {
    "name": "invalid_wallet_01",
    "warning": ""
  }
  ```

ACKs for top commit:
  achow101:
    ACK 6f29409ad1

Tree-SHA512: d192955fc2285bf27ae5dd4c1b7cfd3d85441a7f3554b189b974aefb319c6b997543991dbb0ca2c8cb980f7058913a77cf0164c02e9b51ceb9c2cb601317c428
2022-04-18 11:29:29 -04:00
..
rpc rpc, wallet: setwalletflags warnings are optional 2022-04-14 14:39:21 -04:00
test Merge bitcoin/bitcoin#24602: fuzz: add target for coinselection algorithms 2022-03-31 13:09:17 -04:00
bdb.cpp Replace use of ArgsManager with DatabaseOptions 2022-03-16 08:26:28 +01:00
bdb.h Replace use of ArgsManager with DatabaseOptions 2022-03-16 08:26:28 +01:00
coincontrol.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
coincontrol.h wallet: add input weights to CCoinControl 2022-01-24 11:23:31 -05:00
coinselection.cpp [wallet] randomly generate change targets 2022-03-25 11:56:46 +00:00
coinselection.h lint: codespell 2.1.0 2022-04-07 12:49:51 +01:00
context.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
context.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
crypter.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
crypter.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
db.cpp Replace use of ArgsManager with DatabaseOptions 2022-03-16 08:26:28 +01:00
db.h Replace use of ArgsManager with DatabaseOptions 2022-03-16 08:26:28 +01:00
dump.cpp Replace use of ArgsManager with DatabaseOptions 2022-03-16 08:26:28 +01:00
dump.h Replace use of ArgsManager with DatabaseOptions 2022-03-16 08:26:28 +01:00
external_signer_scriptpubkeyman.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
external_signer_scriptpubkeyman.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
feebumper.cpp refactor: fix clang-tidy named args usage 2022-04-04 09:01:19 +01:00
feebumper.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
fees.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
fees.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
init.cpp Replace use of ArgsManager with DatabaseOptions 2022-03-16 08:26:28 +01:00
interfaces.cpp Merge bitcoin/bitcoin#24091: wallet: Consolidate CInputCoin and COutput 2022-03-24 20:46:43 +00:00
ismine.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
load.cpp wallet: Postpone NotifyWalletLoaded() for encrypted wallets 2022-03-30 21:28:53 +02:00
load.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
receive.cpp refactor: fix clang-tidy named args usage 2022-04-04 09:01:19 +01:00
receive.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
salvage.cpp Replace use of ArgsManager with DatabaseOptions 2022-03-16 08:26:28 +01:00
salvage.h Replace use of ArgsManager with DatabaseOptions 2022-03-16 08:26:28 +01:00
scriptpubkeyman.cpp Merge bitcoin/bitcoin#23304: wallet: Derive inactive HD chains in additional places 2022-03-02 09:35:07 +01:00
scriptpubkeyman.h Merge bitcoin/bitcoin#23304: wallet: Derive inactive HD chains in additional places 2022-03-02 09:35:07 +01:00
spend.cpp refactor: fix clang-tidy named args usage 2022-04-04 09:01:19 +01:00
spend.h moveonly: move COutput to coinselection.h 2022-03-23 14:32:07 -04:00
sqlite.cpp Merge bitcoin/bitcoin#23732: refactor: Remove gArgs from bdb.h and sqlite.h 2022-03-24 07:40:42 +01:00
sqlite.h Replace use of ArgsManager with DatabaseOptions 2022-03-16 08:26:28 +01:00
transaction.cpp Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
transaction.h wallet: add GetWitnessHash() 2022-02-01 08:44:51 -03:00
wallet.cpp Change wallet validation order 2022-04-15 03:48:33 -03:00
wallet.h wallet, refactor: Add wallet::NotifyWalletLoaded() function 2022-03-29 22:33:58 +02:00
walletdb.cpp refactor: fix clang-tidy named args usage 2022-04-04 09:01:19 +01:00
walletdb.h Merge bitcoin/bitcoin#23304: wallet: Derive inactive HD chains in additional places 2022-03-02 09:35:07 +01:00
wallettool.cpp Replace use of ArgsManager with DatabaseOptions 2022-03-16 08:26:28 +01:00
wallettool.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00
walletutil.cpp Use ArgsManager::GetPathArg() for "-walletdir" option 2022-02-09 19:31:23 +02:00
walletutil.h Add src/wallet/* code to wallet:: namespace 2022-01-06 22:14:16 -05:00