2019-05-24 15:17:49 +03:00
|
|
|
// +build neutrino
|
|
|
|
|
|
|
|
package lntest
|
|
|
|
|
2019-07-11 14:51:22 +03:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/btcsuite/btcd/chaincfg"
|
|
|
|
)
|
2019-05-24 15:17:49 +03:00
|
|
|
|
|
|
|
// NeutrinoBackendConfig is an implementation of the BackendConfig interface
|
|
|
|
// backed by a neutrino node.
|
|
|
|
type NeutrinoBackendConfig struct {
|
|
|
|
minerAddr string
|
|
|
|
}
|
|
|
|
|
2019-07-11 14:51:22 +03:00
|
|
|
// A compile time assertion to ensure NeutrinoBackendConfig meets the
|
|
|
|
// BackendConfig interface.
|
|
|
|
var _ BackendConfig = (*NeutrinoBackendConfig)(nil)
|
|
|
|
|
2019-05-24 15:17:49 +03:00
|
|
|
// GenArgs returns the arguments needed to be passed to LND at startup for
|
|
|
|
// using this node as a chain backend.
|
|
|
|
func (b NeutrinoBackendConfig) GenArgs() []string {
|
|
|
|
var args []string
|
|
|
|
args = append(args, "--bitcoin.node=neutrino")
|
|
|
|
args = append(args, "--neutrino.connect="+b.minerAddr)
|
|
|
|
return args
|
|
|
|
}
|
|
|
|
|
|
|
|
// ConnectMiner is called to establish a connection to the test miner.
|
|
|
|
func (b NeutrinoBackendConfig) ConnectMiner() error {
|
2020-09-03 13:59:08 +03:00
|
|
|
return nil
|
2019-05-24 15:17:49 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// DisconnectMiner is called to disconnect the miner.
|
|
|
|
func (b NeutrinoBackendConfig) DisconnectMiner() error {
|
|
|
|
return fmt.Errorf("unimplemented")
|
|
|
|
}
|
|
|
|
|
2019-05-24 15:17:49 +03:00
|
|
|
// Name returns the name of the backend type.
|
|
|
|
func (b NeutrinoBackendConfig) Name() string {
|
2021-02-20 04:42:20 +03:00
|
|
|
return NeutrinoBackendName
|
2019-05-24 15:17:49 +03:00
|
|
|
}
|
|
|
|
|
2019-05-24 15:17:49 +03:00
|
|
|
// NewBackend starts and returns a NeutrinoBackendConfig for the node.
|
2019-07-11 14:51:22 +03:00
|
|
|
func NewBackend(miner string, _ *chaincfg.Params) (
|
2020-09-02 22:15:04 +03:00
|
|
|
*NeutrinoBackendConfig, func() error, error) {
|
2019-07-11 14:51:22 +03:00
|
|
|
|
2019-05-24 15:17:49 +03:00
|
|
|
bd := &NeutrinoBackendConfig{
|
|
|
|
minerAddr: miner,
|
|
|
|
}
|
|
|
|
|
2020-09-02 22:15:04 +03:00
|
|
|
cleanUp := func() error { return nil }
|
2019-05-24 15:17:49 +03:00
|
|
|
return bd, cleanUp, nil
|
|
|
|
}
|