Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
yancyribbens committed Jan 24, 2024
1 parent f12a376 commit dc0e5df
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,18 @@ pub struct WeightedUtxo {

impl WeightedUtxo {
fn effective_value(&self, fee_rate: FeeRate) -> Option<SignedAmount> {
effective_value(fee_rate, self.satisfaction_weight, self.utxo.value)
let signed_input_fee = self.calculate_fee(fee_rate)?.to_signed().ok()?;
self.utxo.value.to_signed().ok()?.checked_sub(signed_input_fee)
}

fn calculate_fee(&self, fee_rate: FeeRate) -> Option<Amount> {
// TODO TxIn::BASE_WEIGHT
let weight = self.satisfaction_weight.checked_add(Weight::ZERO)?;
fee_rate.checked_mul_by_weight(weight)
}

fn is_wasteful(&self, fee_rate: FeeRate, long_term_fee_rate: FeeRate) -> bool {
self.calculate_fee(fee_rate) > self.calculate_fee(long_term_fee_rate)
}
}

Expand Down

0 comments on commit dc0e5df

Please sign in to comment.