lntest: define BackendCfg and btcd impl
BackendCfg is an interface that can be backed by different Bitcoin node implementations. We currently use the btcdHarness as our chain backend.
This commit is contained in:
4 files changed
+123
-21
No files matched your search
+19
-11
@@ -22,7 +22,6 @@ import (
|
||||
|
||||
"github.com/btcsuite/btcd/chaincfg"
|
||||
"github.com/btcsuite/btcd/chaincfg/chainhash"
|
||||
"github.com/btcsuite/btcd/rpcclient"
|
||||
"github.com/btcsuite/btcd/wire"
|
||||
"github.com/btcsuite/btcutil"
|
||||
"github.com/go-errors/errors"
|
||||
@@ -91,12 +90,24 @@ func generateListeningPorts() (int, int, int) {
|
||||
return p2p, rpc, rest
|
||||
}
|
||||
|
||||
// BackendConfig is an interface that abstracts away the specific chain backend
|
||||
// node implementation.
|
||||
type BackendConfig interface {
|
||||
// GenArgs returns the arguments needed to be passed to LND at startup
|
||||
// for using this node as a chain backend.
|
||||
GenArgs() []string
|
||||
|
||||
// P2PAddr returns the address of this node to be used when connection
|
||||
// over the Bitcoin P2P network.
|
||||
P2PAddr() string
|
||||
}
|
||||
|
||||
type nodeConfig struct {
|
||||
Name string
|
||||
RPCConfig *rpcclient.ConnConfig
|
||||
NetParams *chaincfg.Params
|
||||
BaseDir string
|
||||
ExtraArgs []string
|
||||
Name string
|
||||
BackendCfg BackendConfig
|
||||
NetParams *chaincfg.Params
|
||||
BaseDir string
|
||||
ExtraArgs []string
|
||||
|
||||
DataDir string
|
||||
LogDir string
|
||||
@@ -144,16 +155,13 @@ func (cfg nodeConfig) genArgs() []string {
|
||||
args = append(args, "--bitcoin.regtest")
|
||||
}
|
||||
|
||||
encodedCert := hex.EncodeToString(cfg.RPCConfig.Certificates)
|
||||
backendArgs := cfg.BackendCfg.GenArgs()
|
||||
args = append(args, backendArgs...)
|
||||
args = append(args, "--bitcoin.active")
|
||||
args = append(args, "--nobootstrap")
|
||||
args = append(args, "--debuglevel=debug")
|
||||
args = append(args, "--bitcoin.defaultchanconfs=1")
|
||||
args = append(args, fmt.Sprintf("--bitcoin.defaultremotedelay=%v", DefaultCSV))
|
||||
args = append(args, fmt.Sprintf("--btcd.rpchost=%v", cfg.RPCConfig.Host))
|
||||
args = append(args, fmt.Sprintf("--btcd.rpcuser=%v", cfg.RPCConfig.User))
|
||||
args = append(args, fmt.Sprintf("--btcd.rpcpass=%v", cfg.RPCConfig.Pass))
|
||||
args = append(args, fmt.Sprintf("--btcd.rawrpccert=%v", encodedCert))
|
||||
args = append(args, fmt.Sprintf("--rpclisten=%v", cfg.RPCAddr()))
|
||||
args = append(args, fmt.Sprintf("--restlisten=%v", cfg.RESTAddr()))
|
||||
args = append(args, fmt.Sprintf("--listen=%v", cfg.P2PAddr()))
|
||||
|
||||
Reference in new issue
Block a user