Skip to content

Commit 9100be5

Browse files
committed
lntest: add method P2PAddr to backend
It is useful if we want to keep bitcoind main itest mode, but connect one node using neutrino.
1 parent 07217f2 commit 9100be5

File tree

4 files changed

+18
-0
lines changed

4 files changed

+18
-0
lines changed

lntest/bitcoind_common.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ func (b BitcoindBackendConfig) Name() string {
8585
return "bitcoind"
8686
}
8787

88+
// P2PAddr return bitcoin p2p ip:port.
89+
func (b BitcoindBackendConfig) P2PAddr() (string, error) {
90+
return fmt.Sprintf("127.0.0.1:%d", b.p2pPort), nil
91+
}
92+
8893
// newBackend starts a bitcoind node with the given extra parameters and returns
8994
// a BitcoindBackendConfig for that node.
9095
func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string,

lntest/btcd.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,11 @@ func (b BtcdBackendConfig) Name() string {
7474
return "btcd"
7575
}
7676

77+
// P2PAddr return bitcoin p2p ip:port.
78+
func (b BtcdBackendConfig) P2PAddr() (string, error) {
79+
return b.harness.P2PAddress(), nil
80+
}
81+
7782
// NewBackend starts a new rpctest.Harness and returns a BtcdBackendConfig for
7883
// that node. miner should be set to the P2P address of the miner to connect
7984
// to.

lntest/neutrino.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ func (b NeutrinoBackendConfig) Name() string {
5454
return NeutrinoBackendName
5555
}
5656

57+
// P2PAddr return bitcoin p2p ip:port.
58+
func (b NeutrinoBackendConfig) P2PAddr() (string, error) {
59+
return b.minerAddr, nil
60+
}
61+
5762
// NewBackend starts and returns a NeutrinoBackendConfig for the node.
5863
func NewBackend(miner string, _ *chaincfg.Params) (
5964
*NeutrinoBackendConfig, func() error, error) {

lntest/node/config.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ type BackendConfig interface {
114114
// Credentials returns the rpc username, password and host for the
115115
// backend.
116116
Credentials() (string, string, string, error)
117+
118+
// P2PAddr return bitcoin p2p ip:port.
119+
P2PAddr() (string, error)
117120
}
118121

119122
// BaseNodeConfig is the base node configuration.

0 commit comments

Comments
 (0)