pub trait CoinSelectionAlgorithm<D: Database>: Debug {
// Required method
fn coin_select(
&self,
database: &D,
required_utxos: Vec<WeightedUtxo>,
optional_utxos: Vec<WeightedUtxo>,
fee_rate: FeeRate,
target_amount: u64,
drain_script: &Script,
) -> Result<CoinSelectionResult, Error>;
}
Expand description
Trait for generalized coin selection algorithms
This trait can be implemented to make the Wallet
use a customized coin
selection algorithm when it creates transactions.
For an example see this module’s documentation.
Required Methods§
Sourcefn coin_select(
&self,
database: &D,
required_utxos: Vec<WeightedUtxo>,
optional_utxos: Vec<WeightedUtxo>,
fee_rate: FeeRate,
target_amount: u64,
drain_script: &Script,
) -> Result<CoinSelectionResult, Error>
fn coin_select( &self, database: &D, required_utxos: Vec<WeightedUtxo>, optional_utxos: Vec<WeightedUtxo>, fee_rate: FeeRate, target_amount: u64, drain_script: &Script, ) -> Result<CoinSelectionResult, Error>
Perform the coin selection
database
: a reference to the wallet’s database that can be used to lookup additional details for a specific UTXOrequired_utxos
: the utxos that must be spent regardless oftarget_amount
with their weight costoptional_utxos
: the remaining available utxos to satisfytarget_amount
with their weight costfee_rate
: fee rate to usetarget_amount
: the outgoing amount in satoshis and the fees already accumulated from added outputs and transaction’s header.drain_script
: the script to use in case of change