sweep: add a dedicated method to create sweeping txns

This takes the old `createSweepTx` and refactors it to be
sweep-specific. A sweeping txns differs from a normal tx as it doesn't
need to take outputs as params.
This commit is contained in:
yyforyongyu committed 2024-04-19 21:33:32 +08:00
1 parent 59fbcb18d5
commit 59526988cf
4 files changed
+269 -7

No files matched your search

+13
View File
@@ -106,6 +106,19 @@ func (w *weightEstimator) weight() int {
return w.estimator.Weight()
}
// fee returns the tx fee to use for the aggregated inputs and outputs, which
// is different from feeWithParent as it doesn't take into account unconfirmed
// parent transactions.
func (w *weightEstimator) fee() btcutil.Amount {
// Calculate the weight of the transaction.
weight := int64(w.estimator.Weight())
// Calculate the fee.
fee := w.feeRate.FeeForWeight(weight)
return fee
}
// feeWithParent returns the tx fee to use for the aggregated inputs and
// outputs, taking into account unconfirmed parent transactions (cpfp).
func (w *weightEstimator) feeWithParent() btcutil.Amount {