.outputs
.last_mut()
.expect("No output to deduct fee from");
assert!(
total_output_amount.checked_sub(fee).unwrap() > Amount::from_sat(sat_offset),
"invariant: deducting fee does not consume sat",
);
assert!(
*last_output_amount >= fee,
"invariant: last output can pay fee: {} {}",
*last_output_amount,
fee,
);
*last_output_amount -= fee;
self
}
/// Estimate the size in virtual bytes of the transaction under construction.
/// We initialize wallets with taproot descriptors only, so we know that all
/// inputs are taproot key path spends, which allows us to know that witnesses
/// will all consist of single Schnorr signatures.
fn estimate_vbytes(&self) -> usize {
Self::estimate_vbytes_with(
self.inputs.len(),
self
.outputs
.iter()
.map(|(address, _amount)| address)
.cloned()
.collect(),
)
}
fn estimate_vbytes_with(inputs: usize, outputs: Vec<Address>) -> usize {