breacharbiter: use EstimateFeePerVSize

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

View File

@ -1050,13 +1050,13 @@ func (b *breachArbiter) createJusticeTx(
spendableOutputs = append(spendableOutputs, input)
}
txWeight := uint64(weightEstimate.Weight())
return b.sweepSpendableOutputsTxn(txWeight, spendableOutputs...)
txVSize := int64(weightEstimate.VSize())
return b.sweepSpendableOutputsTxn(txVSize, spendableOutputs...)
}
// sweepSpendableOutputsTxn creates a signed transaction from a sequence of
// spendable outputs by sweeping the funds into a single p2wkh output.
func (b *breachArbiter) sweepSpendableOutputsTxn(txWeight uint64,
func (b *breachArbiter) sweepSpendableOutputsTxn(txVSize int64,
inputs ...SpendableOutput) (*wire.MsgTx, error) {
// First, we obtain a new public key script from the wallet which we'll
@ -1076,11 +1076,11 @@ func (b *breachArbiter) sweepSpendableOutputsTxn(txWeight uint64,
// We'll actually attempt to target inclusion within the next two
// blocks as we'd like to sweep these funds back into our wallet ASAP.
feePerWeight, err := b.cfg.Estimator.EstimateFeePerWeight(2)
feePerVSize, err := b.cfg.Estimator.EstimateFeePerVSize(2)
if err != nil {
return nil, err
}
txFee := btcutil.Amount(txWeight * uint64(feePerWeight))
txFee := feePerVSize.FeeForVSize(txVSize)
// TODO(roasbeef): already start to siphon their funds into fees
sweepAmt := int64(totalAmt - txFee)