diff --git a/chainregistry.go b/chainregistry.go index d0f26a94..f54cafd3 100644 --- a/chainregistry.go +++ b/chainregistry.go @@ -83,9 +83,10 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB) (*chainControl estimator := lnwallet.StaticFeeEstimator{FeeRate: 50} walletConfig := &btcwallet.Config{ - PrivatePass: []byte("hello"), - DataDir: homeChainConfig.ChainDir, - NetParams: activeNetParams.Params, + PrivatePass: []byte("hello"), + DataDir: homeChainConfig.ChainDir, + NetParams: activeNetParams.Params, + FeeEstimator: estimator, } cc := &chainControl{ diff --git a/lnwallet/btcwallet/btcwallet.go b/lnwallet/btcwallet/btcwallet.go index 81c7d342..1650cb61 100644 --- a/lnwallet/btcwallet/btcwallet.go +++ b/lnwallet/btcwallet/btcwallet.go @@ -108,6 +108,14 @@ func New(cfg Config) (*BtcWallet, error) { return nil, err } + // Using the passed fee estimator, we'll compute the relay fee for all + // transactions made which will be scaled up according to the size of a + // particular transaction. + // + // TODO(roasbeef): hook in dynamic relay fees + relayFee := cfg.FeeEstimator.EstimateFeePerByte(3) * 1000 + wallet.SetRelayFee(btcutil.Amount(relayFee)) + return &BtcWallet{ cfg: &cfg, wallet: wallet, @@ -123,7 +131,7 @@ func New(cfg Config) (*BtcWallet, error) { // // This is a part of the WalletController interface. func (b *BtcWallet) Start() error { - // Establish an RPC connection in additino to starting the goroutines + // Establish an RPC connection in addition to starting the goroutines // in the underlying wallet. if err := b.chain.Start(); err != nil { return err @@ -465,7 +473,7 @@ func (b *BtcWallet) ListTransactionDetails() ([]*lnwallet.TransactionDetail, err txDetails := make([]*lnwallet.TransactionDetail, 0, len(txns.MinedTransactions)+len(txns.UnminedTransactions)) - // For both confirmed and unconfirme dtransactions, create a + // For both confirmed and unconfirmed transactions, create a // TransactionDetail which re-packages the data returned by the base // wallet. for _, blockPackage := range txns.MinedTransactions { diff --git a/lnwallet/btcwallet/config.go b/lnwallet/btcwallet/config.go index ab374de2..532ef3ca 100644 --- a/lnwallet/btcwallet/config.go +++ b/lnwallet/btcwallet/config.go @@ -3,6 +3,7 @@ package btcwallet import ( "path/filepath" + "github.com/lightningnetwork/lnd/lnwallet" "github.com/roasbeef/btcd/chaincfg" "github.com/roasbeef/btcd/wire" "github.com/roasbeef/btcutil" @@ -67,6 +68,11 @@ type Config struct { // notifications for received funds, etc. ChainSource chain.Interface + // FeeEstimator is an instance of the fee estimator interface which + // will be used by the wallet to dynamically set transaction fees when + // crafting transactions. + FeeEstimator lnwallet.FeeEstimator + // NetParams is the net parameters for the target chain. NetParams *chaincfg.Params } @@ -78,7 +84,7 @@ func networkDir(dataDir string, chainParams *chaincfg.Params) string { // For now, we must always name the testnet data directory as "testnet" // and not "testnet3" or any other version, as the chaincfg testnet3 - // paramaters will likely be switched to being named "testnet3" in the + // parameters will likely be switched to being named "testnet3" in the // future. This is done to future proof that change, and an upgrade // plan to move the testnet3 data directory can be worked out later. if chainParams.Net == wire.TestNet3 {