config

package
v0.6.11 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 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 config resolves the bbox command's settings: flags, then BBOX_* in the environment, then the config file, then the built-in default.

The overlay hosts, the facade and the host a priced question goes to have no default: a default there would quietly send a sender's envelopes or a reader's questions to somebody else's server, so a command that needs one and finds none is a usage error. The chain services do have one on main and test, so that no node is needed: WhatsOnChain for headers and the chain view, and GorillaPool's public arcade to broadcast. A regtest chain has no public services, and names its own.

Index

Constants

View Source
const (
	ModePlane      = "plane"
	ModeUnicast    = "unicast"
	QuorumAll      = "all"
	QuorumMajority = "majority"
	QuorumOne      = "one"
)

The modes and the named quorums.

Variables

View Source
var ErrUnknownKey = errors.New("config: unknown key")

ErrUnknownKey reports a key the grammar does not define.

View Source
var Keys = []string{"accept_payer_limit", "accept_threshold_sats", "accept_total_limit", "accept_watch", "accept_window", "arcade_key", "asset", "box", "chain", "facade", "fee_dust", "fee_floor", "fee_max_rate", "fee_max_tx", "fee_min_rate", "fee_policy_urls", "fee_rate", "fee_source", "fund_mined_only", "header_token", "header_url", "history_host", "home", "hosts", "mode", "network", "object_bound", "office", "originator", "quorum", "rpc", "rpc_pass", "rpc_user", "settle", "timeout", "tree_count", "woc_key", "woc_rate"}

Keys is the file grammar's key list, in lexicographic order. A key not in it is an error: a misspelt key that was silently ignored would leave a setting at its default with no sign that the file was ever read.

Functions

func Backends added in v0.4.0

func Backends(spec string) []string

Backends are the backends a chain specification names, each without the method it is qualified by (tx=, proof=, spend=, known=).

func DefaultHome

func DefaultHome() string

DefaultHome is ~/.bbox, or .bbox when there is no home directory.

func Need

func Need(q string, n int) (int, error)

Need is how many of n hosts the quorum q requires. A number above n is an error: a quorum no host set can meet would refuse every publish.

func Parse

func Parse(r io.Reader) (map[string]string, error)

Parse reads the key = value grammar: one setting per line, '#' comments, blank lines ignored, a key at most once.

func Path

func Path(flagPath string, getenv func(string) string) string

Path is the config file location: the -config flag, else $BBOX_HOME/config, else $XDG_CONFIG_HOME/bbox/config, else ~/.bbox/config.

Types

type Config

