lnd: properly initialize LightningWallet with new config
This commit is contained in:
parent
522712b9a6
commit
a73589f3e9
@ -43,6 +43,15 @@ var defaultLitecoinForwardingPolicy = htlcswitch.ForwardingPolicy{
|
|||||||
TimeLockDelta: 1,
|
TimeLockDelta: 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// defaultChannelConstraints is the default set of channel constraints that are
|
||||||
|
// meant to be used when initially funding a channel.
|
||||||
|
//
|
||||||
|
// TODO(roasbeef): have one for both chains
|
||||||
|
var defaultChannelConstraints = channeldb.ChannelConstraints{
|
||||||
|
DustLimit: lnwallet.DefaultDustLimit(),
|
||||||
|
MaxAcceptedHtlcs: lnwallet.MaxHTLCNumber / 2,
|
||||||
|
}
|
||||||
|
|
||||||
// chainCode is an enum-like structure for keeping track of the chains currently
|
// chainCode is an enum-like structure for keeping track of the chains currently
|
||||||
// supported within lnd.
|
// supported within lnd.
|
||||||
type chainCode uint32
|
type chainCode uint32
|
||||||
@ -266,8 +275,17 @@ func newChainControlFromConfig(cfg *config, chanDB *channeldb.DB) (*chainControl
|
|||||||
|
|
||||||
// Create, and start the lnwallet, which handles the core payment
|
// Create, and start the lnwallet, which handles the core payment
|
||||||
// channel logic, and exposes control via proxy state machines.
|
// channel logic, and exposes control via proxy state machines.
|
||||||
wallet, err := lnwallet.NewLightningWallet(chanDB, cc.chainNotifier, wc,
|
walletCfg := lnwallet.Config{
|
||||||
cc.signer, cc.chainIO, cc.feeEstimator, activeNetParams.Params)
|
Database: chanDB,
|
||||||
|
Notifier: cc.chainNotifier,
|
||||||
|
WalletController: wc,
|
||||||
|
Signer: cc.signer,
|
||||||
|
FeeEstimator: cc.feeEstimator,
|
||||||
|
ChainIO: cc.chainIO,
|
||||||
|
DefaultConstraints: defaultChannelConstraints,
|
||||||
|
NetParams: *activeNetParams.Params,
|
||||||
|
}
|
||||||
|
wallet, err := lnwallet.NewLightningWallet(walletCfg)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Printf("unable to create wallet: %v\n", err)
|
fmt.Printf("unable to create wallet: %v\n", err)
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
|
3
lnd.go
3
lnd.go
@ -22,6 +22,7 @@ import (
|
|||||||
"github.com/lightningnetwork/lnd/lnwallet"
|
"github.com/lightningnetwork/lnd/lnwallet"
|
||||||
"github.com/lightningnetwork/lnd/lnwire"
|
"github.com/lightningnetwork/lnd/lnwire"
|
||||||
"github.com/roasbeef/btcd/btcec"
|
"github.com/roasbeef/btcd/btcec"
|
||||||
|
"github.com/roasbeef/btcutil"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -145,7 +146,7 @@ func lndMain() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for _, channel := range dbChannels {
|
for _, channel := range dbChannels {
|
||||||
if chanID.IsChanPoint(channel.ChanID) {
|
if chanID.IsChanPoint(&channel.FundingOutpoint) {
|
||||||
return lnwallet.NewLightningChannel(
|
return lnwallet.NewLightningChannel(
|
||||||
activeChainControl.signer,
|
activeChainControl.signer,
|
||||||
activeChainControl.chainNotifier,
|
activeChainControl.chainNotifier,
|
||||||
|
23
log.go
23
log.go
@ -36,20 +36,21 @@ func (logWriter) Write(p []byte) (n int, err error) {
|
|||||||
// subsystemLoggers map.
|
// subsystemLoggers map.
|
||||||
//
|
//
|
||||||
// Loggers can not be used before the log rotator has been initialized with a
|
// Loggers can not be used before the log rotator has been initialized with a
|
||||||
// log file. This must be performed early during application startup by calling
|
// log file. This must be performed early during application startup by
|
||||||
// initLogRotator.
|
// calling initLogRotator.
|
||||||
var (
|
var (
|
||||||
// backendLog is the logging backend used to create all subsystem loggers.
|
// backendLog is the logging backend used to create all subsystem
|
||||||
// The backend must not be used before the log rotator has been initialized,
|
// loggers. The backend must not be used before the log rotator has
|
||||||
// or data races and/or nil pointer dereferences will occur.
|
// been initialized, or data races and/or nil pointer dereferences will
|
||||||
|
// occur.
|
||||||
backendLog = btclog.NewBackend(logWriter{})
|
backendLog = btclog.NewBackend(logWriter{})
|
||||||
|
|
||||||
// logRotator is one of the logging outputs. It should be closed on
|
// logRotator is one of the logging outputs. It should be closed on
|
||||||
// application shutdown.
|
// application shutdown.
|
||||||
logRotator *rotator.Rotator
|
logRotator *rotator.Rotator
|
||||||
|
|
||||||
// logRotatorPipe is the write-end pipe for writing to the log rotator. It
|
// logRotatorPipe is the write-end pipe for writing to the log rotator.
|
||||||
// is written to by the Write method of the logWriter type.
|
// It is written to by the Write method of the logWriter type.
|
||||||
logRotatorPipe *io.PipeWriter
|
logRotatorPipe *io.PipeWriter
|
||||||
|
|
||||||
ltndLog = backendLog.Logger("LTND")
|
ltndLog = backendLog.Logger("LTND")
|
||||||
@ -100,9 +101,9 @@ var subsystemLoggers = map[string]btclog.Logger{
|
|||||||
"BTCN": btcnLog,
|
"BTCN": btcnLog,
|
||||||
}
|
}
|
||||||
|
|
||||||
// initLogRotator initializes the logging rotater to write logs to logFile and
|
// initLogRotator initializes the logging rotator to write logs to logFile and
|
||||||
// create roll files in the same directory. It must be called before the
|
// create roll files in the same directory. It must be called before the
|
||||||
// package-global log rotater variables are used.
|
// package-global log rotator variables are used.
|
||||||
func initLogRotator(logFile string) {
|
func initLogRotator(logFile string) {
|
||||||
logDir, _ := filepath.Split(logFile)
|
logDir, _ := filepath.Split(logFile)
|
||||||
err := os.MkdirAll(logDir, 0700)
|
err := os.MkdirAll(logDir, 0700)
|
||||||
@ -149,8 +150,8 @@ func setLogLevels(logLevel string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// logClosure is used to provide a closure over expensive logging operations
|
// logClosure is used to provide a closure over expensive logging operations so
|
||||||
// so don't have to be performed when the logging level doesn't warrant it.
|
// don't have to be performed when the logging level doesn't warrant it.
|
||||||
type logClosure func() string
|
type logClosure func() string
|
||||||
|
|
||||||
// String invokes the underlying function and returns the result.
|
// String invokes the underlying function and returns the result.
|
||||||
|
Loading…
Reference in New Issue
Block a user