Author

Topic: Request. Standardize naming of RPC Calls (bounty) (Read 1432 times)

sr. member
Activity: 476
Merit: 250
Tangible Cryptography LLC
November 05, 2012, 10:30:32 AM
#8
You didn't actually look at my commit, did you?  Smiley
How embarassing  Embarrassed I DID click on the commit, skimmed the first few lines that showed removal of existing commands and went back to comment here. Please forgive my ignorance  Lips sealed

No worries.  It happens.

Since everything goes through a dispatch table, it was easy enough to put duplicate entries in so that the old commands would keep working.  The catch is that the list of commands that you get from typing "bitcoind help" is generated from that table, and I wasn't sure how to prevent duplicates.  Turned out that the problem had already come up before and someone else had fixed it so I didn't have to.

That was a nice implementation.  If the pull is integrated in the mainline all that is required is updated docs on sites like the wiki and unless new developers look at the source the old variants will be invisible, yet will still retain backwards compatibility. 

Backwards compatibility and forward standardization a win-win scenario.

Thanks. 
kjj
legendary
Activity: 1302
Merit: 1025
You didn't actually look at my commit, did you?  Smiley
How embarassing  Embarrassed I DID click on the commit, skimmed the first few lines that showed removal of existing commands and went back to comment here. Please forgive my ignorance  Lips sealed

No worries.  It happens.

Since everything goes through a dispatch table, it was easy enough to put duplicate entries in so that the old commands would keep working.  The catch is that the list of commands that you get from typing "bitcoind help" is generated from that table, and I wasn't sure how to prevent duplicates.  Turned out that the problem had already come up before and someone else had fixed it so I didn't have to.
hero member
Activity: 488
Merit: 500
You didn't actually look at my commit, did you?  Smiley
How embarassing  Embarrassed I DID click on the commit, skimmed the first few lines that showed removal of existing commands and went back to comment here. Please forgive my ignorance  Lips sealed
kjj
legendary
Activity: 1302
Merit: 1025
While I like the idea we have to make sure to stay backwardscompatible. So we can not just rename the commands and break all sorts of things that rely on the existing commands.
Better would be to add new commands and mark the old ones as "deprecated" and remove them only after some intermediate releases are done.

You didn't actually look at my commit, did you?  Smiley
hero member
Activity: 488
Merit: 500
While I like the idea we have to make sure to stay backwardscompatible. So we can not just rename the commands and break all sorts of things that rely on the existing commands.
Better would be to add new commands and mark the old ones as "deprecated" and remove them only after some intermediate releases are done.
kjj
legendary
Activity: 1302
Merit: 1025
I had to rebase this against the latest master.  New link is:

https://github.com/kjj2/bitcoin/commit/4ba9b0603e235c2579622e3fc4d554da8507f345
kjj
legendary
Activity: 1302
Merit: 1025
These are pretty easy changes.

https://github.com/kjj2/bitcoin/commit/c82fa0b722b0aec843e4538b1f21f5298fb2fee6

I changed the names of the functions too, so I'm running a full recompile to make sure I didn't typo anything.

This isn't worth 5 BTC by the way.  If this gets accepted, either give the bounty to some worthy cause, or hold onto it until you have a more difficult change request.
sr. member
Activity: 476
Merit: 250
Tangible Cryptography LLC
So I am doing some programming and a minor thing that bugs me is the "weird" naming convention of a minority of the RPC calls.

Code:
bitcoind help

addmultisigaddress <'["key","key"]'> [account]
backupwallet
createrawtransaction [{"txid":txid,"vout":n},...] {address:amount,...}
decoderawtransaction
dumpprivkey
getaccount
getaccountaddress
getaddressesbyaccount
getbalance [account] [minconf=1]
getblock
getblockcount
getblockhash
getblocktemplate [params]
getconnectioncount
getdifficulty
getgenerate
gethashespersec
getinfo
getmininginfo
getnewaddress [account]
getpeerinfo
getrawmempool
getrawtransaction [verbose=0]
getreceivedbyaccount [minconf=1]
getreceivedbyaddress [minconf=1]
gettransaction
getwork [data]
help [command]
importprivkey [label]
keypoolrefill
listaccounts [minconf=1]
listaddressgroupings
listreceivedbyaccount [minconf=1] [includeempty=false]
listreceivedbyaddress [minconf=1] [includeempty=false]
listsinceblock [blockhash] [target-confirmations]
listtransactions [account] [count=10] [from=0]
listunspent [minconf=1] [maxconf=9999999]  ["address",...]
move [minconf=1] [comment]
sendfrom [minconf=1] [comment] [comment-to]
sendmany {address:amount,...} [minconf=1] [comment]
sendrawtransaction
sendtoaddress [comment] [comment-to]
setaccount
setgenerate [genproclimit]
settxfee
signmessage
signrawtransaction [{"txid":txid,"vout":n,"scriptPubKey":hex},...] [,...] [sighashtype="ALL"]
stop
submitblock [optional-params-obj]
validateaddress
verifymessage
walletlock
walletpassphrase
walletpassphrasechange

Generally procedure calls have a "verb".  It is a command you are asking the system (any system) to do something.  Getbalance ... instructing the bitcoind to get something, get what?  the balance.  The call getbalance is self documenting.  It is clear that the call will be returning information and the information returned is the balance.  Names which lack a verb are not self describing.  Most of the RPC calls follow this convention, the list above can be summarized as the following verbs

Code:
add
backup
create
decode
dump
get
import
list
move
send
set
sign
stop
submit
validate
verify

There are four calls which break with that convention:
Code:
keypoolrefill
walletlock
walletpassphrase
walletpassphrasechange

Of the four "walletpassphrase" is the worst.  It lacks any verb and thus the call itself isn't self documenting at all (walletpassphrase what?).  I suggest the four calls be renamed to fit with the standard set by the other RPC calls (verb + object of verb)
Code:
refillkeypool
lockwallet
unlockwallet
setpassphrase

To avoid breaking compatibility with existing code the current RPC calls can be made deprecated aliases to the newly named ones.  I know it is relatively minor but it just bugs me every time I am doing some bitcoind coding.  I don't have the time to do the modifications and pull request so I am offering a bounty.  2BTC for a completed pull, and 3 BTC more when integrated into the mainline.
Jump to: