sweep/tx_input_set: account for required outputs in input set

If inputs require outputs to be added at the same time, this will
change the weight and amount calculations, so we must account for that.

We wait to get the weight estimator for the sweep tx until needed,
such that we can easily choose whether to include a change output or not
in the estimate. This is needed for the case where the second level
transactions can pay for their own fee, so no change output is needed.
This commit is contained in:
Johan T. Halseth committed 2020-11-20 13:06:54 +01:00
1 parent 985b7838ab
commit 0cba47dac0
4 files changed
+238 -55

No files matched your search

-16
View File
@@ -26,22 +26,6 @@ func newWeightEstimator(feeRate chainfee.SatPerKWeight) *weightEstimator {
}
}
// clone returns a copy of this weight estimator.
func (w *weightEstimator) clone() *weightEstimator {
parents := make(map[chainhash.Hash]struct{}, len(w.parents))
for hash := range w.parents {
parents[hash] = struct{}{}
}
return &weightEstimator{
estimator: w.estimator,
feeRate: w.feeRate,
parents: parents,
parentsFee: w.parentsFee,
parentsWeight: w.parentsWeight,
}
}
// add adds the weight of the given input to the weight estimate.
func (w *weightEstimator) add(inp input.Input) error {
// If there is a parent tx, add the parent's fee and weight.