Skip to content

Better names for types #665

@evanlinjin

Description

@evanlinjin

Description

After going through the codebase of the wallet module, I felt like we could do with some improvements in naming. I will list some suggestions below.

ChangeSpendPolicy -> InternalSpendPolicy

/// Policy regarding the use of change outputs when creating a transaction
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Hash, Clone, Copy)]
pub enum ChangeSpendPolicy {
/// Use both change and non-change outputs (default)
ChangeAllowed,
/// Only use change outputs (see [`TxBuilder::only_spend_change`])
OnlyChange,
/// Only use non-change outputs (see [`TxBuilder::do_not_spend_change`])
ChangeForbidden,
}

Right now we do not keep track of which outputs are change/not-change in the database. We only differentiate based on whether the scriptPubKey is derived from the external descriptor or internal descriptor.

pub(crate) change_policy: ChangeSpendPolicy,

Similarly, this field should be called spend_internal_policy.

LocalUtxo::is_spent -> LocalUtxo::is_used

bdk/src/types.rs

Lines 134 to 135 in dd51380

/// Whether this UTXO is spent or not
pub is_spent: bool,

Considering that UTXO is an acronym for "Unspent Transaction Output", this naming is very confusing. "Spent" for me means that the transaction is already included in a mined block. By calling it is_used, we will know whether it has already been used as input during tx creation.

Metadata

Metadata

Assignees

Labels

apiA breaking API changediscussionThere's still a discussion ongoingmodule-wallet

Type

No type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions