Documentation
¶
Overview ¶
Package config resolves the bsecret command's settings: flags, then BSECRET_* in the environment, then the config file, then the built-in default.
The overlay addresses have no default: the overlay hosts of the crypt and of the hall, the facade, where large ciphertexts are kept, and the host a priced question goes to. A default there would quietly send an organization's records, or a member's questions, to somebody else's server, so a command that needs one and finds none is a usage error.
The chain services do, on mainnet and testnet, so that a home needs no node of its own (Resolve): headers and the chain view from WhatsOnChain (woc:main, woc:test), checked against their proof of work and the headers, and GorillaPool's public arcade to broadcast (arcade:main, arcade:test). A regtest chain has no public services and no defaults.
Index ¶
Constants ¶
const ( ModePlane = "plane" ModeUnicast = "unicast" QuorumAll = "all" QuorumMajority = "majority" QuorumOne = "one" )
The modes and the named quorums.
const WalletEmbedded = "embedded"
WalletEmbedded is the wallet key's default: the home's own identity file.
Variables ¶
var ErrUnknownKey = errors.New("config: unknown key")
ErrUnknownKey reports a key the grammar does not define.
var Keys = []string{"arcade_key", "asset", "chain", "chain_tree_count", "content", "crypt", "delay", "facade", "fee_dust",
"fee_floor", "fee_max_rate", "fee_max_tx", "fee_min_rate", "fee_policy_urls", "fee_rate", "fee_source", "freshness",
"fund_unmined", "hall", "hall_hosts", "header_token", "header_url", "home", "hosts", "lookup_auth", "max_fetch", "mode", "network",
"object_bound", "org", "originator", "paid_host", "quorum", "rpc", "rpc_pass", "rpc_user", "settle", "timeout",
"tree_count", "vault", "wallet", "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 DefaultHome ¶
func DefaultHome() string
DefaultHome is ~/.bsecret, or .bsecret when there is no home directory.
func IsHex32 ¶
IsHex32 reports whether s is 64 lowercase hex digits: a vault or secret identifier, or a txid.
func IsKeyHex ¶
IsKeyHex reports whether s is an identity key that may own a vault or be a member: 66 lowercase hex digits whose bytes meet the key rule.
func Need ¶
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.
Types ¶
type Config ¶
type Config struct {
// ArcadeKey is the bearer token for an arcade installation in Settle.
ArcadeKey string
// Asset is the node's asset API base URL. It is the older spelling of
// Chain = asset:<URL>, and the node coinbase is mined through (regtest).
Asset string
// Chain is the chain view: where transactions, proofs and spends are
// read (nodeapi.ParseChain): woc:main, woc:test, asset:<URL>, or a
// list. Resolve defaults it to woc:<network> on main and test.
Chain string
// ChainTreeCount is how many outputs a new chain tree has.
ChainTreeCount int
// Content is where a ciphertext too large to be carried is kept: a
// directory (a writer stores into it, a reader reads from it) or an
// http(s) base URL a reader fetches <base>/<hash> from, comma
// separated when there are several. A file there is named by the
// lowercase hex of its SHA-256.
Content []string
// Crypt is the crypt identifier <name>_<suffix> a command uses when it
// names none.
Crypt string
// Delay is the propagation delay: how long after a mined object's block
// is in the publisher's headers it is published (spec section 8.3).
Delay time.Duration
// Facade is the overlay host a publisher submits to in mode plane.
Facade string
// Fee is the miner fee policy (feepolicy.Config), from the fee_* keys.
// Unset keys keep mint.DefaultFees.
Fee feepolicy.Config
// Freshness bounds how old a writer's evidence that the vault's and the
// group's latest tokens are unspent may be when it publishes a version
// (spec section 7.1). Every transition retakes the evidence as it is
// built, whatever this says.
Freshness time.Duration
// FundUnmined is whether fund -beef takes a payment not yet mined
// whose parents are proven: "accept" (the default) or "refuse".
FundUnmined string
// Hall is the borg hall a new vault's group lives in.
Hall string
// HallHosts are the overlay hosts asked about the group's hall; unset,
// Hosts are asked.
HallHosts []string
// HeaderToken is the bearer token a header source is sent (a
// block-headers-service requires one).
HeaderToken string
// HeaderURL is the header source every proof is checked against:
// woc:main, woc:test, bhs:URL, arcade:URL, chaintracks:URL or a
// bridge's /v1 base URL. Resolve defaults it to woc:<network> on main
// and test.
HeaderURL string
// Home is the identity's directory: key, coin pool and state.
Home string
// Hosts are the overlay hosts of the crypt a reader asks. In mode
// unicast they are every host a publisher submits to; in mode plane
// mined objects also go to each of them directly.
Hosts []string
// LookupAuth asks every ls_bsecret question over BRC-104 as this home's
// identity, at each host's base URL: what a private crypt's hosts
// require (spec section 10.4).
LookupAuth bool
// MaxFetch is the most ciphertext a reader fetches by hash, in bytes.
MaxFetch int
// Mode is how a publisher's objects reach the hosts: "plane" or
// "unicast".
Mode string
// Network is "main", "test" or "regtest".
Network string
// ObjectBound is the largest object the plane takes, in bytes.
ObjectBound int
// Org is the owner a reader's command reads when it names none: the
// organization's identity key, 66 lowercase hex digits.
Org string
// Originator is the BRC-100 originator presented to the wallet.
Originator string
// PaidHost is the base URL of ls_bsecret on the host a priced question
// is asked of: the host's terms route (spec section 10.3).
PaidHost string
// Quorum is, in mode unicast, how many of Hosts must take a carrier for
// it to count as published: "all", "majority", "one" or a number.
// Tokens and sweeps always need every host.
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 transactions are broadcast through
// (publish.ParseSettler): arcade:main, arcade:test, arcade:<url>,
// arc:<url>, rpc:<url> or tcp:<host:port>. Resolve defaults it to
// arcade:<network> on main and test.
Settle string
// Timeout bounds each request to a host, node or header source.
Timeout time.Duration
// TreeCount is how many outputs a new secret funding tree has.
TreeCount int
// Vault is the vault a command uses when it names none: its
// identifier, 64 lowercase hex digits, or its display name.
Vault string
// Wallet is where the home's identity key is held: "embedded" (the
// default, identity.json in the home) or wire:<URL>, a BRC-100 wallet
// reached over the wallet wire at a loopback URL.
Wallet string
// WoCKey is a WhatsOnChain API key, and WoCRate the requests a second
// its plan allows (zero is the free rate, 3).
WoCKey string
WoCRate float64
}
Config is the resolved settings.
func Load ¶
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) Apply ¶
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
AssetURL is the node's asset API base URL: asset, else the first asset:<URL> backend the chain view names, else "".
func (Config) CheckNetwork ¶ added in v0.4.0
CheckNetwork refuses a WhatsOnChain chain view or a public arcade named for another network than the configured one.
func (Config) GroupHosts ¶
GroupHosts are the hosts asked about the group's hall.
func (Config) Resolve ¶ added in v0.4.0
Resolve fills what a network has a default for and is not configured: on main and test, the chain view woc:<network>, the header source woc:<network> and the settlement leg arcade:<network>. The older key asset becomes the chain view asset:<URL>; asset and chain both set is refused, since which one is meant cannot be told. A regtest chain has no public services, so nothing is filled for it.