Merge pull request #2062 from cfromknecht/sweeper-filter-unknown-witness-types
sweep/sweeper: ignore unknown witness types
This commit is contained in:
commit
90fe860a3c
@ -65,14 +65,13 @@ func (s *UtxoSweeper) CreateSweepTx(inputs []Input,
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
txWeight, csvCount, cltvCount := s.getWeightEstimate(inputs)
|
|
||||||
|
|
||||||
// Using the txn weight estimate, compute the required txn fee.
|
// Using the txn weight estimate, compute the required txn fee.
|
||||||
feePerKw, err := s.cfg.Estimator.EstimateFeePerKW(s.cfg.ConfTarget)
|
feePerKw, err := s.cfg.Estimator.EstimateFeePerKW(s.cfg.ConfTarget)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inputs, txWeight, csvCount, cltvCount := s.getWeightEstimate(inputs)
|
||||||
log.Infof("Creating sweep transaction for %v inputs (%v CSV, %v CLTV) "+
|
log.Infof("Creating sweep transaction for %v inputs (%v CSV, %v CLTV) "+
|
||||||
"using %v sat/kw", len(inputs), csvCount, cltvCount,
|
"using %v sat/kw", len(inputs), csvCount, cltvCount,
|
||||||
int64(feePerKw))
|
int64(feePerKw))
|
||||||
@ -149,7 +148,7 @@ func (s *UtxoSweeper) CreateSweepTx(inputs []Input,
|
|||||||
|
|
||||||
// getWeightEstimate returns a weight estimate for the given inputs.
|
// getWeightEstimate returns a weight estimate for the given inputs.
|
||||||
// Additionally, it returns counts for the number of csv and cltv inputs.
|
// Additionally, it returns counts for the number of csv and cltv inputs.
|
||||||
func (s *UtxoSweeper) getWeightEstimate(inputs []Input) (int64, int, int) {
|
func (s *UtxoSweeper) getWeightEstimate(inputs []Input) ([]Input, int64, int, int) {
|
||||||
|
|
||||||
// Create a transaction which sweeps all the newly mature outputs into
|
// Create a transaction which sweeps all the newly mature outputs into
|
||||||
// an output controlled by the wallet.
|
// an output controlled by the wallet.
|
||||||
@ -169,6 +168,7 @@ func (s *UtxoSweeper) getWeightEstimate(inputs []Input) (int64, int, int) {
|
|||||||
csvCount := 0
|
csvCount := 0
|
||||||
cltvCount := 0
|
cltvCount := 0
|
||||||
|
|
||||||
|
var sweepInputs []Input
|
||||||
for i := range inputs {
|
for i := range inputs {
|
||||||
input := inputs[i]
|
input := inputs[i]
|
||||||
|
|
||||||
@ -178,6 +178,7 @@ func (s *UtxoSweeper) getWeightEstimate(inputs []Input) (int64, int, int) {
|
|||||||
// to us.
|
// to us.
|
||||||
case lnwallet.CommitmentNoDelay:
|
case lnwallet.CommitmentNoDelay:
|
||||||
weightEstimate.AddP2WKHInput()
|
weightEstimate.AddP2WKHInput()
|
||||||
|
sweepInputs = append(sweepInputs, input)
|
||||||
|
|
||||||
// Outputs on a past commitment transaction that pay directly
|
// Outputs on a past commitment transaction that pay directly
|
||||||
// to us.
|
// to us.
|
||||||
@ -185,6 +186,7 @@ func (s *UtxoSweeper) getWeightEstimate(inputs []Input) (int64, int, int) {
|
|||||||
weightEstimate.AddWitnessInput(
|
weightEstimate.AddWitnessInput(
|
||||||
lnwallet.ToLocalTimeoutWitnessSize,
|
lnwallet.ToLocalTimeoutWitnessSize,
|
||||||
)
|
)
|
||||||
|
sweepInputs = append(sweepInputs, input)
|
||||||
csvCount++
|
csvCount++
|
||||||
|
|
||||||
// Outgoing second layer HTLC's that have confirmed within the
|
// Outgoing second layer HTLC's that have confirmed within the
|
||||||
@ -194,6 +196,7 @@ func (s *UtxoSweeper) getWeightEstimate(inputs []Input) (int64, int, int) {
|
|||||||
weightEstimate.AddWitnessInput(
|
weightEstimate.AddWitnessInput(
|
||||||
lnwallet.ToLocalTimeoutWitnessSize,
|
lnwallet.ToLocalTimeoutWitnessSize,
|
||||||
)
|
)
|
||||||
|
sweepInputs = append(sweepInputs, input)
|
||||||
csvCount++
|
csvCount++
|
||||||
|
|
||||||
// Incoming second layer HTLC's that have confirmed within the
|
// Incoming second layer HTLC's that have confirmed within the
|
||||||
@ -203,6 +206,7 @@ func (s *UtxoSweeper) getWeightEstimate(inputs []Input) (int64, int, int) {
|
|||||||
weightEstimate.AddWitnessInput(
|
weightEstimate.AddWitnessInput(
|
||||||
lnwallet.ToLocalTimeoutWitnessSize,
|
lnwallet.ToLocalTimeoutWitnessSize,
|
||||||
)
|
)
|
||||||
|
sweepInputs = append(sweepInputs, input)
|
||||||
csvCount++
|
csvCount++
|
||||||
|
|
||||||
// An HTLC on the commitment transaction of the remote party,
|
// An HTLC on the commitment transaction of the remote party,
|
||||||
@ -211,6 +215,7 @@ func (s *UtxoSweeper) getWeightEstimate(inputs []Input) (int64, int, int) {
|
|||||||
weightEstimate.AddWitnessInput(
|
weightEstimate.AddWitnessInput(
|
||||||
lnwallet.AcceptedHtlcTimeoutWitnessSize,
|
lnwallet.AcceptedHtlcTimeoutWitnessSize,
|
||||||
)
|
)
|
||||||
|
sweepInputs = append(sweepInputs, input)
|
||||||
cltvCount++
|
cltvCount++
|
||||||
|
|
||||||
// An HTLC on the commitment transaction of the remote party,
|
// An HTLC on the commitment transaction of the remote party,
|
||||||
@ -219,16 +224,16 @@ func (s *UtxoSweeper) getWeightEstimate(inputs []Input) (int64, int, int) {
|
|||||||
weightEstimate.AddWitnessInput(
|
weightEstimate.AddWitnessInput(
|
||||||
lnwallet.OfferedHtlcSuccessWitnessSize,
|
lnwallet.OfferedHtlcSuccessWitnessSize,
|
||||||
)
|
)
|
||||||
|
sweepInputs = append(sweepInputs, input)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
log.Warnf("kindergarten output in nursery store "+
|
log.Warnf("kindergarten output in nursery store "+
|
||||||
"contains unexpected witness type: %v",
|
"contains unexpected witness type: %v",
|
||||||
input.WitnessType())
|
input.WitnessType())
|
||||||
continue
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
txWeight := int64(weightEstimate.Weight())
|
txWeight := int64(weightEstimate.Weight())
|
||||||
|
|
||||||
return txWeight, csvCount, cltvCount
|
return sweepInputs, txWeight, csvCount, cltvCount
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user