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 ¶
- Variables
- func ReadBEEF(path string, stdin io.Reader) ([]byte, error)
- type Funded
- type Line
- type Spec
- type Tip
- type View
- func (v *View) Fees(ctx context.Context) mint.Fees
- func (v *View) FundBEEF(ctx context.Context, s *bwallet.Signer, pool *bwallet.Pool, beef []byte, ...) (Funded, error)
- func (v *View) FundTxid(ctx context.Context, s *bwallet.Signer, pool *bwallet.Pool, txid string) (Funded, error)
- func (v *View) Report(ctx context.Context) []Line
Constants ¶
This section is empty.
Variables ¶
var ErrSpec = errors.New("chaincfg")
ErrSpec is a configuration that cannot be used.
var ErrUnmined = bwallet.ErrUnmined
ErrUnmined is a payment imported by txid that has no block yet.
Functions ¶
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 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) Fees ¶
Fees is the static fees the configuration names (a live policy's fallback), over mint.DefaultFees.
func (Spec) HeadersSpec ¶
HeadersSpec is the header source specification in force.
func (Spec) SettleSpec ¶
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 (*View) 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.