denpamusic / php-bitcoinrpc

Fully unit-tested Bitcoin JSON-RPC client based on GuzzleHttp.
MIT License
283 stars 100 forks source link

Camel case to work with ethereum json rpc #26

Closed M-Shahbaz closed 5 years ago

M-Shahbaz commented 5 years ago

I was testing this library to make it work with ethereum json rpc, interestingly it does work. Ethereum json rpc methods has strict camel case names and doesn't work with all lower case method names. e.g: => "net_version" method works bitcoind()->client('ethereum')->net_version()->get();

=> "web3_clientVersion" method doesn't work bitcoind()->client('ethereum')->web3_clientVersion()->get(); Throws Exception: "The method web3_clientversion does not exist/is not available"

Ethereum JSON RPC methods ref: https://github.com/ethereum/wiki/wiki/JSON-RPC

denpamusic commented 5 years ago

Thank you for your contribution!

Sadly Bitcoin Core(and most forks) require lowercase and will not work with camel case.

I really want to allow devs to use any casing in rpc methods to better fit their coding style. That's why I chose to lowercase method names in the first place.

One way around this, would be to add client-specific setting, something like ['preserve_case' => true]. When set to true it'll preserve case as is, if it's set to false(default) it'll lowercase method names.

If you're willing to update your PR using this approach and adding tests for it, I'll gladly merge it. Otherwise I'll implement this myself and credit you for idea in release notes.

M-Shahbaz commented 5 years ago

Ok, thanks. I understand and I also found lowercase more dev friendly :+1: . client-specific setting would be a better approach.