0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-06 10:18:44 -05:00
bitcoin-bitcoin-core/src/rpc
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
..
blockchain.cpp Merge #21053: rpc, test: document {previous,next}blockhash as optional 2021-02-23 18:28:23 +01:00
blockchain.h move-onlyish: break out CreateUTXOSnapshot from dumptxoutset 2021-02-12 07:53:34 -06:00
client.cpp rpc: add external_signer option to createwallet 2021-02-23 14:34:31 +01:00
client.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
mining.cpp Merge #20749: [Bundle 1/n] Prune g_chainman usage related to ::LookupBlockIndex 2021-02-01 13:09:46 +01:00
mining.h rpc: create rpc/mining.h, hoist default max tries values to constant 2020-06-01 15:08:36 +02:00
misc.cpp Merge #18466: rpc: fix invalid parameter error codes for {sign,verify}message RPCs 2021-03-01 11:45:42 +01:00
net.cpp [net processing] Move ping data fields to net processing 2021-02-15 16:15:51 +00:00
protocol.h rpc: Add specific error code for "wallet already loaded" 2021-01-25 07:55:35 +01:00
rawtransaction.cpp scripted-diff: Invoke ::AcceptToMemoryPool with chainstate 2021-02-18 14:49:06 -05:00
rawtransaction_util.cpp Don't make "in" parameters look like "out"/"in-out" parameters: pass by ref to const instead of ref to non-const 2020-12-06 00:22:40 +00:00
rawtransaction_util.h Don't make "in" parameters look like "out"/"in-out" parameters: pass by ref to const instead of ref to non-const 2020-12-06 00:22:40 +00:00
register.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
request.cpp scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
request.h scripted-diff: Bump copyright headers 2020-12-31 09:45:41 +01:00
server.cpp rpc: Remove duplicate name and argNames from CRPCCommand 2021-01-28 08:19:52 +01:00
server.h rpc: Remove duplicate name and argNames from CRPCCommand 2021-01-28 08:19:52 +01:00
util.cpp Merge #19145: Add hash_type MUHASH for gettxoutsetinfo 2021-02-12 10:47:41 +01:00
util.h Merge #19145: Add hash_type MUHASH for gettxoutsetinfo 2021-02-12 10:47:41 +01:00