bdk icon indicating copy to clipboard operation
bdk copied to clipboard

refactor(bdk): use idiomatic naming for all getter methods

Open notmandatory opened this issue 2 years ago • 5 comments

          I don't think this should be addressed in this PR, but I think we should use idiomatic naming for methods: https://rust-lang.github.io/api-guidelines/naming.html#getter-names-follow-rust-convention-c-getter

I.e. Wallet::get_address should be Wallet::address.

Originally posted by @evanlinjin in https://github.com/bitcoindevkit/bdk/issues/1028#issuecomment-1813522784

notmandatory avatar Nov 16 '23 14:11 notmandatory

Rename Psbt::get_utxo_for -> utxo_at_index ?

or get_txout

ValuedMammal avatar Feb 05 '24 02:02 ValuedMammal

My personal preference which is slightly different from the rust style guide: I'm fine with get_ if there is something like a corresponding insert_. So get_tx feels good because there's also insert_tx. It shouldn't be get_balance though.

LLFourn avatar Feb 06 '24 02:02 LLFourn

A small change but I think we should push to 2.0 milestone.

notmandatory avatar Mar 20 '24 02:03 notmandatory

I'd also be fine with making this a note in CONTRIBUTING.md along with some additional code conventions and guidelines, in hopes that it sort of implements itself over time.

ValuedMammal avatar Mar 20 '24 13:03 ValuedMammal

Yes I like that idea, and between 1.0 and 2.0 we can slowly deprecate old naming and add the new ones. We just can't fully remove the old names until a 2.0 version bump.

notmandatory avatar Mar 21 '24 04:03 notmandatory

We only need to change Wallet::get_balance() to Wallet::balance() so we should be able to get this in to the 1.0 milestone.

The Wallet::get_address fix was done in #1402.

Any other pub fn get_* are less commonly used and can wait until 2.0.

notmandatory avatar Jun 01 '24 22:06 notmandatory