s/UTXO/LocalUtxo/g

Since this struct has a "keychain" it is not a general "UTXO" but a
local wallet UTXO.
This commit is contained in:
LLFourn
2021-02-04 12:09:53 +11:00
parent 4ad0f54c30
commit a7183f34ef
10 changed files with 68 additions and 68 deletions

View File

@@ -50,8 +50,8 @@
//! fn coin_select(
//! &self,
//! database: &D,
//! required_utxos: Vec<(UTXO, usize)>,
//! optional_utxos: Vec<(UTXO, usize)>,
//! required_utxos: Vec<(LocalUtxo, usize)>,
//! optional_utxos: Vec<(LocalUtxo, usize)>,
//! fee_rate: FeeRate,
//! amount_needed: u64,
//! fee_amount: f32,
@@ -99,7 +99,7 @@
use crate::database::Database;
use crate::error::Error;
use crate::types::{FeeRate, UTXO};
use crate::types::{FeeRate, LocalUtxo};
use rand::seq::SliceRandom;
#[cfg(not(test))]
@@ -122,7 +122,7 @@ pub(crate) const TXIN_BASE_WEIGHT: usize = (32 + 4 + 4 + 1) * 4;
#[derive(Debug)]
pub struct CoinSelectionResult {
/// List of outputs selected for use as inputs
pub selected: Vec<UTXO>,
pub selected: Vec<LocalUtxo>,
/// Sum of the selected inputs' value
pub selected_amount: u64,
/// Total fee amount in satoshi
@@ -151,8 +151,8 @@ pub trait CoinSelectionAlgorithm<D: Database>: std::fmt::Debug {
fn coin_select(
&self,
database: &D,
required_utxos: Vec<(UTXO, usize)>,
optional_utxos: Vec<(UTXO, usize)>,
required_utxos: Vec<(LocalUtxo, usize)>,
optional_utxos: Vec<(LocalUtxo, usize)>,
fee_rate: FeeRate,
amount_needed: u64,
fee_amount: f32,
@@ -170,8 +170,8 @@ impl<D: Database> CoinSelectionAlgorithm<D> for LargestFirstCoinSelection {
fn coin_select(
&self,
_database: &D,
required_utxos: Vec<(UTXO, usize)>,
mut optional_utxos: Vec<(UTXO, usize)>,
required_utxos: Vec<(LocalUtxo, usize)>,
mut optional_utxos: Vec<(LocalUtxo, usize)>,
fee_rate: FeeRate,
amount_needed: u64,
mut fee_amount: f32,
@@ -239,7 +239,7 @@ impl<D: Database> CoinSelectionAlgorithm<D> for LargestFirstCoinSelection {
#[derive(Debug, Clone)]
// Adds fee information to an UTXO.
struct OutputGroup {
utxo: UTXO,
utxo: LocalUtxo,
// weight needed to satisfy the UTXO, as described in `Descriptor::max_satisfaction_weight`
satisfaction_weight: usize,
// Amount of fees for spending a certain utxo, calculated using a certain FeeRate
@@ -249,7 +249,7 @@ struct OutputGroup {
}
impl OutputGroup {
fn new(utxo: UTXO, satisfaction_weight: usize, fee_rate: FeeRate) -> Self {
fn new(utxo: LocalUtxo, satisfaction_weight: usize, fee_rate: FeeRate) -> Self {
let fee = (TXIN_BASE_WEIGHT + satisfaction_weight) as f32 / 4.0 * fee_rate.as_sat_vb();
let effective_value = utxo.txout.value as i64 - fee.ceil() as i64;
OutputGroup {
@@ -291,8 +291,8 @@ impl<D: Database> CoinSelectionAlgorithm<D> for BranchAndBoundCoinSelection {
fn coin_select(
&self,
_database: &D,
required_utxos: Vec<(UTXO, usize)>,
optional_utxos: Vec<(UTXO, usize)>,
required_utxos: Vec<(LocalUtxo, usize)>,
optional_utxos: Vec<(LocalUtxo, usize)>,
fee_rate: FeeRate,
amount_needed: u64,
fee_amount: f32,
@@ -535,10 +535,10 @@ mod test {
const P2WPKH_WITNESS_SIZE: usize = 73 + 33 + 2;
fn get_test_utxos() -> Vec<(UTXO, usize)> {
fn get_test_utxos() -> Vec<(LocalUtxo, usize)> {
vec![
(
UTXO {
LocalUtxo {
outpoint: OutPoint::from_str(
"ebd9813ecebc57ff8f30797de7c205e3c7498ca950ea4341ee51a685ff2fa30a:0",
)
@@ -552,7 +552,7 @@ mod test {
P2WPKH_WITNESS_SIZE,
),
(
UTXO {
LocalUtxo {
outpoint: OutPoint::from_str(
"65d92ddff6b6dc72c89624a6491997714b90f6004f928d875bc0fd53f264fa85:0",
)
@@ -568,11 +568,11 @@ mod test {
]
}
fn generate_random_utxos(rng: &mut StdRng, utxos_number: usize) -> Vec<(UTXO, usize)> {
fn generate_random_utxos(rng: &mut StdRng, utxos_number: usize) -> Vec<(LocalUtxo, usize)> {
let mut res = Vec::new();
for _ in 0..utxos_number {
res.push((
UTXO {
LocalUtxo {
outpoint: OutPoint::from_str(
"ebd9813ecebc57ff8f30797de7c205e3c7498ca950ea4341ee51a685ff2fa30a:0",
)
@@ -589,9 +589,9 @@ mod test {
res
}
fn generate_same_value_utxos(utxos_value: u64, utxos_number: usize) -> Vec<(UTXO, usize)> {
fn generate_same_value_utxos(utxos_value: u64, utxos_number: usize) -> Vec<(LocalUtxo, usize)> {
let utxo = (
UTXO {
LocalUtxo {
outpoint: OutPoint::from_str(
"ebd9813ecebc57ff8f30797de7c205e3c7498ca950ea4341ee51a685ff2fa30a:0",
)
@@ -607,7 +607,7 @@ mod test {
vec![utxo; utxos_number]
}
fn sum_random_utxos(mut rng: &mut StdRng, utxos: &mut Vec<(UTXO, usize)>) -> u64 {
fn sum_random_utxos(mut rng: &mut StdRng, utxos: &mut Vec<(LocalUtxo, usize)>) -> u64 {
let utxos_picked_len = rng.gen_range(2, utxos.len() / 2);
utxos.shuffle(&mut rng);
utxos[..utxos_picked_len]