Rename must_use_utxos to required_utxos
This commit is contained in:
parent
8d65581825
commit
43a51a1ec3
@ -53,7 +53,7 @@
|
|||||||
//! fn coin_select(
|
//! fn coin_select(
|
||||||
//! &self,
|
//! &self,
|
||||||
//! database: &D,
|
//! database: &D,
|
||||||
//! must_use_utxos: Vec<(UTXO, usize)>,
|
//! required_utxos: Vec<(UTXO, usize)>,
|
||||||
//! may_use_utxos: Vec<(UTXO, usize)>,
|
//! may_use_utxos: Vec<(UTXO, usize)>,
|
||||||
//! fee_rate: FeeRate,
|
//! fee_rate: FeeRate,
|
||||||
//! amount_needed: u64,
|
//! amount_needed: u64,
|
||||||
@ -61,7 +61,7 @@
|
|||||||
//! ) -> Result<CoinSelectionResult, bdk::Error> {
|
//! ) -> Result<CoinSelectionResult, bdk::Error> {
|
||||||
//! let mut selected_amount = 0;
|
//! let mut selected_amount = 0;
|
||||||
//! let mut additional_weight = 0;
|
//! let mut additional_weight = 0;
|
||||||
//! let all_utxos_selected = must_use_utxos
|
//! let all_utxos_selected = required_utxos
|
||||||
//! .into_iter().chain(may_use_utxos)
|
//! .into_iter().chain(may_use_utxos)
|
||||||
//! .scan((&mut selected_amount, &mut additional_weight), |(selected_amount, additional_weight), (utxo, weight)| {
|
//! .scan((&mut selected_amount, &mut additional_weight), |(selected_amount, additional_weight), (utxo, weight)| {
|
||||||
//! let txin = TxIn {
|
//! let txin = TxIn {
|
||||||
@ -139,7 +139,7 @@ pub trait CoinSelectionAlgorithm<D: Database>: std::fmt::Debug {
|
|||||||
///
|
///
|
||||||
/// - `database`: a reference to the wallet's database that can be used to lookup additional
|
/// - `database`: a reference to the wallet's database that can be used to lookup additional
|
||||||
/// details for a specific UTXO
|
/// details for a specific UTXO
|
||||||
/// - `must_use_utxos`: the utxos that must be spent regardless of `amount_needed` with their
|
/// - `required_utxos`: the utxos that must be spent regardless of `amount_needed` with their
|
||||||
/// weight cost
|
/// weight cost
|
||||||
/// - `may_be_spent`: the utxos that may be spent to satisfy `amount_needed` with their weight
|
/// - `may_be_spent`: the utxos that may be spent to satisfy `amount_needed` with their weight
|
||||||
/// cost
|
/// cost
|
||||||
@ -150,7 +150,7 @@ pub trait CoinSelectionAlgorithm<D: Database>: std::fmt::Debug {
|
|||||||
fn coin_select(
|
fn coin_select(
|
||||||
&self,
|
&self,
|
||||||
database: &D,
|
database: &D,
|
||||||
must_use_utxos: Vec<(UTXO, usize)>,
|
required_utxos: Vec<(UTXO, usize)>,
|
||||||
may_use_utxos: Vec<(UTXO, usize)>,
|
may_use_utxos: Vec<(UTXO, usize)>,
|
||||||
fee_rate: FeeRate,
|
fee_rate: FeeRate,
|
||||||
amount_needed: u64,
|
amount_needed: u64,
|
||||||
@ -169,7 +169,7 @@ impl<D: Database> CoinSelectionAlgorithm<D> for DumbCoinSelection {
|
|||||||
fn coin_select(
|
fn coin_select(
|
||||||
&self,
|
&self,
|
||||||
_database: &D,
|
_database: &D,
|
||||||
must_use_utxos: Vec<(UTXO, usize)>,
|
required_utxos: Vec<(UTXO, usize)>,
|
||||||
mut may_use_utxos: Vec<(UTXO, usize)>,
|
mut may_use_utxos: Vec<(UTXO, usize)>,
|
||||||
fee_rate: FeeRate,
|
fee_rate: FeeRate,
|
||||||
amount_needed: u64,
|
amount_needed: u64,
|
||||||
@ -188,7 +188,7 @@ impl<D: Database> CoinSelectionAlgorithm<D> for DumbCoinSelection {
|
|||||||
// smallest to largest, before being reversed with `.rev()`.
|
// smallest to largest, before being reversed with `.rev()`.
|
||||||
let utxos = {
|
let utxos = {
|
||||||
may_use_utxos.sort_unstable_by_key(|(utxo, _)| utxo.txout.value);
|
may_use_utxos.sort_unstable_by_key(|(utxo, _)| utxo.txout.value);
|
||||||
must_use_utxos
|
required_utxos
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|utxo| (true, utxo))
|
.map(|utxo| (true, utxo))
|
||||||
.chain(may_use_utxos.into_iter().rev().map(|utxo| (false, utxo)))
|
.chain(may_use_utxos.into_iter().rev().map(|utxo| (false, utxo)))
|
||||||
|
@ -348,7 +348,7 @@ where
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
let (must_use_utxos, may_use_utxos) = self.get_must_may_use_utxos(
|
let (required_utxos, may_use_utxos) = self.get_must_may_use_utxos(
|
||||||
builder.change_policy,
|
builder.change_policy,
|
||||||
&builder.unspendable,
|
&builder.unspendable,
|
||||||
&builder.utxos,
|
&builder.utxos,
|
||||||
@ -363,7 +363,7 @@ where
|
|||||||
mut fee_amount,
|
mut fee_amount,
|
||||||
} = builder.coin_selection.coin_select(
|
} = builder.coin_selection.coin_select(
|
||||||
self.database.borrow().deref(),
|
self.database.borrow().deref(),
|
||||||
must_use_utxos,
|
required_utxos,
|
||||||
may_use_utxos,
|
may_use_utxos,
|
||||||
fee_rate,
|
fee_rate,
|
||||||
outgoing,
|
outgoing,
|
||||||
@ -604,7 +604,7 @@ where
|
|||||||
.cloned()
|
.cloned()
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
||||||
let (mut must_use_utxos, may_use_utxos) = self.get_must_may_use_utxos(
|
let (mut required_utxos, may_use_utxos) = self.get_must_may_use_utxos(
|
||||||
builder.change_policy,
|
builder.change_policy,
|
||||||
&builder.unspendable,
|
&builder.unspendable,
|
||||||
&builder_extra_utxos[..],
|
&builder_extra_utxos[..],
|
||||||
@ -613,7 +613,7 @@ where
|
|||||||
true, // we only want confirmed transactions for RBF
|
true, // we only want confirmed transactions for RBF
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
must_use_utxos.append(&mut original_utxos);
|
required_utxos.append(&mut original_utxos);
|
||||||
|
|
||||||
let amount_needed = tx.output.iter().fold(0, |acc, out| acc + out.value);
|
let amount_needed = tx.output.iter().fold(0, |acc, out| acc + out.value);
|
||||||
let (new_feerate, initial_fee) = match builder
|
let (new_feerate, initial_fee) = match builder
|
||||||
@ -645,7 +645,7 @@ where
|
|||||||
fee_amount,
|
fee_amount,
|
||||||
} = builder.coin_selection.coin_select(
|
} = builder.coin_selection.coin_select(
|
||||||
self.database.borrow().deref(),
|
self.database.borrow().deref(),
|
||||||
must_use_utxos,
|
required_utxos,
|
||||||
may_use_utxos,
|
may_use_utxos,
|
||||||
new_feerate,
|
new_feerate,
|
||||||
amount_needed,
|
amount_needed,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user