config

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 11 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 bfinger's settings: flags, then BFINGER_* in the environment, then the config file, then the built-in default.

The overlay addresses have NO default: the host (the domain's manifest names it) and the facade. The header source, the chain view and the settlement leg default, on mainnet and testnet, to the public services that need no node (WhatsOnChain headers checked for their proof of work, WhatsOnChain's chain view, GorillaPool's arcade); regtest has no default header source, so a missing value there is a usage error. A node is an option for all three.

Index

Constants

This section is empty.

Variables

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

ErrUnknownKey reports a key the grammar does not define.

View Source
var Keys = []string{"home", "host", "header_url", "network", "facade", "settle", "rpc", "rpc_user", "rpc_pass", "asset", "topic", "known_keys", "timeout", "quorum", "originator", "wallet", "wallet_url", "funding", "proofs", "arcade_key",
	"chain", "woc_key", "fund_unmined", "fee_rate", "fee_source", "fee_floor", "fee_dust", "fee_min_rate", "fee_max_rate", "fee_max_tx", "fee_policy_urls", "messagebox"}

Keys is the file grammar's key list, with the field each sets. 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 DefaultHeaderURL added in v0.7.0

func DefaultHeaderURL(network string) string

DefaultHeaderURL is the header source used when none is set: the public WhatsOnChain service for main and test, and none for regtest (a private chain has no public header service).

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.

func Path

func Path(flagPath string) string

Path is the config file location: -config, else $BFINGER_HOME/config, else $XDG_CONFIG_HOME/bfinger/config, else ~/.bfinger/config.

Types

type Config

type Config struct {
	// Home is the state directory: known_keys, identity, pool, journal, state.
	Home string
	// Host is the overlay host base URL for lookups. Empty means resolve it
	// from the domain's manifest (BRC-180).
	Host string
	// HeaderURL is the header source: woc:main, woc:test, chaintracks:URL, or
	// a bridge's header read API base. Empty resolves to WhatsOnChain on the
	// network (woc:main, woc:test; see DefaultHeaderURL); regtest has none.
	HeaderURL string
	// Network is the chain: "main" (the default), "test" or "regtest" (any
	// private chain). It sets the proof-of-work floor a header must meet.
	Network string
	// Facade is the bridge facade base URL for publishing objects.
	Facade string
	// MessageBox is the BRC-33 message box server private store deliveries
	// are sent through and taken from. Empty: deliveries are files.
	MessageBox string
	// Settle is the settlement leg, as publish.ParseSettler reads it:
	// "arcade:main", "arcade:test" or "arcade:<url>" for an arcade
	// installation, "arc:<url>" for an ARC one, "rpc:<url>" for a node with
	// an acknowledgement, or "tcp:<host:port>" for the bare-EF ingress.
	// Empty is the network's public arcade (publish.DefaultSettle).
	Settle string
	// ArcadeKey is the bearer token for an arcade installation that wants
	// one. Only sent to the arcade URL in Settle.
	ArcadeKey string
	// Proofs is "wait" (a transition returns once its state token is mined
	// and proven) or "async" (it returns once the network has accepted the
	// token, and the proof is collected by a later command). Async needs a
	// settlement leg that answers, which the bare-EF ingress does not.
	Proofs string
	// Chain is the chain view transactions, proofs and spends are read
	// from, as nodeapi.ParseChain reads it: "woc:main", "woc:test",
	// "asset:<url>" (a node), or a comma-separated list. Empty is Asset's
	// node when one is configured, else WhatsOnChain on this network.
	Chain string
	// WoCKey is a WhatsOnChain API key, for a rate above the free one.
	WoCKey string
	// RPC and Asset are a node's endpoints: coinbase funding (regtest) and,
	// for Asset, the chain view when Chain is unset ("asset:<Asset>").
	RPC   string
	Asset string
	// RPCUser and RPCPass are the node's basic-auth credentials.
	RPCUser string
	RPCPass string
	// Topic is the topic both objects are published to.
	Topic string
	// KnownKeys is the pin store path.
	KnownKeys string
	Timeout   time.Duration
	// Quorum is how many hosts must answer identically; 1 asks one host.
	Quorum int
	// Originator is the BRC-100 originator string presented to the wallet.
	Originator string
	// Wallet is "embedded" (bfinger's own key and coin) or "wire" (a BRC-100
	// wallet reached over the wallet wire at WalletURL).
	Wallet string
	// WalletURL is the wire wallet's base URL. Loopback only.
	WalletURL string
	// Funding is "home" (fees come from the coin in this home, and bfinger
	// settles) or "wallet" (the wire wallet funds, signs and broadcasts
	// every mined transaction through its action flow).
	Funding string
	// FundUnmined is "accept" (fund -beef takes a payment not mined yet
	// whose parents are proven, held until its proof arrives) or "refuse".
	FundUnmined string
	// Fee is the miner fee configuration, over mint.DefaultFees.
	Fee feepolicy.Config
}

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 (missing is fine) and the environment over the defaults. Flags are applied by the caller afterwards, because only the caller knows which flags were actually set.

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 agree on parsing.

func (Config) Resolve added in v0.7.0

func (c Config) Resolve() Config

Resolve fills the settings whose default depends on others: an unset header_url becomes DefaultHeaderURL(Network). Call it once, after the file, environment and flags are applied, so an explicit header_url wins.

Jump to

Keyboard shortcuts

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