lntest: add method P2PAddr to backend

It is useful if we want to keep bitcoind main itest mode, but connect one node
using neutrino.
This commit is contained in:
Boris Nagaev
2025-06-21 12:19:31 -03:00
parent 07217f2dd8
commit 9100be5ba5
4 changed files with 18 additions and 0 deletions

View File

@@ -85,6 +85,11 @@ func (b BitcoindBackendConfig) Name() string {
return "bitcoind"
}
// P2PAddr return bitcoin p2p ip:port.
func (b BitcoindBackendConfig) P2PAddr() (string, error) {
return fmt.Sprintf("127.0.0.1:%d", b.p2pPort), nil
}
// newBackend starts a bitcoind node with the given extra parameters and returns
// a BitcoindBackendConfig for that node.
func newBackend(miner string, netParams *chaincfg.Params, extraArgs []string,

View File

@@ -74,6 +74,11 @@ func (b BtcdBackendConfig) Name() string {
return "btcd"
}
// P2PAddr return bitcoin p2p ip:port.
func (b BtcdBackendConfig) P2PAddr() (string, error) {
return b.harness.P2PAddress(), nil
}
// NewBackend starts a new rpctest.Harness and returns a BtcdBackendConfig for
// that node. miner should be set to the P2P address of the miner to connect
// to.

View File

@@ -54,6 +54,11 @@ func (b NeutrinoBackendConfig) Name() string {
return NeutrinoBackendName
}
// P2PAddr return bitcoin p2p ip:port.
func (b NeutrinoBackendConfig) P2PAddr() (string, error) {
return b.minerAddr, nil
}
// NewBackend starts and returns a NeutrinoBackendConfig for the node.
func NewBackend(miner string, _ *chaincfg.Params) (
*NeutrinoBackendConfig, func() error, error) {

View File

@@ -114,6 +114,9 @@ type BackendConfig interface {
// Credentials returns the rpc username, password and host for the
// backend.
Credentials() (string, string, string, error)
// P2PAddr return bitcoin p2p ip:port.
P2PAddr() (string, error)
}
// BaseNodeConfig is the base node configuration.