Skip to content

Naming schema is inconsistent #621

Description

@satsfy

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions