From 166637bb5599ffa99a1e234bae75fa96fb377cab Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 13 Feb 2018 14:59:55 +0100 Subject: [PATCH] contractcourt: use vsize fee estimate and new fee rate types --- contractcourt/contract_resolvers.go | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/contractcourt/contract_resolvers.go b/contractcourt/contract_resolvers.go index 5cc9ffa6..6cb8063c 100644 --- a/contractcourt/contract_resolvers.go +++ b/contractcourt/contract_resolvers.go @@ -482,23 +482,24 @@ func (h *htlcSuccessResolver) Resolve() (ContractResolver, error) { // // TODO(roasbeef): signal up if fee would be too large // to sweep singly, need to batch - satWeight, err := h.FeeEstimator.EstimateFeePerWeight(6) + feePerVSize, err := h.FeeEstimator.EstimateFeePerVSize(6) if err != nil { return nil, err } - log.Debugf("%T(%x): using %v sat/weight to sweep htlc"+ + log.Debugf("%T(%x): using %v sat/vbyte to sweep htlc"+ "incoming+remote htlc confirmed", h, - h.payHash[:], int64(satWeight)) + h.payHash[:], int64(feePerVSize)) // Using a weight estimator, we'll compute the total // fee required, and from that the value we'll end up // with. - totalWeight := (&lnwallet.TxWeightEstimator{}). + totalVSize := (&lnwallet.TxWeightEstimator{}). AddWitnessInput(lnwallet.OfferedHtlcSuccessWitnessSize). - AddP2WKHOutput().Weight() - totalFees := int64(totalWeight) * int64(satWeight) - sweepAmt := h.htlcResolution.SweepSignDesc.Output.Value - totalFees + AddP2WKHOutput().VSize() + totalFees := feePerVSize.FeeForVSize(int64(totalVSize)) + sweepAmt := h.htlcResolution.SweepSignDesc.Output.Value - + int64(totalFees) // With the fee computation finished, we'll now // construct the sweep transaction. @@ -1252,19 +1253,19 @@ func (c *commitSweepResolver) Resolve() (ContractResolver, error) { // First, we'll estimate the total weight so we can compute // fees properly. We'll use a lax estimate, as this output is // in no immediate danger. - satWeight, err := c.FeeEstimator.EstimateFeePerWeight(6) + feePerVSize, err := c.FeeEstimator.EstimateFeePerVSize(6) if err != nil { return nil, err } - log.Debugf("%T(%v): using %v sat/weight for sweep tx", c, - c.chanPoint, int64(satWeight)) + log.Debugf("%T(%v): using %v sat/vsize for sweep tx", c, + c.chanPoint, int64(feePerVSize)) - totalWeight := (&lnwallet.TxWeightEstimator{}). + totalVSize := (&lnwallet.TxWeightEstimator{}). AddP2PKHInput(). - AddP2WKHOutput().Weight() - totalFees := int64(totalWeight) * int64(satWeight) - sweepAmt := signDesc.Output.Value - totalFees + AddP2WKHOutput().VSize() + totalFees := feePerVSize.FeeForVSize(int64(totalVSize)) + sweepAmt := signDesc.Output.Value - int64(totalFees) c.sweepTx = wire.NewMsgTx(2) c.sweepTx.AddTxIn(&wire.TxIn{