bitcoin

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: AGPL-3.0 Imports: 20 Imported by: 0

Documentation

Overview

Package bitcoin reads a Bitcoin wallet from its extended public key (xpub, ypub or zpub): addresses are derived locally, history and balances come from an Esplora API (mempool.space by default, or your own instance). Litecoin, Dogecoin and Bitcoin Cash are read the same way (see Coin).

Index

Constants

View Source
const (

	// GapLimit is how many unused addresses in a row end a chain (BIP44).
	GapLimit = 20
)

Variables

View Source
var (
	Bitcoin = Coin{Name: "Bitcoin", Symbol: "BTC", /* contains filtered or unexported fields */}

	Litecoin = Coin{Name: "Litecoin", Symbol: "LTC", /* contains filtered or unexported fields */}

	Dogecoin = Coin{Name: "Dogecoin", Symbol: "DOGE", /* contains filtered or unexported fields */}

	BitcoinCash = Coin{Name: "Bitcoin Cash", Symbol: "BCH", /* contains filtered or unexported fields */}
)

Functions

func New

func New(cfg source.Config) (source.Source, error)

New builds a Bitcoin wallet from its settings.

func NewCoin

func NewCoin(coin Coin, cfg source.Config) (source.Source, error)

NewCoin builds a wallet of any Coin: cfg "xpub" is the account key (or "address" its only address), and "esplora_url" (Bitcoin and Litecoin) replaces the public servers.

Types

type Coin

type Coin struct {
	Name   string // "Bitcoin"
	Symbol string // "BTC"
	// contains filtered or unexported fields
}

Coin is a blockchain built like Bitcoin (UTXO, BIP32 keys): Litecoin, Dogecoin and Bitcoin Cash differ only in how keys and addresses are written, and in which public servers index them.

func (Coin) ValidAddress

func (c Coin) ValidAddress(a string) bool

ValidAddress reports whether a is one address of the coin (legacy, nested or native segwit, taproot). Bitcoin Cash addresses are not read alone: its wallets always give an extended public key.

type Wallet

type Wallet struct {
	// contains filtered or unexported fields
}

Wallet is a configured account of a Coin.

func (*Wallet) Activities

func (b *Wallet) Activities(ctx context.Context, f source.Fetch) error

func (*Wallet) Balances

func (b *Wallet) Balances(ctx context.Context) ([]model.Balance, error)

Balances sums the confirmed funds of every used address.

func (*Wallet) State

func (b *Wallet) State() []byte

func (*Wallet) Test

func (b *Wallet) Test(ctx context.Context) error

Test checks the key and that the Esplora API answers.

Jump to

Keyboard shortcuts

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