btcdocker

package module
v0.0.0-...-3daaf66 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 3, 2024 License: Unlicense Imports: 19 Imported by: 0

README

BTC Docker Test

Create Bitcoind and Lnd containers in regtest. Useful for integration testing.

You need to have Docker installed.

import "github.com/elnosh/btc-docker-test"

ctx := context.Background()

bitcoind, err := btcdocker.NewBitcoind(ctx)
if err != nil {
    // handle err
}

blockchainInfo, err := bitcoind.Client.GetBlockchainInfo()

lnd, err := btcdocker.NewLnd(ctx, bitcoind)
if err != nil {
    // handle err
}

req := lnrpc.GetInfoRequest{}
info, err := lnd.Client.GetInfo(ctx, &req)

Inspired by Bitcoind and Lnd

Documentation

Index

Constants

View Source
const (
	RPC_USER                     = "testuser"
	RPC_PASSWORD                 = "testpassword"
	BITCOIND_RPC_PORT            = "18443"
	BITCOIND_ZMQPUBRAWBLOCK_PORT = "28334"
	BITCOIND_ZMQPUBRAWTX_PORT    = "28335"
)
View Source
const (
	LND_GRPC_PORT = "10009"
	LND_REST_PORT = "8080"
	LND_P2P_PORT  = "9735"
)

Variables

This section is empty.

Functions

func SetupLndClient

func SetupLndClient(host string, tlsCert string, macaroonBytes []byte) (lnrpc.LightningClient, error)

Types

type Bitcoind

type Bitcoind struct {
	testcontainers.Container
	Client *rpcclient.Client

	// ContainerIP is to be used when communicating between containers in the network
	ContainerIP string
	Host        string

	// These are the mapped ports which are exposed to the host
	RpcPort            string
	ZmqpubrawblockPort string
	ZmqpubrawtxPort    string
	// contains filtered or unexported fields
}

func NewBitcoind

func NewBitcoind(ctx context.Context) (*Bitcoind, error)

func (*Bitcoind) Terminate

func (bitcoind *Bitcoind) Terminate(ctx context.Context) error

type Lnd

type Lnd struct {
	testcontainers.Container
	Client lnrpc.LightningClient

	// ContainerIP is to be used when communicating between containers in the network
	ContainerIP string
	Host        string

	// These are the mapped ports which are exposed to the host
	GrpcPort string
	RestPort string
	P2PPort  string

	LndDir        string
	AdminMacaroon []byte
}

func NewLnd

func NewLnd(ctx context.Context, bitcoind *Bitcoind) (*Lnd, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL