sweep: make sweeper aware of unconfirmed parent transactions.

Extend the fee estimator to take into account parent transactions with
their weights and fees.

Do not try to cpfp parent transactions that have a higher fee rate than
the sweep tx fee rate.
This commit is contained in:
Joost Jager committed 2020-09-17 12:30:39 +02:00
1 parent 3e3d8487fb
commit 681496b474
13 files changed
+334 -30

No files matched your search

+2 -7
View File
@@ -71,9 +71,6 @@ func (t *txInputSetState) clone() txInputSetState {
type txInputSet struct {
txInputSetState
// feePerKW is the fee rate used to calculate the tx fee.
feePerKW chainfee.SatPerKWeight
// dustLimit is the minimum output value of the tx.
dustLimit btcutil.Amount
@@ -96,11 +93,10 @@ func newTxInputSet(wallet Wallet, feePerKW,
)
state := txInputSetState{
weightEstimate: newWeightEstimator(),
weightEstimate: newWeightEstimator(feePerKW),
}
b := txInputSet{
feePerKW: feePerKW,
dustLimit: dustLimit,
maxInputs: maxInputs,
wallet: wallet,
@@ -146,8 +142,7 @@ func (t *txInputSet) addToState(inp input.Input, constraints addConstraints) *tx
s.inputTotal += value
// Recalculate the tx fee.
weight := s.weightEstimate.weight()
fee := t.feePerKW.FeeForWeight(int64(weight))
fee := s.weightEstimate.fee()
// Calculate the new output value.
s.outputValue = s.inputTotal - fee