Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RPC: Add alias
blockhash
to getblockheader
for backward compatibi…
…lity Summary ---- It was found that recent changes to our RPC API introduced here: https://gitlab.com/bitcoin-cash-node/bitcoin-cash-node/-/merge_requests/443 caused the named parameter "blockhash" to be renamed to "hash_or_height". It turns out some extant software in the wild relied on this named parameter to not change. See: trezor/blockbook#498 (comment) Fortunately, this codebase supports named parameter aliasing by using the '|' character inside the parameter names in the RPC method table. So, we leverage this facility and make `getblockheader` also accept `blockhash` interchangeably with the `hash_or_height` named parameter. This ensures continued 100% RPC compatibility with ABC and older BCHN. The rpc_blockchain unit test for `getblockheader` was also updated/modified to test that this alias continues to work. Closes Bitcoin-ABC#173 . Test Plan --- This should cover it: - `ninja && test/functional/test_runner rpc_blockchain` Also manual testing to verify in case you are paranoid, do the below with and without this commit (testnet3 assumed below): `curl --user USER_NAME_HERE --data-binary '{"jsonrpc": "1.0", "id":"curltest", "method": "getblockheader", "params": {"blockhash":"000000008a91ac6ac787eda6a2f5a7ddc94311322c3f80ddf0f144cb7c2ba7bc"} }' -H 'content-type: text/plain;' http://127.0.0.1:18332/` - Without this commit: should complain about unknown named arg `blockhash` - With this commit: should accept arg and return a header for block Note that you may need to adjust the above username and port for your setup. The above example assumes testnet3.
- Loading branch information