Skip to content

Commit 69f7e5a

Browse files
committed
Add requested changes
1 parent dc3e32d commit 69f7e5a

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/wallet/coin_selection.rs

+11-8
Original file line numberDiff line numberDiff line change
@@ -147,20 +147,20 @@ impl CoinSelectionResult {
147147

148148
/// Metric introduced to measure the performance of different coin selection algorithms.
149149
///
150-
/// This implementations considers waste as the sum of two values:
150+
/// This implementation considers "waste" the sum of two values:
151151
/// * Timing cost
152152
/// * Creation cost
153153
/// > waste = timing_cost + creation_cost
154154
///
155-
/// **Timing cost** is the cost associated to the current fee rate and some long term fee rate used
156-
/// as a treshold to consolidate UTXOs.
155+
/// **Timing cost** is the cost associated with the current fee rate and some long term fee rate used
156+
/// as a threshold to consolidate UTXOs.
157157
/// > timing_cost = txin_size * current_fee_rate - txin_size * long_term_fee_rate
158158
///
159159
/// Timing cost can be negative if the `current_fee_rate` is cheaper than the `long_term_fee_rate`,
160160
/// or zero if they are equal.
161161
///
162-
/// **Creation cost** is the cost associated to the surplus of coins besides the transaction amount
163-
/// and transaction fees. It can happen in the form of a change output or in the form of excess
162+
/// **Creation cost** is the cost associated with the surplus of coins beyond the transaction amount
163+
/// and transaction fees. It can appear in the form of a change output or in the form of excess
164164
/// fees paid to the miner.
165165
///
166166
/// Change cost is derived from the cost of adding the extra output to the transaction and spending
@@ -177,7 +177,7 @@ impl CoinSelectionResult {
177177
/// algorithm.
178178
///
179179
/// So, waste can be zero if creation and timing cost are zero. Or can be negative, if timing cost
180-
/// is negative and the creation cost is lower enough (less than the absolute value of timing
180+
/// is negative and the creation cost is low enough (less than the absolute value of timing
181181
/// cost).
182182
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
183183
pub struct Waste(pub i64);
@@ -189,7 +189,10 @@ impl Waste {
189189
///
190190
/// - `selected`: the selected transaction inputs
191191
/// - `cost_of_change`: the cost of creating change and spending it in the future
192-
/// - `target`: the amount in satoshis of the aimed transaction output
192+
/// - `target`: threshold in satoshis used to select UTXOs. It includes the sum of recipient
193+
/// outputs, the fees for creating the recipient outputs and the fees for fixed transaction
194+
/// parts
195+
193196
/// - `fee_rate`: fee rate to use
194197
pub fn calculate(
195198
selected: &[WeightedUtxo],
@@ -1511,7 +1514,7 @@ mod test {
15111514
let change_out_size = 31_f32;
15121515
let change_in_size = 68_f32;
15131516
let cost_of_change: u64 = (change_out_size * fee_rate.as_sat_vb()
1514-
- change_in_size * LONG_TERM_FEE_RATE.as_sat_vb())
1517+
+ change_in_size * LONG_TERM_FEE_RATE.as_sat_vb())
15151518
as u64;
15161519

15171520
let utxo_fee_diff: i64 = utxos.iter().fold(0, |acc, utxo| {

0 commit comments

Comments
 (0)