1
Is there a way to make bitcoin-cli output JSON-serialized errors? For example if I do
bitcoin-cli getblock foo
the output is
error code: -5
error message:
Block not found
I want the output to be something more like:
{
"error": {
"code": -5,
"message": "Block not found"
}
}
Behind the scenes, that's what the RPC response body looks like, and I want to tell bitcoin-cli, "Don't pretty-print the error if there is one. Just give me the JSON response."
To add some context, I want to use bitcoin-cli not curl or another http library because bitcoin-cli knows how to find and read bitcoin.conf and infer from that the RPC username, password, and port. These days with "cookie-based" authentication and INI file "sections" in bitcoin.conf, the logic to automagically infer the RPC username, password, and port is actually quite complex. The logic also differs somewhat between Bitcoin Core and other server implementations. – chrisarnesen – 2018-12-07T08:47:38.337