utxonursery: use EstimateFeePerVSize

This commit is contained in:
Johan T. Halseth 2018-02-13 15:04:33 +01:00
parent 2a9aa092d8
commit 5f267bcc5b
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26
1 changed files with 5 additions and 5 deletions

View File

@ -994,15 +994,15 @@ func (u *utxoNursery) createSweepTx(kgtnOutputs []kidOutput,
utxnLog.Infof("Creating sweep transaction for %v CSV inputs, %v CLTV "+ utxnLog.Infof("Creating sweep transaction for %v CSV inputs, %v CLTV "+
"inputs", len(csvOutputs), len(cltvOutputs)) "inputs", len(csvOutputs), len(cltvOutputs))
txWeight := uint64(weightEstimate.Weight()) txVSize := int64(weightEstimate.VSize())
return u.populateSweepTx(txWeight, classHeight, csvOutputs, cltvOutputs) return u.populateSweepTx(txVSize, classHeight, csvOutputs, cltvOutputs)
} }
// populateSweepTx populate the final sweeping transaction with all witnesses // populateSweepTx populate the final sweeping transaction with all witnesses
// in place for all inputs using the provided txn fee. The created transaction // in place for all inputs using the provided txn fee. The created transaction
// has a single output sending all the funds back to the source wallet, after // has a single output sending all the funds back to the source wallet, after
// accounting for the fee estimate. // accounting for the fee estimate.
func (u *utxoNursery) populateSweepTx(txWeight uint64, classHeight uint32, func (u *utxoNursery) populateSweepTx(txVSize int64, classHeight uint32,
csvInputs []CsvSpendableOutput, csvInputs []CsvSpendableOutput,
cltvInputs []SpendableOutput) (*wire.MsgTx, error) { cltvInputs []SpendableOutput) (*wire.MsgTx, error) {
@ -1022,11 +1022,11 @@ func (u *utxoNursery) populateSweepTx(txWeight uint64, classHeight uint32,
} }
// Using the txn weight estimate, compute the required txn fee. // Using the txn weight estimate, compute the required txn fee.
feePerWeight, err := u.cfg.Estimator.EstimateFeePerWeight(6) feePerVSize, err := u.cfg.Estimator.EstimateFeePerVSize(6)
if err != nil { if err != nil {
return nil, err return nil, err
} }
txFee := btcutil.Amount(txWeight) * feePerWeight txFee := feePerVSize.FeeForVSize(txVSize)
// Sweep as much possible, after subtracting txn fees. // Sweep as much possible, after subtracting txn fees.
sweepAmt := int64(totalSum - txFee) sweepAmt := int64(totalSum - txFee)