diff --git a/src/lib.rs b/src/lib.rs index 0a9445f1..e3dac71b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -55,7 +55,18 @@ pub struct WeightedUtxo { impl WeightedUtxo { fn effective_value(&self, fee_rate: FeeRate) -> Option { - 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 { + // 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) } }