btcdocker

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: Unlicense Imports: 9 Imported by: 3

README

BTC Docker Test

Utility to create bitcoind and other containers in regtest. Useful for integration testing.

Supports
  • bitcoind
  • LND
  • CLN

You need to have Docker installed.

import (
    btcdocker "github.com/elnosh/btc-docker-test"
    "github.com/elnosh/btc-docker-test/lnd"
    "github.com/elnosh/btc-docker-test/cln"
) 

ctx := context.Background()

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

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

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

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

// create CLN container
cln, err := cln.NewCLN(ctx, bitcoind)
if err != nil {
    // handle err
}

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"
)

Variables

This section is empty.

Functions

This section is empty.

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
	Network     string

	// These are the mapped ports which are exposed to the host
	RpcPort            string
	ZmqpubrawblockPort string
	ZmqpubrawtxPort    string

	Dir string
}

func NewBitcoind

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

func (*Bitcoind) Terminate

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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