mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-04-07 03:28:05 +02:00
Merge pull request #6088 from arshbot/export-backend-credentials
Export backend credentials
This commit is contained in:
commit
f788f9286e
@ -22,12 +22,12 @@ const logDirPattern = "%s/.backendlogs"
|
||||
// BitcoindBackendConfig is an implementation of the BackendConfig interface
|
||||
// backed by a Bitcoind node.
|
||||
type BitcoindBackendConfig struct {
|
||||
RpcHost string
|
||||
RpcUser string
|
||||
RpcPass string
|
||||
ZmqBlockPath string
|
||||
ZmqTxPath string
|
||||
P2pPort int
|
||||
rpcHost string
|
||||
rpcUser string
|
||||
rpcPass string
|
||||
zmqBlockPath string
|
||||
zmqTxPath string
|
||||
p2pPort int
|
||||
rpcClient *rpcclient.Client
|
||||
|
||||
// minerAddr is the p2p address of the miner to connect to.
|
||||
@ -43,13 +43,13 @@ var _ BackendConfig = (*BitcoindBackendConfig)(nil)
|
||||
func (b BitcoindBackendConfig) GenArgs() []string {
|
||||
var args []string
|
||||
args = append(args, "--bitcoin.node=bitcoind")
|
||||
args = append(args, fmt.Sprintf("--bitcoind.rpchost=%v", b.RpcHost))
|
||||
args = append(args, fmt.Sprintf("--bitcoind.rpcuser=%v", b.RpcUser))
|
||||
args = append(args, fmt.Sprintf("--bitcoind.rpcpass=%v", b.RpcPass))
|
||||
args = append(args, fmt.Sprintf("--bitcoind.rpchost=%v", b.rpcHost))
|
||||
args = append(args, fmt.Sprintf("--bitcoind.rpcuser=%v", b.rpcUser))
|
||||
args = append(args, fmt.Sprintf("--bitcoind.rpcpass=%v", b.rpcPass))
|
||||
args = append(args, fmt.Sprintf("--bitcoind.zmqpubrawblock=%v",
|
||||
b.ZmqBlockPath))
|
||||
b.zmqBlockPath))
|
||||
args = append(args, fmt.Sprintf("--bitcoind.zmqpubrawtx=%v",
|
||||
b.ZmqTxPath))
|
||||
b.zmqTxPath))
|
||||
|
||||
return args
|
||||
}
|
||||
@ -64,6 +64,11 @@ func (b BitcoindBackendConfig) DisconnectMiner() error {
|
||||
return b.rpcClient.AddNode(b.minerAddr, rpcclient.ANRemove)
|
||||
}
|
||||
|
||||
// Credentials returns the rpc username, password and host for the backend.
|
||||
func (b BitcoindBackendConfig) Credentials() (string, string, string, error) {
|
||||
return b.rpcUser, b.rpcPass, b.rpcHost, nil
|
||||
}
|
||||
|
||||
// Name returns the name of the backend type.
|
||||
func (b BitcoindBackendConfig) Name() string {
|
||||
return "bitcoind"
|
||||
@ -179,12 +184,12 @@ func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string) (
|
||||
}
|
||||
|
||||
bd := BitcoindBackendConfig{
|
||||
RpcHost: rpcHost,
|
||||
RpcUser: rpcUser,
|
||||
RpcPass: rpcPass,
|
||||
ZmqBlockPath: zmqBlockAddr,
|
||||
ZmqTxPath: zmqTxAddr,
|
||||
P2pPort: p2pPort,
|
||||
rpcHost: rpcHost,
|
||||
rpcUser: rpcUser,
|
||||
rpcPass: rpcPass,
|
||||
zmqBlockPath: zmqBlockAddr,
|
||||
zmqTxPath: zmqTxAddr,
|
||||
p2pPort: p2pPort,
|
||||
rpcClient: client,
|
||||
minerAddr: miner,
|
||||
}
|
||||
|
@ -67,6 +67,11 @@ func (b BtcdBackendConfig) DisconnectMiner() error {
|
||||
return b.harness.Client.Node(btcjson.NDisconnect, b.minerAddr, &temp)
|
||||
}
|
||||
|
||||
// Credentials returns the rpc username, password and host for the backend.
|
||||
func (b BtcdBackendConfig) Credentials() (string, string, string, error) {
|
||||
return b.rpcConfig.User, b.rpcConfig.Pass, b.rpcConfig.Host, nil
|
||||
}
|
||||
|
||||
// Name returns the name of the backend type.
|
||||
func (b BtcdBackendConfig) Name() string {
|
||||
return "btcd"
|
||||
|
@ -82,6 +82,10 @@ type BackendConfig interface {
|
||||
|
||||
// Name returns the name of the backend type.
|
||||
Name() string
|
||||
|
||||
// Credentials returns the rpc username, password and host for the
|
||||
// backend.
|
||||
Credentials() (string, string, string, error)
|
||||
}
|
||||
|
||||
// NodeConfig is the basic interface a node configuration must implement.
|
||||
|
@ -42,6 +42,12 @@ func (b NeutrinoBackendConfig) DisconnectMiner() error {
|
||||
return fmt.Errorf("unimplemented")
|
||||
}
|
||||
|
||||
// Credentials returns the rpc username, password and host for the backend.
|
||||
// For neutrino, we return an error because there is no rpc client available.
|
||||
func (b NeutrinoBackendConfig) Credentials() (string, string, string, error) {
|
||||
return "", "", "", fmt.Errorf("unimplemented")
|
||||
}
|
||||
|
||||
// Name returns the name of the backend type.
|
||||
func (b NeutrinoBackendConfig) Name() string {
|
||||
return NeutrinoBackendName
|
||||
|
Loading…
x
Reference in New Issue
Block a user