+
+ #[cfg(anchors)]
+ /// Computes a feerate based on the given confirmation target. If a previous feerate was used,
+ /// the new feerate is below it, and `force_feerate_bump` is set, we'll use a 25% increase of
+ /// the previous feerate instead of the new feerate.
+ pub(crate) fn compute_package_feerate<F: Deref>(
+ &self, fee_estimator: &LowerBoundedFeeEstimator<F>, conf_target: ConfirmationTarget,
+ force_feerate_bump: bool,
+ ) -> u32 where F::Target: FeeEstimator {
+ let feerate_estimate = fee_estimator.bounded_sat_per_1000_weight(conf_target);
+ if self.feerate_previous != 0 {
+ // If old feerate inferior to actual one given back by Fee Estimator, use it to compute new fee...
+ if feerate_estimate as u64 > self.feerate_previous {
+ feerate_estimate
+ } else if !force_feerate_bump {
+ self.feerate_previous.try_into().unwrap_or(u32::max_value())
+ } else {
+ // ...else just increase the previous feerate by 25% (because that's a nice number)
+ (self.feerate_previous + (self.feerate_previous / 4)).try_into().unwrap_or(u32::max_value())
+ }
+ } else {
+ feerate_estimate
+ }
+ }
+
+ /// Determines whether a package contains an input which must have additional external inputs
+ /// attached to help the spending transaction reach confirmation.
+ pub(crate) fn requires_external_funding(&self) -> bool {
+ self.inputs.iter().find(|input| match input.1 {
+ PackageSolvingData::HolderFundingOutput(ref outp) => outp.opt_anchors(),
+ PackageSolvingData::HolderHTLCOutput(ref outp) => outp.opt_anchors(),
+ _ => false,
+ }).is_some()
+ }
+