From 3dc9e3c7d4105a19e767f33f3094214c05ae46f2 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Tue, 13 Feb 2018 15:05:19 +0100 Subject: [PATCH] server: express fee rates using fee rate types --- server.go | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/server.go b/server.go index 176ab57ee..8573b7d42 100644 --- a/server.go +++ b/server.go @@ -25,7 +25,6 @@ import ( "github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/routing" - "github.com/roasbeef/btcd/blockchain" "github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/chaincfg/chainhash" "github.com/roasbeef/btcd/connmgr" @@ -1651,7 +1650,7 @@ type openChanReq struct { pushAmt lnwire.MilliSatoshi - fundingFeePerWeight btcutil.Amount + fundingFeePerVSize lnwallet.SatPerVByte private bool @@ -1779,7 +1778,7 @@ func (s *server) DisconnectPeer(pubKey *btcec.PublicKey) error { func (s *server) OpenChannel(nodeKey *btcec.PublicKey, localAmt btcutil.Amount, pushAmt lnwire.MilliSatoshi, minHtlc lnwire.MilliSatoshi, - fundingFeePerByte btcutil.Amount, + fundingFeePerVSize lnwallet.SatPerVByte, private bool) (chan *lnrpc.OpenStatusUpdate, chan error) { updateChan := make(chan *lnrpc.OpenStatusUpdate, 1) @@ -1811,15 +1810,11 @@ func (s *server) OpenChannel(nodeKey *btcec.PublicKey, return updateChan, errChan } - // We'll scale the sat/byte set as the fee rate to sat/weight as this - // is what's used internally when deciding upon coin selection. - fundingFeePerWeight := fundingFeePerByte / blockchain.WitnessScaleFactor - - // If the fee rate wasn't high enough to cleanly convert to weight, - // then we'll use a default confirmation target. - if fundingFeePerWeight == 0 { + // If the fee rate wasn't specified, then we'll use a default + // confirmation target. + if fundingFeePerVSize == 0 { estimator := s.cc.feeEstimator - fundingFeePerWeight, err = estimator.EstimateFeePerWeight(6) + fundingFeePerVSize, err = estimator.EstimateFeePerVSize(6) if err != nil { errChan <- err return updateChan, errChan @@ -1831,15 +1826,15 @@ func (s *server) OpenChannel(nodeKey *btcec.PublicKey, // instead of blocking on this request which is exported as a // synchronous request to the outside world. req := &openChanReq{ - targetPubkey: nodeKey, - chainHash: *activeNetParams.GenesisHash, - localFundingAmt: localAmt, - fundingFeePerWeight: fundingFeePerWeight, - pushAmt: pushAmt, - private: private, - minHtlc: minHtlc, - updates: updateChan, - err: errChan, + targetPubkey: nodeKey, + chainHash: *activeNetParams.GenesisHash, + localFundingAmt: localAmt, + fundingFeePerVSize: fundingFeePerVSize, + pushAmt: pushAmt, + private: private, + minHtlc: minHtlc, + updates: updateChan, + err: errChan, } // TODO(roasbeef): pass in chan that's closed if/when funding succeeds