chaincfg

package
v0.33.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 18 Imported by: 1 module, 2 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package chaincfg builds what every bstore program reads the chain through from its configuration: the chain view (transactions, proofs, spends), the header source and the tip, the settlement leg, and the miner fee policy. The writer's home, the S3 gateway and the provider share it, so each backend is configuration and the same keys mean the same thing in each.

Nothing here needs a node. On mainnet and testnet the defaults are the zero-infrastructure profile: WhatsOnChain for the chain view and the headers (every header held to its proof of work, every proof to those headers) and GorillaPool's public arcade to broadcast. A node is still the better chain view ("asset:URL"): it removes the one trust WhatsOnChain adds, its word that an output is unspent.

Index

Constants

This section is empty.

Variables

View Source
var ErrSpec = errors.New("chaincfg")

ErrSpec is a configuration that cannot be used.

View Source
var ErrUnmined = bwallet.ErrUnmined

ErrUnmined is a payment imported by txid that has no block yet.

Functions

func ReadBEEF

func ReadBEEF(path string, stdin io.Reader) ([]byte, error)

ReadBEEF reads a payment's BEEF from a file, or stdin for "-", as bytes or as hex.

Types

type Funded

type Funded struct {
	// Txid is the payment; Mined whether it has a block, Height which.
	Txid   string
	Mined  bool
	Height uint32
	// Paying is how many outputs pay the fund address; Held how many of
	// them the pool held already and Spent how many the chain view shows
	// spent (both left out); Added how many entered the pool, Satoshis
	// their sum.
	Paying   int
	Held     int
	Spent    int
	Added    int
	Satoshis uint64
}

Funded is what an import of a payment took into a pool.

type Line

type Line struct{ Label, Text string }

Line is one line of a status report.

type Spec

type Spec struct {
	// Network is main, test or regtest. A regtest chain has no public
	// services: it needs Chain (or Node), Settle and Headers.
	Network string
	// Chain is a nodeapi.ParseChain specification (woc:main, woc:test,
	// asset:URL, or a list); empty is woc:<network>. Node is the older
	// key, a node's asset API URL, read as asset:<Node>; both set is
	// refused.
	Chain string
	Node  string
	// Settle is a publish.ParseSettler specification; empty is
	// publish.DefaultSettle(network), GorillaPool's arcade. ArcadeKey is
	// the bearer token of an arcade or ARC leg; RPCUser, RPCPass and RPCID
	// authenticate an rpc: leg (RPCID default "bstore").
	Settle    string
	ArcadeKey string
	RPCUser   string
	RPCPass   string
	RPCID     string
	// Headers is a headers.New specification; empty is woc:<network>.
	// HeadersToken is a bearer token for a block-headers-service.
	Headers      string
	HeadersToken string
	// WoCKey is a WhatsOnChain API key and WoCRate its requests a second
	// (zero is the free tier's 3). A busy program needs one, or a node.
	WoCKey  string
	WoCRate float64
	// Fee is the fee block; FeeRate and FeeFloor the older keys
	// fee_sat_per_byte and fee_floor (zero: absent), folded in by
	// feepolicy.MergeLegacy.
	Fee      *feepolicy.Config
	FeeRate  uint64
	FeeFloor uint64
	// Client, when set, is every backend's HTTP client.
	Client *http.Client
}

Spec is the chain, settlement and fee settings of one configuration. Every field but Network is optional on mainnet and testnet.

func (Spec) ChainSpec

func (s Spec) ChainSpec() (string, error)

ChainSpec is the chain view specification in force.

func (Spec) Check

func (s Spec) Check() error

Check refuses a configuration that cannot be opened, reaching nothing.

func (Spec) FeeConfig

func (s Spec) FeeConfig() (*feepolicy.Config, error)

FeeConfig is the fee block with the older keys folded in.

func (Spec) Fees

func (s Spec) Fees() (mint.Fees, error)

Fees is the static fees the configuration names (a live policy's fallback), over mint.DefaultFees.

func (Spec) HeadersSpec

func (s Spec) HeadersSpec() (string, error)

HeadersSpec is the header source specification in force.

func (Spec) SettleSpec

func (s Spec) SettleSpec() (string, error)

SettleSpec is the settlement specification in force.

type Tip

type Tip interface {
	CurrentHeight(ctx context.Context) (uint32, error)
	HeaderAt(ctx context.Context, height uint32) (*headers.Header, error)
}

Tip is the chain's height and a block's header by height, from the header source.

type View

type View struct {
	Network string
	// ChainSpec, SettleSpec and HeadersSpec are the specifications in
	// force, for a status line.
	ChainSpec, SettleSpec, HeadersSpec string
	// Chain is the chain view: arcade's proofs of what it was sent first
	// when the leg is arcade or ARC, then the configured backends, every
	// proof checked against Headers.
	Chain *nodeapi.Sources
	// Known says whether the network holds a transaction, mined or not:
	// the chain view's word, as a node's was. Not arcade's: arcade knows
	// what it was sent even when the network refused it, and a
	// transaction refused must not read as one waiting to mine.
	Known nodeapi.KnownSource
	// Asset is the node, when the chain view names one (asset:URL):
	// coinbase funding on a regtest chain needs it.
	Asset *nodeapi.Asset
	// Headers is the header source; Tip reads the height and a header by
	// height from it.
	Headers *headers.Client
	Tip     Tip
	// Settler is the settlement leg, every input given its source
	// transaction where the leg wants one; Arcade the leg itself when it
	// is arcade or ARC, RPC when it is a node's.
	Settler bpub.Settler
	Arcade  *bpub.Arcade
	RPC     *nodeapi.RPC
	// FeeSource answers the fees a build uses: static, or a broadcaster's
	// live policy (fee.source arc).
	FeeSource feepolicy.Source
}

View is an opened configuration.

func Open

func Open(s Spec) (*View, error)

Open builds the backends a configuration names. It reaches nothing.

func (*View) CacheSpends added in v0.11.2

func (v *View) CacheSpends()

CacheSpends is for a long-running service, whose answers may be spendTTL old in exchange for reading a transaction once. A hold transaction holds up to 1,024 outputs and a node answers for all of them at once: one read serves every entry on that transaction, where a read per entry kept a node's cores busy with no put running. A command that acts once on what it reads keeps the plain view.

func (*View) Fees

func (v *View) Fees(ctx context.Context) mint.Fees

Fees is the fee policy now. A live policy never fails on the network: it answers its last good value, then the static fees.

func (*View) FundBEEF

func (v *View) FundBEEF(ctx context.Context, s *bwallet.Signer, pool *bwallet.Pool, beef []byte, refuseUnmined bool) (Funded, error)

FundBEEF imports a payment to the signer's fund address handed over as BEEF, as a wallet answers a payment (bwallet.ImportBEEF): no lookup. A mined payment's proof is checked against the headers. An unmined one is taken when every parent it spends is proven, unless refuseUnmined; it is handed to the settlement leg (in case the wallet did not broadcast it), and its outputs wait in the pool until its proof is collected.

func (*View) FundTxid

func (v *View) FundTxid(ctx context.Context, s *bwallet.Signer, pool *bwallet.Pool, txid string) (Funded, error)

FundTxid imports a mined payment to the signer's fund address by txid: fetched with its proof from the chain view, the proof checked against the headers (bwallet.ImportTxid). A payment not mined yet is ErrUnmined.

func (*View) Report

func (v *View) Report(ctx context.Context) []Line

Report reads, and spends nothing: whether the chain view, the header source and the settlement leg answer, and the fee policy in force.

Jump to

Keyboard shortcuts

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