}
let expected_fee = self.fee_rate.fee(modified_tx.vsize());
assert_eq!(
actual_fee, expected_fee,
"invariant: fee estimation is correct",
);
for tx_out in &transaction.output {
assert!(
Amount::from_sat(tx_out.value) >= tx_out.script_pubkey.dust_value(),
"invariant: all outputs are above dust limit",
);
}
Ok(transaction)
}
fn calculate_sat_offset(&self) -> u64 {
let mut sat_offset = 0;
for outpoint in &self.inputs {
if *outpoint == self.outgoing.outpoint {
return sat_offset + self.outgoing.offset;
} else {
sat_offset += self.amounts[outpoint].to_sat();
}
}
panic!("Could not find outgoing sat in inputs");
}
/// Cardinal UTXOs are those that contain no inscriptions and can therefore
/// be used to pad transactions. Sometimes multiple of these UTXOs are needed
/// and depending on the context we want to select either ones above or
/// under (when trying to consolidate dust outputs) the target value.