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
|
/// 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.
Description
After going through the codebase of the
walletmodule, I felt like we could do with some improvements in naming. I will list some suggestions below.ChangeSpendPolicy->InternalSpendPolicybdk/src/wallet/tx_builder.rs
Lines 742 to 751 in dd51380
Right now we do not keep track of which outputs are change/not-change in the database. We only differentiate based on whether the
scriptPubKeyis derived from the external descriptor or internal descriptor.bdk/src/wallet/tx_builder.rs
Line 145 in dd51380
Similarly, this field should be called
spend_internal_policy.LocalUtxo::is_spent->LocalUtxo::is_usedbdk/src/types.rs
Lines 134 to 135 in dd51380
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.