From 52e6cb1a06b77e03d3ce7cea933ab85b43d5c064 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sun, 26 Nov 2017 13:35:25 -0600 Subject: [PATCH] lnwallet: correct BTC -> SAT conversion in BtcdFeeEstimator In this commit, we correct the BTC -> SAT conversion in BtcdFeeEstimator. Previously, we use 10e8 instead of 1e8, causing us to be off by an order of magnitude. --- lnwallet/fee_estimator.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lnwallet/fee_estimator.go b/lnwallet/fee_estimator.go index 5c9c6b08f..845d98ab4 100644 --- a/lnwallet/fee_estimator.go +++ b/lnwallet/fee_estimator.go @@ -173,12 +173,15 @@ func (b *BtcdFeeEstimator) fetchEstimatePerByte(confTarget uint32) (btcutil.Amou // Next, we'll convert the returned value to satoshis, as it's // currently returned in BTC. - satPerKB := uint64(btcPerKB * 10e8) + satPerKB, err := btcutil.NewAmount(btcPerKB) + if err != nil { + return 0, err + } // The value returned is expressed in fees per KB, while we want // fee-per-byte, so we'll divide by 1024 to map to satoshis-per-byte // before returning the estimate. - satPerByte := btcutil.Amount(satPerKB / 1024) + satPerByte := satPerKB / 1024 walletLog.Debugf("Returning %v sat/byte for conf target of %v", int64(satPerByte), confTarget)