bitcoin/src/wallet
Wladimir J. van der Laan 362e901a17
Merge #18466: rpc: fix invalid parameter error codes for {sign,verify}message RPCs
a5cfb40e27 doc: release note for changed {sign,verify}message error codes (Sebastian Falbesoner)
9e399b9b2d test: check parameter validity in rpc_signmessage.py (Sebastian Falbesoner)
e62f0c71f1 rpc: fix {sign,message}verify RPC errors for invalid address/signature (Sebastian Falbesoner)

Pull request description:

  RPCs that accept address parameters usually return the intended error code `RPC_INVALID_ADDRESS_OR_KEY` (-5) if a passed address is invalid. The two exceptions to the rule are `signmessage` and `verifymessage`, which return `RPC_TYPE_ERROR` (-3) in this case instead. Oddly enough `verifymessage` returns `RPC_INVALID_ADDRESS_OR_KEY` when the _signature_ was malformed, where `RPC_TYPE_ERROR` would be more approriate.

  This PR fixes these inaccuracies and as well adds tests to `rpc_signmessage.py` that check the parameter validity and error codes for the related RPCs `signmessagewithprivkey`, `signmessage` and `verifymessage`.

  master branch:
  ```
  $ ./bitcoin-cli signmessage invalid_addr message
  error code: -3
  error message:
  Invalid address
  $ ./bitcoin-cli verifymessage invalid_addr dummy_sig message
  error code: -3
  error message:
  Invalid address
  $ ./bitcoin-cli verifymessage 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX invalid_sig message
  error code: -5
  error message:
  Malformed base64 encoding
  ```
  PR branch:
  ```
  $ ./bitcoin-cli signmessage invalid_addr message
  error code: -5
  error message:
  Invalid address
  $ ./bitcoin-cli verifymessage invalid_addr dummy_sig message
  error code: -5
  error message:
  Invalid address
  $ ./bitcoin-cli verifymessage 12c6DSiU4Rq3P4ZxziKxzrL5LmMBrzjrJX invalid_sig message
  error code: -3
  error message:
  Malformed base64 encoding
  ```

ACKs for top commit:
  laanwj:
    Code review ACK a5cfb40e27
  meshcollider:
    utACK a5cfb40e27

Tree-SHA512: bae0c4595a2603cea66090f6033785601837b45fd853052312b3a39d8520566c581994b68f693dd247c22586c638c3b7689c849085cce548cc36b9bf0e119d2d
2021-03-01 11:45:42 +01:00
..
test Change BOOST_CHECK to BOOST_CHECK_EQUAL to see mismatched values when a check fails. 2021-02-09 15:00:02 +01:00
bdb.cpp Merge #20464: refactor: Treat CDataStream bytes as uint8_t 2021-02-01 15:17:28 +01:00
bdb.h wallet: Add BerkeleyDB version sanity check at init time 2021-01-17 18:10:20 +01:00
coincontrol.cpp [rpc] walletcreatefundedpsbt: don't automatically append inputs 2020-03-12 13:07:17 +01:00
coincontrol.h [rpc] walletcreatefundedpsbt: don't automatically append inputs 2020-03-12 13:07:17 +01:00
coinselection.cpp Merge #20040: wallet: Refactor OutputGroups to handle fees and spending eligibility on grouping 2021-02-01 22:43:17 +13:00
coinselection.h Merge #20040: wallet: Refactor OutputGroups to handle fees and spending eligibility on grouping 2021-02-01 22:43:17 +13:00
context.cpp Remove g_rpc_chain global 2020-05-28 02:13:19 -04:00
context.h wallet: Pass unused args to StartWallets 2020-07-09 13:07:37 +02:00
crypter.cpp Fix occurences of c_str() used with size() to data() 2019-10-28 13:41:45 +01:00
crypter.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
db.cpp wallet: List all wallets in non-SQLite or non-BDB builds 2020-12-04 11:03:28 -04:00
db.h refactor: Consolidate redundant wallet database path and exists functions 2020-12-04 11:03:28 -04:00
dump.cpp wallettool: Add createfromdump command 2020-12-16 12:33:06 -05:00
dump.h wallettool: Add createfromdump command 2020-12-16 12:33:06 -05:00
external_signer.cpp rpc: send: support external signer 2021-02-23 14:34:32 +01:00
external_signer.h rpc: send: support external signer 2021-02-23 14:34:32 +01:00
external_signer_scriptpubkeyman.cpp rpc: signerdisplayaddress 2021-02-23 14:34:31 +01:00
external_signer_scriptpubkeyman.h rpc: send: support external signer 2021-02-23 14:34:32 +01:00
feebumper.cpp Merge #20584: Declare de facto const reference variables/member functions as const 2021-01-07 09:05:09 +01:00
feebumper.h wallet: Avoid translating RPC errors when creating txs 2020-05-01 07:39:06 -04:00
fees.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
fees.h Remove uses of fee globals in wallet code 2019-02-22 15:43:02 -04:00
init.cpp wallet: fix doc typo in signer option 2021-02-23 11:05:13 -08:00
interfaces.cpp rpc: add external signer RPC files 2021-02-23 14:34:30 +01:00
ismine.h doc: Add developer documentation to isminetype 2021-01-19 19:04:45 +08:00
load.cpp Replace fs::absolute calls with AbsPathJoin calls 2021-01-15 22:48:15 +01:00
load.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
rpcdump.cpp wallet: listdescriptors uses normalized descriptor form 2021-02-23 08:51:01 +01:00
rpcsigner.cpp rpc: signerdisplayaddress 2021-02-23 14:34:31 +01:00
rpcsigner.h rpc: add external signer RPC files 2021-02-23 14:34:30 +01:00
rpcwallet.cpp Merge #18466: rpc: fix invalid parameter error codes for {sign,verify}message RPCs 2021-03-01 11:45:42 +01:00
rpcwallet.h Assert that RPCArg names are equal to CRPCCommand ones (net, rpcwallet) 2020-09-22 20:49:30 +02:00
salvage.cpp refactor: Drop call to GetWalletEnv in wallet salvage code 2020-12-04 11:03:28 -04:00
salvage.h wallettool: Have RecoverDatabaseFile return errors and warnings 2020-07-26 20:22:45 -04:00
scriptpubkeyman.cpp rpc: send: support external signer 2021-02-23 14:34:32 +01:00
scriptpubkeyman.h wallet: ExternalSigner: add GetDescriptors method 2021-02-23 14:34:31 +01:00
sqlite.cpp refactor: Consolidate redundant wallet database path and exists functions 2020-12-04 11:03:28 -04:00
sqlite.h doc: fix various typos 2021-01-04 12:31:31 +08:00
wallet.cpp rpc: send: support external signer 2021-02-23 14:34:32 +01:00
wallet.h rpc: signerdisplayaddress 2021-02-23 14:34:31 +01:00
walletdb.cpp wallet: load flags before everything else 2021-02-09 19:01:15 +01:00
walletdb.h Include wallet/bdb.h where it is actually being used 2020-11-18 11:55:43 -05:00
wallettool.cpp refactor: Move all command dependend checks to ExecuteWalletToolFunc 2021-01-21 19:30:34 +01:00
wallettool.h refactor: Move all command dependend checks to ExecuteWalletToolFunc 2021-01-21 19:30:34 +01:00
walletutil.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
walletutil.h wallet: add external_signer flag 2021-02-23 14:34:30 +01:00