The naming schema of corepc client and types is ad hoc. Some examples:
In client:
derive_addresses (no optional args) and derive_addresses_multipath (with second optional arg), or
estimate_smart_fee (no optional args) and estimate_smart_fee_with_mode (with second optional arg).
The suffix changed. One says with_<argname>, the other says <argname>.
In types:
GetTxOutSetInfo.BlockInfo.Unspendables becomes GetTxOutSetInfoUnspendables. Could have been GetTxOutSetInfoBlockInfoUnspendables.
GetTransaction.Details[item] becomes GetTransactionDetail. Could have been GetTransactionDetailsItem.
GetBlock(verbose=3).Tx[Vin[Prevout]] becomes GetBlockVerboseThreePrevout. Could have been GetBlockVerboseThreeTxItemVinItemPrevout.
Observations:
- If we need to support more optional arguments, the name permutations should logically increase by N+1 methods for every new optional arg we support. Clearly not good. Otherwise, we simply don't support valid optional arguments.
- Corepc types avoid repeating themselves at the cost of potential drift.
- About verbosity,
getblock uses get_block_verbose_zero/one/two/three, but getrawtransaction uses a single get_raw_transaction + get_raw_transaction_verbose.
- The same RPC is split into feels-based number of methods, such as
scanblocks is three methods _start/_status/_abort, while others fold everything into one.
signmessagewithprivkey is PrivKey in the type but privkey in the fn name while getrawaddrman is AddrMan in the type but addrman in the fn name.
- Some good conventions to keep are
ScriptPubKey, for example. Codegen could generate something like DecodePsbtInputsItemWitnessUtxoScriptPubKey, notice that this struct matches several others in repo and abstracts them all into ScriptPubKey because it is consistent.
I found this problem because I'm implementing a codegen production client, and, to match the existing naming schema, it requires many exceptions for machine generated naming schema to fit the mold.
Therefore, I propose we standardize a coherent naming schema for corepc.
The naming schema of corepc client and types is ad hoc. Some examples:
In client:
derive_addresses(no optional args) andderive_addresses_multipath(with second optional arg), orestimate_smart_fee(no optional args) andestimate_smart_fee_with_mode(with second optional arg).The suffix changed. One says
with_<argname>, the other says<argname>.In types:
GetTxOutSetInfo.BlockInfo.UnspendablesbecomesGetTxOutSetInfoUnspendables. Could have beenGetTxOutSetInfoBlockInfoUnspendables.GetTransaction.Details[item]becomesGetTransactionDetail. Could have beenGetTransactionDetailsItem.GetBlock(verbose=3).Tx[Vin[Prevout]]becomesGetBlockVerboseThreePrevout. Could have beenGetBlockVerboseThreeTxItemVinItemPrevout.Observations:
getblockusesget_block_verbose_zero/one/two/three, butgetrawtransactionuses a singleget_raw_transaction+get_raw_transaction_verbose.scanblocksis three methods_start/_status/_abort, while others fold everything into one.signmessagewithprivkeyisPrivKeyin the type butprivkeyin the fn name whilegetrawaddrmanisAddrManin the type butaddrmanin the fn name.ScriptPubKey, for example. Codegen could generate something likeDecodePsbtInputsItemWitnessUtxoScriptPubKey, notice that this struct matches several others in repo and abstracts them all intoScriptPubKeybecause it is consistent.I found this problem because I'm implementing a codegen production client, and, to match the existing naming schema, it requires many exceptions for machine generated naming schema to fit the mold.
Therefore, I propose we standardize a coherent naming schema for corepc.