type Config struct {
	// AcceptPayerLimit and AcceptTotalLimit bound the satoshis taken on
	// the fast path and not yet mined, per payer and in all; zero is one
	// and ten thresholds. AcceptThresholdSats is the largest payment taken
	// on the network's acceptance; above it a payment waits for its block.
	// AcceptWatch is how long to watch for a conflict before taking one
	// fast, and AcceptWindow how long one counts against the limits unless
	// it mines first (bcommon acceptance.Policy).
	AcceptPayerLimit    uint64
	AcceptThresholdSats uint64
	AcceptTotalLimit    uint64
	AcceptWatch         time.Duration
	AcceptWindow        time.Duration
	// ArcadeKey is the bearer token for an arcade installation in Settle.
	ArcadeKey string
	// Asset is the older spelling of Chain = asset:<Asset>: a node's asset
	// API base URL. It may not be set beside Chain.
	Asset string
	// Chain is the chain view transactions, proofs and spends are read
	// from (bcommon nodeapi.ParseChain): woc:main, woc:test,
	// asset:<node URL>, or a list of them. Empty is woc:<Network> on main
	// and test (ChainSpec).
	Chain string
	// Box is the box an envelope goes to when send names none, and the
	// box list and read ask about when they name none; empty asks about
	// every box.
	Box string
	// Fee is the miner fee policy (bcommon feepolicy.Config): the fee_*
	// keys. Every key unset is mint.DefaultFees, the network's rate.
	Fee feepolicy.Config
	// FundMinedOnly refuses, at fund -beef, a payment that has not mined.
	FundMinedOnly bool
	// Facade is the overlay host a publisher submits to in mode plane.
	Facade string
	// HeaderURL is the header source every proof is checked against: a
	// bridge's /v1 base URL, woc:main, woc:test, bhs:URL,
	// arcade:URL or chaintracks:URL. Empty is woc:<Network> on main and
	// test (Headers). HeaderToken is the bearer token a
	// block-headers-service asks for.
	HeaderToken string
	HeaderURL   string
	// HistoryHost is the base URL of ls_bbox on the host a priced history
	// question is asked of: the host's terms route (spec section 7.4).
	HistoryHost string
	// Home is the identity's directory: key, coin pool and state.
	Home string
	// Hosts are the overlay hosts a reader asks. In mode unicast they are
	// every host a publisher submits to; in mode plane a sweep also goes
	// to each of them directly.
	Hosts []string
	// Mode is how a publisher's objects reach the hosts: "plane" (one
	// submit to Facade, which the plane delivers to every subscribed host)
	// or "unicast" (one submit to each of Hosts).
	Mode string
	// Network is "main", "test" or "regtest": the fund address's prefix
	// and the proof-of-work floor a header source is held to.
	Network string
	// ObjectBound is the largest object the plane takes, in bytes.
	ObjectBound int
	// Office is the office identifier <name>_<suffix> a command uses when
	// it names none.
	Office string
	// Originator is the BRC-100 originator presented to the wallet.
	Originator string
	// Quorum is, in mode unicast, how many of Hosts must take an object
	// for it to count as published: "all", "majority", "one" or a number.
	Quorum string
	// RPC is the node's JSON-RPC URL; RPCUser and RPCPass its basic auth.
	RPC     string
	RPCPass string
	RPCUser string
	// Settle is the settlement leg mined transactions go to (funding
	// trees, sweeps, payments a recipient internalizes), as bcommon
	// publish.ParseSettler reads it: arcade:main, arcade:test,
	// arcade:<url>, arc:<url>, rpc:<url> or tcp:<host:port>. Empty is
	// arcade:<Network> on main and test (SettleSpec).
	Settle string
	// Timeout bounds each request to a host, node or header source.
	Timeout time.Duration
	// TreeCount is how many outputs a new funding tree has.
	TreeCount int
	// WoCKey is a WhatsOnChain API key, and WoCRate the requests a second
	// its plan allows (zero is the free tier's 3).
	WoCKey  string
	WoCRate float64
}

Config is the resolved settings.

func Defaults

func Defaults() Config

Defaults are the built-in values for the keys that have one.

func Load

func Load(path string, getenv func(string) string) (Config, error)

Load resolves the file (a missing one is fine) and the environment over the defaults. Flags are applied by the caller afterwards with Apply.

func (Config) AcceptPolicy added in v0.2.0

func (c Config) AcceptPolicy() acceptance.Policy

AcceptPolicy is the payment acceptance rule the settings name.

func (Config) Apply

func (c Config) Apply(vals map[string]string) (Config, error)

Apply sets the given keys the same way for a file, the environment or flags, so all three parse alike.

func (Config) AssetURL added in v0.4.0

func (c Config) AssetURL() string

AssetURL is the node the chain view names, for what only a node does (coinbase on a regtest chain): Asset, else the first asset: backend in Chain. Empty when there is none.

func (Config) ChainSpec added in v0.4.0

func (c Config) ChainSpec() string

ChainSpec is the chain view: Chain, else asset:<Asset>, else WhatsOnChain on main and test. Empty on regtest with none set.

func (Config) Headers added in v0.4.0

func (c Config) Headers() string

Headers is the header source: HeaderURL, else WhatsOnChain on main and test. Empty on regtest with none set.

func (Config) SettleSpec added in v0.4.0

func (c Config) SettleSpec() string

SettleSpec is the settlement leg: Settle, else GorillaPool's public arcade on main and test (publish.DefaultSettle). Empty on regtest with none set.

Jump to

Keyboard shortcuts

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