home

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 8 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 home is a sender's directory: its identity and coin pool (bcommon's bwallet), its settings, and the funding trees its carriers spend from.

Index

Constants

This section is empty.

Variables

View Source
var ErrLocked = errors.New("the home is in use by another beefcat command")

ErrLocked is a home another beefcat command is using.

Functions

func Lock

func Lock(dir string) (func(), error)

Lock takes the home's lock: one command that spends from its pool or writes its state at a time. The returned function releases it.

func SaveConfig

func SaveConfig(dir string, c Config) error

SaveConfig writes the home's settings.

Types

type Config

type Config struct {
	// Network is main, test or regtest.
	Network string `json:"network"`
	// Headers is the header source every proof is checked against.
	Headers string `json:"headers,omitempty"`
	// Chain is the chain view: transactions, proofs and spends.
	Chain string `json:"chain,omitempty"`
	// Settle is the settlement leg funding trees and sweeps are mined
	// through.
	Settle string `json:"settle,omitempty"`
	// RPC is a node's JSON-RPC, for coinbase on a regtest chain you run.
	RPC string `json:"rpc,omitempty"`
}

Config is what init writes and every command reads. A flag overrides a field for one run.

func LoadConfig

func LoadConfig(dir string) (Config, error)

LoadConfig reads the home's settings; a home without any is empty.

func (*Config) Defaults

func (c *Config) Defaults()

Defaults fills what a network implies.

type Pending

type Pending struct {
	Tree funding.Tree   `json:"tree"`
	Coin bwallet.Output `json:"coin"`
	// Asked counts the commands that found the tree unknown and its coin
	// unspent.
	Asked int `json:"asked,omitempty"`
}

Pending is a funding tree signed for a coin and not yet recorded as mined: what producer.Trees.Prepare was given.

type State

type State struct {
	Identity string         `json:"identity"`
	Trees    []funding.Tree `json:"trees,omitempty"`
	Pending  []Pending      `json:"pending,omitempty"`
	Sweeps   []Sweep        `json:"sweeps,omitempty"`
	// Sent counts the carriers and data bytes this home has sent.
	SentCarriers uint64 `json:"sentCarriers,omitempty"`
	SentBytes    uint64 `json:"sentBytes,omitempty"`
	// contains filtered or unexported fields
}

State is the home's record of its funding trees.

func LoadState

func LoadState(dir, identity string) (*State, error)

LoadState reads the home's state for identity (hex), or starts an empty one. The caller holds the lock.

func (*State) DropPending

func (s *State) DropPending(txid string)

DropPending forgets the pending record of txid.

func (*State) NextTree

func (s *State) NextTree() *funding.Tree

NextTree is the first mined tree with an output left, or nil.

func (*State) NextTreeFrom added in v0.2.0

func (s *State) NextTreeFrom(height uint32) *funding.Tree

NextTreeFrom is the first tree mined at height or above with an output left, or nil.

func (*State) Remaining

func (s *State) Remaining() uint64

Remaining is how many carriers the mined trees can still fund.

func (*State) RemainingFrom added in v0.2.0

func (s *State) RemainingFrom(height uint32) uint64

RemainingFrom is how many carriers the trees mined at height or above can still fund.

func (*State) Save

func (s *State) Save() error

Save writes the state, atomically.

func (*State) Tree

func (s *State) Tree(txid string) *funding.Tree

Tree is the recorded tree txid, or nil.

type Sweep

type Sweep struct {
	Tree   string `json:"tree"`
	Txid   string `json:"txid"`
	RawHex string `json:"rawHex"`
	// Height is set once the sweep mined.
	Height uint32 `json:"height,omitempty"`
}

Sweep is a sweep of one tree's outputs.

Jump to

Keyboard shortcuts

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