server: express fee rates using fee rate types

This commit is contained in:
Johan T. Halseth 2018-02-13 15:05:19 +01:00
parent 5f267bcc5b
commit 3dc9e3c7d4
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -25,7 +25,6 @@ import (
"github.com/lightningnetwork/lnd/lnwallet" "github.com/lightningnetwork/lnd/lnwallet"
"github.com/lightningnetwork/lnd/lnwire" "github.com/lightningnetwork/lnd/lnwire"
"github.com/lightningnetwork/lnd/routing" "github.com/lightningnetwork/lnd/routing"
"github.com/roasbeef/btcd/blockchain"
"github.com/roasbeef/btcd/btcec" "github.com/roasbeef/btcd/btcec"
"github.com/roasbeef/btcd/chaincfg/chainhash" "github.com/roasbeef/btcd/chaincfg/chainhash"
"github.com/roasbeef/btcd/connmgr" "github.com/roasbeef/btcd/connmgr"
@ -1651,7 +1650,7 @@ type openChanReq struct {
pushAmt lnwire.MilliSatoshi pushAmt lnwire.MilliSatoshi
fundingFeePerWeight btcutil.Amount fundingFeePerVSize lnwallet.SatPerVByte
private bool private bool
@ -1779,7 +1778,7 @@ func (s *server) DisconnectPeer(pubKey *btcec.PublicKey) error {
func (s *server) OpenChannel(nodeKey *btcec.PublicKey, func (s *server) OpenChannel(nodeKey *btcec.PublicKey,
localAmt btcutil.Amount, pushAmt lnwire.MilliSatoshi, localAmt btcutil.Amount, pushAmt lnwire.MilliSatoshi,
minHtlc lnwire.MilliSatoshi, minHtlc lnwire.MilliSatoshi,
fundingFeePerByte btcutil.Amount, fundingFeePerVSize lnwallet.SatPerVByte,
private bool) (chan *lnrpc.OpenStatusUpdate, chan error) { private bool) (chan *lnrpc.OpenStatusUpdate, chan error) {
updateChan := make(chan *lnrpc.OpenStatusUpdate, 1) updateChan := make(chan *lnrpc.OpenStatusUpdate, 1)
@ -1811,15 +1810,11 @@ func (s *server) OpenChannel(nodeKey *btcec.PublicKey,
return updateChan, errChan return updateChan, errChan
} }
// We'll scale the sat/byte set as the fee rate to sat/weight as this // If the fee rate wasn't specified, then we'll use a default
// is what's used internally when deciding upon coin selection. // confirmation target.
fundingFeePerWeight := fundingFeePerByte / blockchain.WitnessScaleFactor if fundingFeePerVSize == 0 {
// If the fee rate wasn't high enough to cleanly convert to weight,
// then we'll use a default confirmation target.
if fundingFeePerWeight == 0 {
estimator := s.cc.feeEstimator estimator := s.cc.feeEstimator
fundingFeePerWeight, err = estimator.EstimateFeePerWeight(6) fundingFeePerVSize, err = estimator.EstimateFeePerVSize(6)
if err != nil { if err != nil {
errChan <- err errChan <- err
return updateChan, errChan 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 // instead of blocking on this request which is exported as a
// synchronous request to the outside world. // synchronous request to the outside world.
req := &openChanReq{ req := &openChanReq{
targetPubkey: nodeKey, targetPubkey: nodeKey,
chainHash: *activeNetParams.GenesisHash, chainHash: *activeNetParams.GenesisHash,
localFundingAmt: localAmt, localFundingAmt: localAmt,
fundingFeePerWeight: fundingFeePerWeight, fundingFeePerVSize: fundingFeePerVSize,
pushAmt: pushAmt, pushAmt: pushAmt,
private: private, private: private,
minHtlc: minHtlc, minHtlc: minHtlc,
updates: updateChan, updates: updateChan,
err: errChan, err: errChan,
} }
// TODO(roasbeef): pass in chan that's closed if/when funding succeeds // TODO(roasbeef): pass in chan that's closed if/when funding succeeds