Documentation
¶
Index ¶
- Constants
- Variables
- func AllDirConfigs() map[string]BinaryDirConfig
- func ChainParamsFor(n Network) *chaincfg.Params
- func CoreSectionForNetwork(n Network) string
- func CusfNetworkName(n Network, ecashID string) string
- func DefaultDBCacheMiB() int
- func DeleteFilesWithRetry(paths []string, log zerolog.Logger)
- func DrivechainIndexURLForNetwork(n Network) string
- func ECashEndpoints() netcatalog.Network
- func ECashExplorerHost() string
- func ECashIDFromUAComment(uacomment string) string
- func ECashNetworkID() string
- func ECashPeerFor(id string) string
- func ECashUAComment(id string) string
- func ElectrumHostPortForNetwork(n Network) (string, uint16)
- func ElectrumReachable(ctx context.Context, host string, port uint16) bool
- func ElectrumWalletSupportedForNetwork(n Network) bool
- func EnforcerNetworkName(n Network) string
- func EnforcerNetworksCollide(a, b Network) bool
- func EnforcerValidatorDir(n Network) string
- func EnforcerWalletDir(n Network) string
- func EsploraArgURL(args []string) (string, bool)
- func EsploraReachable(ctx context.Context, baseURL string) bool
- func EsploraURLForNetwork(n Network) string
- func EsploraURLsForNetwork(n Network) []string
- func FeeExplorerURLForNetwork(n Network) string
- func GetExistingFilesInDir(dir string, files []string, log zerolog.Logger) []string
- func GetMatchingFilesInDir(dir string, re *regexp.Regexp, log zerolog.Logger) []string
- func GroupDatadirForPick(g DatadirGroup, picked string) string
- func HomeDir() string
- func IsECashUAComment(uacomment string) bool
- func IsEcashFork(n Network) bool
- func MainchainReaderArgs(cookiePath string, keepDefault bool) ([]string, error)
- func MainchainReaderCookie(dir string) (string, error)
- func NetworkDisplayName(n Network) string
- func PublicExplorerNetwork(n Network) bool
- func PublishedDisplayName(network Network) string
- func PublishedECashPeer(id string) string
- func PublishedEndpoints(network Network) netcatalog.Network
- func PublishedForkHeight(network Network) int
- func RPCPortForNetwork(n Network) int
- func ReadCookieFile(path string) (user, password string, err error)
- func RemoteEnforcerNetworks() []string
- func RemoteEnforcerURLForNetwork(network Network) string
- func RunEnforcerConfMigrations(config *EnforcerConfig) bool
- func SetECashEndpoints(n netcatalog.Network)
- func SetECashNetworkID(id string)
- func SetECashPeer(id, address string)
- func SetForkHeight(network Network, height int)
- func SetHomeDir(dir string)
- func SetNetworkDisplayName(network Network, name string)
- func SetNetworkEndpoints(network Network, n netcatalog.Network)
- func SidechainEsploraURLForNetwork(chain string, n Network) string
- func SplitCheckEsploraURLs() []string
- func SupportsLightMode(n Network) bool
- func ThunderEsploraURLForNetwork(n Network) string
- func UserHomeDir() string
- func WalletChainSourceURLsForNetwork(n Network) []string
- func WipeChainData(network Network, bitcoinDatadirOverride string, log zerolog.Logger)
- func WipeChainDataSync(network Network, bitcoinDatadirOverride string, log zerolog.Logger)
- func WipeEnforcerChainDataSync(network Network, log zerolog.Logger) error
- func WithElectrumFallback(args []string, host string, port uint16) []string
- type BinaryDirConfig
- func (b BinaryDirConfig) AppDir() string
- func (b BinaryDirConfig) BinaryVersion(appDir string) (string, error)
- func (b BinaryDirConfig) CalculateHash(appDir string) (string, error)
- func (b BinaryDirConfig) CheckReleaseDate(downloadURL string, downloadSource int, fileName string) (*time.Time, error)
- func (b BinaryDirConfig) ConnectionString() string
- func (b BinaryDirConfig) DatadirNetwork(network Network, bitcoinOverride string) string
- func (b BinaryDirConfig) DeleteBinaries(assetsDir string, log zerolog.Logger)
- func (b BinaryDirConfig) ExtraFilesForDeletion(assetsDir string) []string
- func (b BinaryDirConfig) FlutterFrontendPath() string
- func (b BinaryDirConfig) FrontendDir() string
- func (b BinaryDirConfig) GetAllDatadirPaths(networkDir string) []string
- func (b BinaryDirConfig) GetBinaryPaths(assetsDir string, log zerolog.Logger) []string
- func (b BinaryDirConfig) GetBlockchainDataPaths(networkDir string, network Network, log zerolog.Logger) []string
- func (b BinaryDirConfig) GetLogPaths(networkDir string, log zerolog.Logger) []string
- func (b BinaryDirConfig) GetSettingsPaths(networkDir string, network Network, log zerolog.Logger) []string
- func (b BinaryDirConfig) GetWalletPaths(networkDir string, network Network, log zerolog.Logger) []string
- func (b BinaryDirConfig) LogPath(networkDir string) string
- func (b BinaryDirConfig) ResolveBinaryPath(appDir string) (string, error)
- func (b BinaryDirConfig) RootDir() string
- func (b BinaryDirConfig) RootDirNetwork(network Network) string
- type BitcoinConfManager
- func (m *BitcoinConfManager) CommitNetworkChange(newNetwork Network) error
- func (m *BitcoinConfManager) CopyConfigDownstream() error
- func (m *BitcoinConfManager) CreateDataDir() error
- func (m *BitcoinConfManager) DataDir() string
- func (m *BitcoinConfManager) ECashPeer() string
- func (m *BitcoinConfManager) GetConfFilePath() string
- func (m *BitcoinConfManager) GetCurrentConfigContent() string
- func (m *BitcoinConfManager) GetDefaultConfig() string
- func (m *BitcoinConfManager) GetExplicitRPCCredentials() (string, string)
- func (m *BitcoinConfManager) GetRPCCookiePath() string
- func (m *BitcoinConfManager) GetRPCCredentials() (string, string, error)
- func (m *BitcoinConfManager) GetRPCHost() string
- func (m *BitcoinConfManager) GetRPCPort() int
- func (m *BitcoinConfManager) HasDatadirForNetwork(n Network) bool
- func (m *BitcoinConfManager) LoadConfig(isFirst bool) error
- func (m *BitcoinConfManager) RefreshMainSectionDefaults() error
- func (m *BitcoinConfManager) ResolvedECashID() string
- func (m *BitcoinConfManager) RootDataDir() string
- func (m *BitcoinConfManager) SaveConfig() error
- func (m *BitcoinConfManager) StartWatching() error
- func (m *BitcoinConfManager) StopWatching()
- func (m *BitcoinConfManager) SwapNetwork(newNetwork Network) error
- func (m *BitcoinConfManager) UpdateDataDir(dataDir string, forNetwork Network) error
- func (m *BitcoinConfManager) UpdateNetwork(n Network) error
- func (m *BitcoinConfManager) WriteConfig(content string) error
- type BitcoinConfMigration
- type BitcoinConfig
- func (c *BitcoinConfig) GetEffectiveSetting(key, network string) string
- func (c *BitcoinConfig) GetGroupDatadir(g DatadirGroup) string
- func (c *BitcoinConfig) GetSetting(key string, section ...string) string
- func (c *BitcoinConfig) HasSetting(key string, section ...string) bool
- func (c *BitcoinConfig) RemoveSetting(key string, section ...string)
- func (c *BitcoinConfig) Serialize() string
- func (c *BitcoinConfig) SetGroupDatadir(g DatadirGroup, path string)
- func (c *BitcoinConfig) SetSetting(key, value string, section ...string)
- type DatadirGroup
- type DownloadProgress
- type EnforcerConfManager
- func (m *EnforcerConfManager) GetCliArgs() []string
- func (m *EnforcerConfManager) GetCurrentConfigContent() string
- func (m *EnforcerConfManager) GetDefaultConfig() string
- func (m *EnforcerConfManager) GetExpectedNodeRpcSettings() map[string]string
- func (m *EnforcerConfManager) LoadConfig() error
- func (m *EnforcerConfManager) RetargetECashNetwork(previousID, id string) (bool, error)
- func (m *EnforcerConfManager) RetargetECashNetworkFor(target Network, previousID, id string) (bool, error)
- func (m *EnforcerConfManager) SaveConfig() error
- func (m *EnforcerConfManager) StartWatching() error
- func (m *EnforcerConfManager) StopWatching()
- func (m *EnforcerConfManager) WriteConfig(content string) error
- type EnforcerConfMigration
- type EnforcerConfig
- type GenericAppConfig
- type GitHubCache
- type Network
- func AllNetworks() []Network
- func LightModeNetworks() []Network
- func LookupNetwork(s string) (Network, bool)
- func NetworkForCatalogEntry(id, family string) (Network, bool)
- func NetworkFromConfig(conf *BitcoinConfig, fallback Network) Network
- func NetworkFromString(s string) Network
- func ResolveNetwork(bitwindowDir string) (Network, string, error)
- func RunBitcoinConfMigrations(config *BitcoinConfig) (bool, []Network)
- type ProcessLogEntry
- type ShutdownProgressInfo
- type SidechainConfManager
- func (m *SidechainConfManager) GetCliArgs() []string
- func (m *SidechainConfManager) GetDefaultConfig() string
- func (m *SidechainConfManager) GetNetwork() string
- func (m *SidechainConfManager) LoadConfig() error
- func (m *SidechainConfManager) StartWatching() error
- func (m *SidechainConfManager) StopWatching()
- func (m *SidechainConfManager) SyncNetworkFromBitcoinConf() error
- func (m *SidechainConfManager) WriteConfig(content string) error
- type SidechainConfSpec
Constants ¶
const CliNetworkFlag = "--network"
CliNetworkFlag is the flag a CUSF sidechain daemon reads for its network. The launch path stops a daemon that gets no such flag, because the daemon then picks its own default network.
const MainchainReaderUser = "sidechain-reader"
MainchainReaderUser is the Core RPC user a sidechain reads the mainchain as.
Variables ¶
var ( BitcoinCoreDirs = MustDirConfig("bitcoincore") BitWindowDirs = MustDirConfig("bitwindow") EnforcerDirs = MustDirConfig("enforcer") ThunderDirs = MustDirConfig("thunder") BitNamesDirs = MustDirConfig("bitnames") BitAssetsDirs = MustDirConfig("bitassets") ZSideDirs = MustDirConfig("zside") TruthcoinDirs = MustDirConfig("truthcoin") PhotonDirs = MustDirConfig("photon") CoinShiftDirs = MustDirConfig("coinshift") BbcDirs = MustDirConfig("bbc") FreebankDirs = MustDirConfig("freebank") )
Package-level accessors that read from JSON. These replace the old hardcoded vars.
var BitcoinConfMigrationsVersion = 13
BitcoinConfMigrationsVersion is the highest migration version.
var DefaultNetwork = string(NetworkECash)
DefaultNetwork is the network an install runs with no saved config and no --network/ORCHESTRATOR_NETWORK override. Every binary reads this one value, so the daemon and the control CLI cannot target different networks. Variant builds override it at link time:
go build -ldflags "-X.DefaultNetwork=signet"
var KnownSidechainSpecs = map[string]SidechainConfSpec{ "thunder": { Name: "Thunder", ConfigFilename: "thunder.conf", BasePort: 6009, CliArgKeys: []string{"net-addr", "mainchain-grpc-url"}, EnforcerArg: "mainchain-grpc-url", PortStyle: "grpc", RPCKey: "rpc-addr", DirKey: "thunder", }, "bitassets": { EnforcerArg: "mainchain-grpc-host", Name: "BitAssets", ConfigFilename: "bitassets.conf", BasePort: 6004, CliArgKeys: []string{"net-addr", "zmq-addr"}, PortStyle: "zmq", RPCKey: "rpc-port", DirKey: "bitassets", }, "bitnames": { EnforcerArg: "mainchain-grpc-host", Name: "BitNames", ConfigFilename: "bitnames.conf", BasePort: 6002, CliArgKeys: []string{"net-addr", "zmq-addr"}, PortStyle: "zmq", RPCKey: "rpc-addr", DirKey: "bitnames", }, "zside": { EnforcerArg: "mainchain-grpc-url", Name: "ZSide", ConfigFilename: "zside.conf", BasePort: 6098, PortStyle: "grpc", RPCKey: "rpc-addr", DirKey: "zside", }, "photon": { EnforcerArg: "mainchain-grpc-url", Name: "Photon", ConfigFilename: "photon.conf", BasePort: 6099, CliArgKeys: []string{"net-addr", "mainchain-grpc-url"}, PortStyle: "grpc", RPCKey: "rpc-addr", DirKey: "photon", }, "truthcoin": { EnforcerArg: "mainchain-grpc-url", Name: "Truthcoin", ConfigFilename: "truthcoin.conf", BasePort: 6013, CliArgKeys: []string{"net-addr", "mainchain-grpc-url"}, PortStyle: "grpc", RPCKey: "rpc-addr", DirKey: "truthcoin", LegacyRootDirName: "truthcoin", }, "coinshift": { EnforcerArg: "mainchain-grpc-url", Name: "CoinShift", ConfigFilename: "coinshift.conf", BasePort: 6255, CliArgKeys: []string{"net-addr", "mainchain-grpc-url"}, PortStyle: "grpc", RPCKey: "rpc-addr", DirKey: "coinshift", }, "liquid-signet": { Name: "Elements Alpha", ConfigFilename: "liquid-signet.conf", BasePort: 29443, PortStyle: "grpc", RPCKey: "rpc-addr", DirKey: "liquid-signet", }, }
KnownSidechainSpecs defines the configuration specs for all known sidechains.
var MainchainReaderRPCs = []string{
"getbestblockhash",
"getblock",
"getblockchaininfo",
"getblockcount",
"getblockhash",
"getblockheader",
"getnetworkinfo",
"getrawtransaction",
"gettxout",
"gettxoutproof",
}
MainchainReaderRPCs are the only Core RPCs the reader user may call.
var SidechainChainDataNames = []string{"data.mdb", "lock.mdb", "logs"}
SidechainChainDataNames are the entries a sidechain keeps its chain in. The datadir is flat across every network, so a swap has to move them.
var SidechainConfMigrationsVersion = len(sidechainConfMigrations)
SidechainConfMigrationsVersion is the version a config carries after every migration runs. A new config file starts there and skips them all.
Functions ¶
func AllDirConfigs ¶
func AllDirConfigs() map[string]BinaryDirConfig
AllDirConfigs returns all BinaryDirConfig entries loaded from JSON.
func ChainParamsFor ¶
ChainParamsFor gives the address encoding and coin type a network takes. Every Network value has params; a value outside the set is a programming error, and a guess here is a wrong address.
func CoreSectionForNetwork ¶
CoreSectionForNetwork returns the Bitcoin Core config section name for a network. Mainnet and eCash both use "main" since eCash runs on mainnet params.
func CusfNetworkName ¶
CusfNetworkName gives the network name a CUSF sidechain daemon accepts for the mainchain network n, on the eCash generation ecashID. It returns "" when the daemon has no such network, and the launch path then stops the daemon.
eCash carries a generation the daemon does not model: alphanet and betanet have a name in the daemon's own enum, and the rest do not. Each generation runs a build with its own magic, so a name from another generation stops it from syncing.
func DefaultDBCacheMiB ¶
func DefaultDBCacheMiB() int
DefaultDBCacheMiB is the -dbcache value for bitcoin.conf: a quarter of host memory, clamped to [450, 16384].
func DeleteFilesWithRetry ¶
DeleteFilesWithRetry deletes files/directories with retry logic (5 attempts, 1 second delay). Dart: deleteFiles (L276-311) + _deleteFilesInDir (L234-273)
func DrivechainIndexURLForNetwork ¶
DrivechainIndexURLForNetwork names the index that reads the sidechain escrow for a network.
The escrow belongs to the mainchain, not to any one sidechain, so it does not sit under a chain path. A network with no index answers empty, and a light install there reads no sidechains.
func ECashEndpoints ¶
func ECashEndpoints() netcatalog.Network
ECashEndpoints returns the live eCash network's published endpoints, falling back to the copy compiled into the binary so the URLs resolve before the catalog has been read.
func ECashExplorerHost ¶
func ECashExplorerHost() string
ECashExplorerHost is the host BitWindow links block, transaction and address pages at for the live eCash network, empty when it publishes no explorer.
func ECashIDFromUAComment ¶
ECashIDFromUAComment returns the eCash network id a uacomment names, empty when it names none.
func ECashNetworkID ¶
func ECashNetworkID() string
ECashNetworkID returns the live eCash network, falling back to the id compiled into the binary so the URLs resolve before the catalog has been read.
func ECashPeerFor ¶
ECashPeerFor is the seed node for a given eCash network, empty when neither the live catalog nor the embedded one publishes an address for it. Every eCash network seeds on its own port, so a built-up name would be a guess.
func ECashUAComment ¶
ECashUAComment returns the uacomment a generated eCash bitcoin.conf carries.
func ElectrumHostPortForNetwork ¶
ElectrumHostPortForNetwork returns a network's electrum server, or an empty host when none exists. The ssl:// prefix selects TLS in the enforcer client.
func ElectrumReachable ¶
ElectrumReachable reports whether an electrum server answers a version handshake. A TLS terminator in front of a dead electrs accepts the connection and then serves nothing, so a dial alone proves nothing.
func ElectrumWalletSupportedForNetwork ¶
ElectrumWalletSupportedForNetwork reports whether a network can run electrum wallets. The wallet signs and broadcasts over Esplora, so an Esplora backend is all it needs. Drivechain reads (sidechains, BIP300) come from a local enforcer, and a network with no local stack answers none of them.
func EnforcerNetworkName ¶
EnforcerNetworkName is the directory name the enforcer files a network's
state under, in
func EnforcerNetworksCollide ¶
EnforcerNetworksCollide reports whether two networks share the enforcer's on-disk directories, which is the only case where swapping between them leaves one network's chain sitting where the other will look for its own.
func EnforcerValidatorDir ¶
EnforcerValidatorDir is the enforcer's validator database directory for network.
func EnforcerWalletDir ¶
EnforcerWalletDir is the enforcer's BDK wallet directory for network.
func EsploraArgURL ¶
EsploraArgURL returns the URL of the --wallet-esplora-url argument.
func EsploraReachable ¶
EsploraReachable reports whether an esplora server answers its tip query.
func EsploraURLForNetwork ¶
EsploraURLForNetwork returns a network's primary esplora API URL (or "" when none exists), for callers that take a single endpoint such as the enforcer's wallet-sync-source.
func EsploraURLsForNetwork ¶
EsploraURLsForNetwork returns the esplora API URLs for a network, primary first. The wallet rotates to the next on a rate-limit/outage, so a network can list multiple providers for resilience. Regtest returns nil — no public esplora exists for it and we don't ship a local one, so the enforcer falls back to wallet-sync-source=disabled (see GetCliArgs in enforcer_conf.go).
func FeeExplorerURLForNetwork ¶
FeeExplorerURLForNetwork names a mempool.space style explorer that reports what the next blocks pay, or an empty string when a network hosts none.
Core's own estimator reads the mempool it holds, and a chain whose mempool carries transactions no miner takes pushes that estimate far over what the blocks really pay. The explorer reads the blocks, so it answers the market.
func GetExistingFilesInDir ¶
func GetMatchingFilesInDir ¶
GetMatchingFilesInDir returns entries of dir whose name matches re. A missing or unreadable dir yields nothing — callers are enumerating paths to delete, so there is nothing to do either way.
func GroupDatadirForPick ¶
func GroupDatadirForPick(g DatadirGroup, picked string) string
GroupDatadirForPick returns the datadir a group should use for a directory the user just chose. Non-default groups run on chain=main and would share mainnet's datadir root. Apply once, at the pick — slots on disk are already resolved and re-applying would redirect a live datadir.
func HomeDir ¶
func HomeDir() string
HomeDir returns the directory every binary path resolves against.
func IsECashUAComment ¶
IsECashUAComment reports whether a uacomment marks an eCash install. A bare
"drynet
func IsEcashFork ¶
IsEcashFork reports whether the network is a fork of BTC mainnet, so its pre-fork outpoints also exist on BTC.
func MainchainReaderArgs ¶
MainchainReaderArgs returns the Core arguments that add the reader user. keepDefault leaves the whitelist default to the user's own conf.
func MainchainReaderCookie ¶
MainchainReaderCookie returns the reader's credential file in dir, in Core cookie format. It writes the file with a new password when absent.
func NetworkDisplayName ¶
NetworkDisplayName is the name the user reads for a network. The catalog names the live eCash network, and the rest carry the name of the network.
func PublicExplorerNetwork ¶
PublicExplorerNetwork reports whether drivechain.info hosts a chain-tip explorer for a network. eCash lives on drivechain.dev under a per-generation host and publishes no tip endpoint, so a poll there dials a name that never existed.
func PublishedDisplayName ¶
PublishedDisplayName returns a network's catalog name, empty when unset.
func PublishedECashPeer ¶
PublishedECashPeer returns the catalog's seed address for an eCash network, empty when the catalog carried none.
func PublishedEndpoints ¶
func PublishedEndpoints(network Network) netcatalog.Network
PublishedEndpoints returns the entry the catalog publishes for a network, zero when it lists none. eCash keys off its resolved entry, because its id is free-form and names no network slot.
func PublishedForkHeight ¶
PublishedForkHeight returns a network's catalog fork height, 0 when the catalog carried none.
func RPCPortForNetwork ¶
RPCPortForNetwork returns the default RPC port for a given network.
func ReadCookieFile ¶
ReadCookieFile reads the "user:password" auth cookie a Bitcoin Core node writes into its datadir on every start.
func RemoteEnforcerNetworks ¶
func RemoteEnforcerNetworks() []string
RemoteEnforcerNetworks names every network that publishes a validator URL, by the name the user reads. Light mode serves sidechains on these networks only.
func RemoteEnforcerURLForNetwork ¶
RemoteEnforcerURLForNetwork returns the published validator URL, or an empty string.
func RunEnforcerConfMigrations ¶
func RunEnforcerConfMigrations(config *EnforcerConfig) bool
RunEnforcerConfMigrations applies pending migrations to an EnforcerConfig. Returns true if any migration was applied.
func SetECashEndpoints ¶
func SetECashEndpoints(n netcatalog.Network)
SetECashEndpoints records the endpoints the catalog publishes for the live eCash network. Called once the network catalog is loaded, before anything dials.
func SetECashNetworkID ¶
func SetECashNetworkID(id string)
SetECashNetworkID records the resolved eCash network. Called once the network catalog is loaded, before anything dials.
func SetECashPeer ¶
func SetECashPeer(id, address string)
SetECashPeer records the seed address published for a eCash network.
func SetForkHeight ¶
SetForkHeight records a network's published fork height. Called once the catalog is loaded, before anything counts down to it.
func SetHomeDir ¶
func SetHomeDir(dir string)
SetHomeDir points every binary path at dir instead of the user's home directory. An empty dir restores the user's home.
A process confined to one install must resolve every other binary's data directory inside that install. Without this a daemon told to use a temp directory still reaches the real home, and a wipe there moves the user's own wallet aside.
func SetNetworkDisplayName ¶
SetNetworkDisplayName records a network's published name ("ECash 4"), so the UI names the fork that is actually coming.
func SetNetworkEndpoints ¶
func SetNetworkEndpoints(network Network, n netcatalog.Network)
SetNetworkEndpoints records the entry the catalog publishes for a network. Called once the network catalog is adopted, before anything dials. The compiled-in copy is adopted at startup, so no read falls in a gap.
func SidechainEsploraURLForNetwork ¶
SidechainEsploraURLForNetwork returns the address index hosted for one sidechain on a network, or an empty string when none is hosted.
func SplitCheckEsploraURLs ¶
func SplitCheckEsploraURLs() []string
SplitCheckEsploraURLs returns the BTC-mainnet esplora servers the split engine reads, primary first.
func SupportsLightMode ¶
SupportsLightMode reports whether a network can run without a local node. Light mode reads the chain from Esplora, so a network with no Esplora server — regtest and testnet — runs in full mode only.
func ThunderEsploraURLForNetwork ¶
ThunderEsploraURLForNetwork returns the thunder address index for a network.
func UserHomeDir ¶
func UserHomeDir() string
UserHomeDir returns the user's home directory. A test binary gets a temp directory in place of the home the process started with.
func WalletChainSourceURLsForNetwork ¶
WalletChainSourceURLsForNetwork returns the endpoints the electrum wallet reads chain data from, best first. The catalog decides which networks read an Electrum-protocol server: where it publishes one, the whole published list applies, so the Fulcrum server serves the wallet and the Esplora stays as the fallback. The rest keep the built-in endpoints. Mainnet's built-in one is the drivechain Electrum server (ssl://), because its public HTTP is a mempool.space API that lacks the /address/:a/utxo and /fee-estimates endpoints the wallet needs. The scheme (ssl/tcp vs https) selects the client. This is deliberately separate from EsploraURLForNetwork, which feeds the enforcer's BDK sync and must stay an HTTP Esplora URL.
func WipeChainData ¶
WipeChainData deletes on-disk chain state for network across all known binaries. Wallet files are preserved. bitcoinDatadirOverride is the user's datadir= setting for bitcoind, empty for the platform default.
The whole operation runs in the background and returns immediately. It must never block the caller: the chain datadir can be large, slow, or on an unresponsive volume (e.g. an external disk that's asleep or unplugged), and even a readdir or rename against a stalled mount hangs indefinitely. This runs inside orchestrator startup, before the RPC listener binds, so a stall here surfaced to the frontend as "backend not ready". Doomed paths are renamed aside first — atomic and O(1) on the same filesystem — so a freshly started bitcoind never sees half-deleted data, then deleted; leftover ".wiping" siblings from an interrupted prior wipe are swept into the delete.
func WipeChainDataSync ¶
WipeChainDataSync renames the doomed paths aside before returning, then deletes them in the background. The rename is what actually makes the old chain state unreachable, so callers that record "this data is gone" — the eCash network rollover persisting a new catalog, say — must use this: with the fully-backgrounded variant the process can exit before the rename lands, and the next boot then trusts a record of a wipe that never happened.
Only safe off the startup critical path. The rename is O(1) on the same filesystem but can still stall on an unresponsive volume, which is why startup keeps WipeChainData.
func WipeEnforcerChainDataSync ¶
WipeEnforcerChainDataSync wipes the enforcer's validator and block state for network, leaving its wallet. The enforcer keeps one chain per network, not per generation, so a eCash network rollover — which stays on eCash and so fires no network swap — must clear it here or the new generation inherits the old one's validator chain. Renames aside synchronously like WipeChainDataSync so a caller recording the wipe can trust it happened. It reports whether every path left the live layout, for the same reason WipeNetworkScopedChainDataSync does: a caller that records the wipe as done would start the enforcer on the retired generation's validator chain.
Types ¶
type BinaryDirConfig ¶
type BinaryDirConfig struct {
Name string
BinaryName string
ChainLayer int
Port int
DataDir map[string]string // os -> subdir (default for all networks)
DataDirMainnet map[string]string // os -> subdir (mainnet override)
IsBitcoinCore bool // built on Bitcoin Core: Core datadir layout and Linux appdir
FlutterFrontendDir map[string]string // os -> Flutter app data subdir
}
BinaryDirConfig holds directory configuration for a single binary. Extracted from orchestrator.BinaryConfig for use in the config package.
func DirConfigByName ¶
func DirConfigByName(name string) (BinaryDirConfig, bool)
DirConfigByName returns the BinaryDirConfig for a given binary name. Matches against the JSON key, display Name, or BinaryName (case-insensitive). The JSON-key match is what lets runtime config names like "enforcer" resolve to the dir config keyed under "enforcer" despite its BinaryName being "bip300301-enforcer".
func MustDirConfig ¶
func MustDirConfig(jsonKey string) BinaryDirConfig
MustDirConfig returns the BinaryDirConfig for a JSON key, panicking if not found.
func (BinaryDirConfig) AppDir ¶
func (b BinaryDirConfig) AppDir() string
AppDir returns the platform base directory for this binary. Dart: Binary.appdir() (L1495-1514)
func (BinaryDirConfig) BinaryVersion ¶
func (b BinaryDirConfig) BinaryVersion(appDir string) (string, error)
BinaryVersion runs the binary with --version and returns the output. Dart: binaryVersion (L1615-1677)
func (BinaryDirConfig) CalculateHash ¶
func (b BinaryDirConfig) CalculateHash(appDir string) (string, error)
CalculateHash computes the SHA256 hash of the binary file. Dart: calculateHash (L1726-1736)
func (BinaryDirConfig) CheckReleaseDate ¶
func (b BinaryDirConfig) CheckReleaseDate(downloadURL string, downloadSource int, fileName string) (*time.Time, error)
CheckReleaseDate checks the release date for a binary without downloading. Dart: _checkReleaseDate (L680-691)
func (BinaryDirConfig) ConnectionString ¶
func (b BinaryDirConfig) ConnectionString() string
ConnectionString returns a display string for this binary's connection. Dart: connectionString (L778-793)
func (BinaryDirConfig) DatadirNetwork ¶
func (b BinaryDirConfig) DatadirNetwork(network Network, bitcoinOverride string) string
DatadirNetwork returns the network-aware datadir used for most file lookups. For bitcoind, if bitcoinOverride is non-empty it is used as the base (from the user's `datadir=` setting in bitwindow-bitcoin.conf); otherwise we fall back to the platform default. bitcoind and bitwindowd add a per-network subdir (e.g. "signet/"); other binaries keep the flat root dir. Dart: Binary.datadir() + Binary.datadirNetwork() (L1537-1591)
func (BinaryDirConfig) DeleteBinaries ¶
func (b BinaryDirConfig) DeleteBinaries(assetsDir string, log zerolog.Logger)
DeleteBinaries deletes binary files and extra files from the assets directory. Dart: deleteBinaries (L169-232)
func (BinaryDirConfig) ExtraFilesForDeletion ¶
func (b BinaryDirConfig) ExtraFilesForDeletion(assetsDir string) []string
ExtraFilesForDeletion returns per-binary extra files to delete from assets dir.
The list has two parts:
- A static set of non-CLI extras (bitcoind's qt/util, bitwindowd's DLLs, etc.)
plus CLI names that don't match the "
-cli" pattern (bitnames/bitassets). - A runtime scan for "
-cli" and " -cli.exe" in assetsDir, so sidechains whose CLI is bundled in the archive (thunder, truthcoin, ...) get picked up when present and silently skipped when the archive only ships a raw main binary.
Dart equivalent: deleteBinaries switch statement (L178-231)
func (BinaryDirConfig) FlutterFrontendPath ¶
func (b BinaryDirConfig) FlutterFrontendPath() string
FlutterFrontendPath returns the Flutter app's getApplicationSupportDirectory() path. Dart: flutterFrontendDir() (L1306-1353)
func (BinaryDirConfig) FrontendDir ¶
func (b BinaryDirConfig) FrontendDir() string
FrontendDir returns the frontend directory from directory config. Dart: frontendDir() (L1604-1612)
func (BinaryDirConfig) GetAllDatadirPaths ¶
func (b BinaryDirConfig) GetAllDatadirPaths(networkDir string) []string
GetAllDatadirPaths returns all files in the binary's datadir. Dart: getAllDatadirPaths (L595-613)
func (BinaryDirConfig) GetBinaryPaths ¶
func (b BinaryDirConfig) GetBinaryPaths(assetsDir string, log zerolog.Logger) []string
GetBinaryPaths returns existing binary + extra file paths in assets dir. Dart: getBinaryPaths (L520-592)
func (BinaryDirConfig) GetBlockchainDataPaths ¶
func (b BinaryDirConfig) GetBlockchainDataPaths(networkDir string, network Network, log zerolog.Logger) []string
GetBlockchainDataPaths returns blockchain data file paths for a binary. Dart: getBlockchainDataPaths (L334-381)
func (BinaryDirConfig) GetLogPaths ¶
func (b BinaryDirConfig) GetLogPaths(networkDir string, log zerolog.Logger) []string
GetLogPaths returns log file paths for a binary (for deletion). Dart: getLogPaths (L579-627)
func (BinaryDirConfig) GetSettingsPaths ¶
func (b BinaryDirConfig) GetSettingsPaths(networkDir string, network Network, log zerolog.Logger) []string
GetSettingsPaths returns settings file paths for a binary. Dart: getSettingsPaths (L384-452)
func (BinaryDirConfig) GetWalletPaths ¶
func (b BinaryDirConfig) GetWalletPaths(networkDir string, network Network, log zerolog.Logger) []string
GetWalletPaths returns wallet file paths for a binary. Dart: getWalletPaths (L455-499)
func (BinaryDirConfig) LogPath ¶
func (b BinaryDirConfig) LogPath(networkDir string) string
LogPath returns the log file path for this binary. Dart: logPath (L1378-1392)
func (BinaryDirConfig) ResolveBinaryPath ¶
func (b BinaryDirConfig) ResolveBinaryPath(appDir string) (string, error)
ResolveBinaryPath finds the binary executable on disk. Dart: resolveBinaryPath (L615-638)
func (BinaryDirConfig) RootDir ¶
func (b BinaryDirConfig) RootDir() string
RootDir returns the root data directory (same for all networks). Panics if directories differ per network. Dart: Binary.rootDir() (L1529-1535)
func (BinaryDirConfig) RootDirNetwork ¶
func (b BinaryDirConfig) RootDirNetwork(network Network) string
RootDirNetwork returns the root data directory for a specific network. Dart: Binary.rootDirNetwork(network) (L1518-1523)
type BitcoinConfManager ¶
type BitcoinConfManager struct {
BitwindowDir string
Network Network
Config *BitcoinConfig
ConfigPath string
DetectedDataDir string
HasPrivateConf bool
// ECashID is the live eCash network ("alphanet"). Set from the
// resolved network catalog; falls back to the embedded id until
// then, so a first boot still writes a usable peer.
ECashID string
// OnNetworkChanged is called after a network switch completes.
// Set by the server to restart services (orchestrator binaries).
OnNetworkChanged func()
// contains filtered or unexported fields
}
BitcoinConfManager manages Bitcoin Core configuration files. Port of the data/config logic from sail_ui/lib/providers/bitcoin_conf_provider.dart. UI-specific logic (file watching, navigation, restart) is omitted.
func NewBitcoinConfManager ¶
func NewBitcoinConfManager(bitwindowDir string, defaultNetwork Network, log zerolog.Logger) (*BitcoinConfManager, error)
NewBitcoinConfManager creates a new BitcoinConfManager and loads config. defaultNetwork seeds the network used to generate the conf on first boot (when no bitwindow-bitcoin.conf exists yet); once the conf exists, its chain= setting drives the manager and the seed is ignored.
func (*BitcoinConfManager) CommitNetworkChange ¶
func (m *BitcoinConfManager) CommitNetworkChange(newNetwork Network) error
CommitNetworkChange commits a pending network change. Dart: commitNetworkChange (L411)
func (*BitcoinConfManager) CopyConfigDownstream ¶
func (m *BitcoinConfManager) CopyConfigDownstream() error
CopyConfigDownstream copies the master config from the BitWindow directory to the downstream location where Bitcoin Core expects it. The downstream file is read-only — any changes should be made to the master.
func (*BitcoinConfManager) CreateDataDir ¶
func (m *BitcoinConfManager) CreateDataDir() error
CreateDataDir creates the directory bitcoind runs in.
A path the user picked must still have its parent: a disconnected disk leaves none, and a recursive create would hide the chain behind an empty directory.
func (*BitcoinConfManager) DataDir ¶
func (m *BitcoinConfManager) DataDir() string
DataDir returns the directory bitcoind writes to on the active network. datadir= is optional — signet, testnet and regtest normally run in Core's platform default — so an unset DetectedDataDir resolves to that default rather than being an error.
func (*BitcoinConfManager) ECashPeer ¶
func (m *BitcoinConfManager) ECashPeer() string
ECashPeer is the seed node for the active eCash network. ECash has no DNS seeds, so bitcoind needs an explicit peer to find the network at all.
func (*BitcoinConfManager) GetConfFilePath ¶
func (m *BitcoinConfManager) GetConfFilePath() string
GetConfFilePath returns the resolved -conf= path to pass to bitcoind. Mirrors the confFile() logic from binaries.dart.
func (*BitcoinConfManager) GetCurrentConfigContent ¶
func (m *BitcoinConfManager) GetCurrentConfigContent() string
GetCurrentConfigContent returns the current configuration content as string. Dart: getCurrentConfigContent (L747)
func (*BitcoinConfManager) GetDefaultConfig ¶
func (m *BitcoinConfManager) GetDefaultConfig() string
GetDefaultConfig generates the default bitcoin.conf content. Port of getDefaultConfig() from bitcoin_conf_provider.dart.
One unified template across all networks: a common settings block (RPC, ZMQ, perf knobs, uacomment) that's identical everywhere, plus per-network [main]/[signet]/[test]/[regtest] sections for the actual differences. The enforcer is now expected to run on mainnet too, so it gets the same perf settings (rpcthreads, rpcworkqueue) and ZMQ wiring as the other networks.
fallbackfee deliberately lives only in the non-mainnet sections — Bitcoin Core rejects a non-zero fallbackfee on mainnet, and the setting is mainly useful for testnet/signet/regtest where fee estimation is unreliable.
func (*BitcoinConfManager) GetExplicitRPCCredentials ¶
func (m *BitcoinConfManager) GetExplicitRPCCredentials() (string, string)
GetExplicitRPCCredentials returns the configured rpcuser/rpcpassword, both empty when the conf relies on cookie auth. Callers that pass a cookie path separately use this so an empty pair falls through to cookie authentication.
func (*BitcoinConfManager) GetRPCCookiePath ¶
func (m *BitcoinConfManager) GetRPCCookiePath() string
GetRPCCookiePath returns the path Core writes its auth cookie to. An rpccookiefile setting wins, absolute or relative to the network datadir.
func (*BitcoinConfManager) GetRPCCredentials ¶
func (m *BitcoinConfManager) GetRPCCredentials() (string, string, error)
GetRPCCredentials returns the basic-auth pair for Core's RPC: rpcuser and rpcpassword when the conf sets them, otherwise the cookie Core writes when it has no configured password.
The cookie is read fresh every call — Core rewrites it on each restart, so a cached value goes stale silently.
func (*BitcoinConfManager) GetRPCHost ¶
func (m *BitcoinConfManager) GetRPCHost() string
GetRPCHost returns the effective RPC host (rpcconnect or local default).
func (*BitcoinConfManager) GetRPCPort ¶
func (m *BitcoinConfManager) GetRPCPort() int
GetRPCPort returns the effective RPC port (config or network default).
func (*BitcoinConfManager) HasDatadirForNetwork ¶
func (m *BitcoinConfManager) HasDatadirForNetwork(n Network) bool
HasDatadirForNetwork reports whether a datadir is configured for n's group. Mainnet and ecash require an explicit user-chosen path because the platform default sits inside ~/Library/Application Support and isn't suitable for full chain data; signet/testnet/regtest accept the default (Bitcoin Core auto-partitions them under chain subdirs).
func (*BitcoinConfManager) LoadConfig ¶
func (m *BitcoinConfManager) LoadConfig(isFirst bool) error
LoadConfig loads or creates the Bitcoin configuration file. 1:1 port of Dart loadConfig (frontend_bitcoin_conf_provider.dart L103).
func (*BitcoinConfManager) RefreshMainSectionDefaults ¶
func (m *BitcoinConfManager) RefreshMainSectionDefaults() error
RefreshMainSectionDefaults rewrites the active network's [main] block and saves it. Used when something the block is built from changes underneath a running install — the eCash network, for instance — without a network swap to trigger the usual rewrite.
func (*BitcoinConfManager) ResolvedECashID ¶
func (m *BitcoinConfManager) ResolvedECashID() string
ResolvedECashID returns the eCash network to write into bitcoin.conf. It falls back to the embedded catalog so a first boot — which happens before the catalog resolves — still writes a real id rather than an empty value.
func (*BitcoinConfManager) RootDataDir ¶
func (m *BitcoinConfManager) RootDataDir() string
RootDataDir returns the datadir root bitcoind must run in: the configured datadir=, or this install's platform default. The orchestrator passes it to bitcoind as -datadir, because Core's own default is a different folder and every path this package builds — cookie, chain data, conf — assumes ours.
func (*BitcoinConfManager) SaveConfig ¶
func (m *BitcoinConfManager) SaveConfig() error
SaveConfig writes the current config to disk.
func (*BitcoinConfManager) StartWatching ¶
func (m *BitcoinConfManager) StartWatching() error
StartWatching watches the BitWindow directory for changes to the master bitcoin config file. On change, it reloads config and copies downstream. Must be called after LoadConfig. Call StopWatching to clean up.
func (*BitcoinConfManager) StopWatching ¶
func (m *BitcoinConfManager) StopWatching()
StopWatching stops the file watcher.
func (*BitcoinConfManager) SwapNetwork ¶
func (m *BitcoinConfManager) SwapNetwork(newNetwork Network) error
SwapNetwork checks datadir availability before switching networks. Dart: swapNetwork (L356) — UI parts (router.push) skipped.
func (*BitcoinConfManager) UpdateDataDir ¶
func (m *BitcoinConfManager) UpdateDataDir(dataDir string, forNetwork Network) error
UpdateDataDir records dataDir for forNetwork's datadir group. If the group is currently active, it also rewrites the live `datadir=` line so bitcoind reads the new path on next boot. Otherwise it only updates the inactive group's slot — the active datadir is untouched.
forNetwork must be a known Network value; the group resolution depends on it (ecash vs default).
func (*BitcoinConfManager) UpdateNetwork ¶
func (m *BitcoinConfManager) UpdateNetwork(n Network) error
UpdateNetwork writes the new network to the config file. On a cross-group swap (default ↔ ecash) it first snapshots the live `datadir=` value into the leaving group's slot, then materializes the entering group's slot into `datadir=`. Within a group, datadir is left untouched (Bitcoin Core's chain subdirs partition the four default networks under the same folder). 1:1 port of Dart updateNetwork (frontend_bitcoin_conf_provider.dart L290).
func (*BitcoinConfManager) WriteConfig ¶
func (m *BitcoinConfManager) WriteConfig(content string) error
WriteConfig writes raw configuration content to the appropriate file. Dart: writeConfig (L756)
type BitcoinConfMigration ¶
type BitcoinConfMigration struct {
Version int
Changes map[string]map[string]string
// WipeChainData lists networks whose on-disk chain state this migration
// invalidates (e.g. a signetchallenge change). Wiped only when the
// migration actually changes a value in an existing config.
WipeChainData []Network
// SkipIfSet leaves a key that the config already carries alone, so a
// migration that only backfills a default never overwrites a user's value.
SkipIfSet bool
// Apply runs a migration that needs more than a key/value write. It
// reports whether it changed the config.
Apply func(*BitcoinConfig) bool
}
BitcoinConfMigration represents a versioned config migration. Changes maps section name → key → value. Empty section "" means global.
type BitcoinConfig ¶
type BitcoinConfig struct {
GlobalSettings map[string]string
GlobalOrder []string
NetworkSettings map[string]map[string]string // "main", "test", "signet", "regtest"
NetworkOrder map[string][]string
ConfigVersion int
// DatadirSlots holds the per-group datadir snapshots read from / written
// to # bitwindow-datadir-= comment lines. Keyed by DatadirGroup
// value ("default", "ecash"). Empty string = unset/cleared.
DatadirSlots map[DatadirGroup]string
// contains filtered or unexported fields
}
BitcoinConfig represents a parsed Bitcoin Core configuration file.
Order matters: the conf editor and the user expect the on-disk order to be preserved across read/write round-trips. Go maps don't preserve insertion order, so we keep a parallel `*Order` slice for each settings map and walk it in Serialize.
func NewBitcoinConfig ¶
func NewBitcoinConfig() *BitcoinConfig
func ParseBitcoinConfig ¶
func ParseBitcoinConfig(content string) *BitcoinConfig
ParseBitcoinConfig parses bitcoin.conf content into a BitcoinConfig.
func (*BitcoinConfig) GetEffectiveSetting ¶
func (c *BitcoinConfig) GetEffectiveSetting(key, network string) string
GetEffectiveSetting returns the effective setting for a network (section overrides global).
func (*BitcoinConfig) GetGroupDatadir ¶
func (c *BitcoinConfig) GetGroupDatadir(g DatadirGroup) string
GetGroupDatadir returns the recorded datadir for a group, or "" if unset.
func (*BitcoinConfig) GetSetting ¶
func (c *BitcoinConfig) GetSetting(key string, section ...string) string
func (*BitcoinConfig) HasSetting ¶
func (c *BitcoinConfig) HasSetting(key string, section ...string) bool
func (*BitcoinConfig) RemoveSetting ¶
func (c *BitcoinConfig) RemoveSetting(key string, section ...string)
func (*BitcoinConfig) Serialize ¶
func (c *BitcoinConfig) Serialize() string
Serialize writes the config back to file format, preserving the order in which keys were inserted (i.e. the order they appeared on disk for parsed configs, or insertion order for programmatically built configs).
func (*BitcoinConfig) SetGroupDatadir ¶
func (c *BitcoinConfig) SetGroupDatadir(g DatadirGroup, path string)
SetGroupDatadir records the datadir for a group. Empty path clears the slot.
func (*BitcoinConfig) SetSetting ¶
func (c *BitcoinConfig) SetSetting(key, value string, section ...string)
type DatadirGroup ¶
type DatadirGroup string
DatadirGroup partitions networks by which folder bitcoind writes to. eCash runs on chain=main and writes to the root of datadir, where it collides with mainnet, so it takes its own group. The four "default" networks share one datadir because Bitcoin Core auto-partitions them via chain subdirectories (signet/, testnet3/, regtest/, blocks/ for mainnet).
const ( DatadirGroupDefault DatadirGroup = "default" DatadirGroupECash DatadirGroup = "ecash" )
func DatadirGroupForNetwork ¶
func DatadirGroupForNetwork(n Network) DatadirGroup
DatadirGroupForNetwork returns the datadir group a network belongs to.
type DownloadProgress ¶
type DownloadProgress struct {
Progress float64 // bytes downloaded
Total float64 // total bytes
Error string // error message
Message string // status message
Hash string // SHA256 hash
DownloadedAt time.Time // when download completed
IsDownloading bool
}
DownloadProgress tracks download progress for a binary. Dart: DownloadInfo class (L1969-2025)
func (DownloadProgress) ProgressPercent ¶
func (d DownloadProgress) ProgressPercent() float64
ProgressPercent returns the download progress as a percentage (0.0-1.0). Dart: DownloadInfo.progressPercent getter
type EnforcerConfManager ¶
type EnforcerConfManager struct {
Config *EnforcerConfig
ConfigPath string
ConfigDir string // directory where bitwindow-enforcer.conf lives; required
// contains filtered or unexported fields
}
EnforcerConfManager manages Enforcer daemon configuration. 1:1 port of sail_ui/lib/providers/enforcer_conf_provider.dart.
func NewEnforcerConfManager ¶
func NewEnforcerConfManager(bitcoinConf *BitcoinConfManager, configDir string, log zerolog.Logger) (*EnforcerConfManager, error)
NewEnforcerConfManager creates a new EnforcerConfManager and loads config. configDir is the directory where bitwindow-enforcer.conf lives (typically the orchestrator's bitwindowDir). It must be set; tests previously scribbled on the user's real ~/Library/Application Support/bip300301_enforcer/ because there was no required dir parameter and the old fallback used a hardcoded global path. Dart: EnforcerConfProvider.create() (L25)
func (*EnforcerConfManager) GetCliArgs ¶
func (m *EnforcerConfManager) GetCliArgs() []string
GetCliArgs converts current config settings to CLI arguments for the enforcer. Persisted values always win — for the bitcoin-conf-derived keys (node-rpc-*, node-zmq-addr-sequence, wallet-esplora-url) we fall back to the bitcoin.conf / network derivation only when the persisted file doesn't specify a value. That preserves an explicit override while keeping fresh installs (no derived keys in the default template) network-correct out of the box. Dart: getCliArgs (L275)
func (*EnforcerConfManager) GetCurrentConfigContent ¶
func (m *EnforcerConfManager) GetCurrentConfigContent() string
GetCurrentConfigContent returns the current configuration content as string. Dart: getCurrentConfigContent (L225)
func (*EnforcerConfManager) GetDefaultConfig ¶
func (m *EnforcerConfManager) GetDefaultConfig() string
GetDefaultConfig generates the default enforcer config content.
node-rpc-{user,pass,addr}, node-zmq-addr-sequence, and wallet-esplora-url are deliberately NOT in this template even though the enforcer needs them — they're derived from the active bitcoin.conf / network and overlaid by GetCliArgs at boot. Persisting them here is what made the enforcer.conf desync from Core whenever the user swapped networks. Dart: getDefaultConfig (L194)
func (*EnforcerConfManager) GetExpectedNodeRpcSettings ¶
func (m *EnforcerConfManager) GetExpectedNodeRpcSettings() map[string]string
GetExpectedNodeRpcSettings derives RPC credentials from bitcoin config. Dart: getExpectedNodeRpcSettings (L71)
func (*EnforcerConfManager) LoadConfig ¶
func (m *EnforcerConfManager) LoadConfig() error
LoadConfig loads config from file, or creates default if not exists. Runs versioned migrations on load when stored version < current. Dart: loadConfig (L148)
func (*EnforcerConfManager) RetargetECashNetwork ¶
func (m *EnforcerConfManager) RetargetECashNetwork(previousID, id string) (bool, error)
RetargetECashNetwork moves persisted settings onto the eCash network id, and reports whether the file changed. previousID is the network they came from, empty when it is unknown.
GetCliArgs treats a persisted value as an explicit override, and every start calls this. So the endpoint moves only when it still names previousID, while the preset always moves — no preset but the running fork's is correct.
func (*EnforcerConfManager) RetargetECashNetworkFor ¶
func (m *EnforcerConfManager) RetargetECashNetworkFor(target Network, previousID, id string) (bool, error)
RetargetECashNetworkFor is RetargetECashNetwork for a switch that has not landed yet. The caller names the network that will be active, because the enforcer conf has to be right before anything reads it — the L1 boot reads it on a goroutine the swap starts.
func (*EnforcerConfManager) SaveConfig ¶
func (m *EnforcerConfManager) SaveConfig() error
SaveConfig writes the current config to disk. Dart: _saveConfig (L44)
func (*EnforcerConfManager) StartWatching ¶
func (m *EnforcerConfManager) StartWatching() error
StartWatching watches the enforcer config directory for changes. On change, it reloads config if content differs.
func (*EnforcerConfManager) StopWatching ¶
func (m *EnforcerConfManager) StopWatching()
StopWatching stops the file watcher.
func (*EnforcerConfManager) WriteConfig ¶
func (m *EnforcerConfManager) WriteConfig(content string) error
WriteConfig writes raw configuration content to the file. Dart: writeConfig (L233)
type EnforcerConfMigration ¶
type EnforcerConfMigration struct {
Version int
Apply func(config *EnforcerConfig)
}
EnforcerConfMigration represents a versioned enforcer config migration.
type EnforcerConfig ¶
EnforcerConfig represents parsed enforcer configuration. Unlike Bitcoin Core, the enforcer doesn't read from a conf file directly - it only accepts CLI arguments. We store settings in a file and convert them to CLI args at launch time. 1:1 port of sail_ui/lib/models/enforcer_config.dart
func NewEnforcerConfig ¶
func NewEnforcerConfig() *EnforcerConfig
func ParseEnforcerConfig ¶
func ParseEnforcerConfig(content string) *EnforcerConfig
ParseEnforcerConfig parses a simple key=value format config file (no sections).
func (*EnforcerConfig) GetSetting ¶
func (c *EnforcerConfig) GetSetting(key string) string
func (*EnforcerConfig) HasSetting ¶
func (c *EnforcerConfig) HasSetting(key string) bool
func (*EnforcerConfig) RemoveSetting ¶
func (c *EnforcerConfig) RemoveSetting(key string)
func (*EnforcerConfig) Serialize ¶
func (c *EnforcerConfig) Serialize() string
Serialize writes the config back to file format.
func (*EnforcerConfig) SetSetting ¶
func (c *EnforcerConfig) SetSetting(key, value string)
type GenericAppConfig ¶
GenericAppConfig is a simple key-value config for sidechain apps.
func NewGenericAppConfig ¶
func NewGenericAppConfig() *GenericAppConfig
func ParseGenericAppConfig ¶
func ParseGenericAppConfig(content string) *GenericAppConfig
func (*GenericAppConfig) GetSetting ¶
func (c *GenericAppConfig) GetSetting(key string) string
func (*GenericAppConfig) RemoveSetting ¶
func (c *GenericAppConfig) RemoveSetting(key string)
func (*GenericAppConfig) Serialize ¶
func (c *GenericAppConfig) Serialize() string
func (*GenericAppConfig) SetSetting ¶
func (c *GenericAppConfig) SetSetting(key, value string)
type GitHubCache ¶
type GitHubCache struct {
// contains filtered or unexported fields
}
GitHubCache caches GitHub API responses with a 1-minute TTL. Dart: _GitHubCache (L813-840)
type Network ¶
type Network string
Network represents the Bitcoin network type.
func LightModeNetworks ¶
func LightModeNetworks() []Network
LightModeNetworks lists the networks light mode can serve.
func LookupNetwork ¶
LookupNetwork converts a string to a Network value and reports whether it named one. Callers that write per-network state need the flag: a catalog id such as "alphanet" is not a network name, and the signet fallback would otherwise stamp that entry's values onto signet.
func NetworkForCatalogEntry ¶
NetworkForCatalogEntry maps a published catalog entry onto the slot it runs in. Every eCash entry shares one slot, whatever its id; the rest are named after the slot itself. false means the app cannot run that entry.
func NetworkFromConfig ¶
func NetworkFromConfig(conf *BitcoinConfig, fallback Network) Network
NetworkFromConfig detects the network from a parsed BitcoinConfig. eCash runs on chain=main, and the uacomment sentinel it writes into [main] tells it apart from mainnet. fallback is returned when the config carries no chain=/testnet=/signet=/ regtest= selector at all — signet for our own managed conf, but the network the file was found under for a user's private bitcoin.conf.
func NetworkFromString ¶
NetworkFromString converts a string (e.g. CLI flag) to a Network value, falling back to signet for anything it does not recognise.
func ResolveNetwork ¶
ResolveNetwork reads the network and, for eCash, its catalog id out of bitwindow-bitcoin.conf. The file is the source of truth, so a caller aligns with it in one read instead of a wait on the orchestrator. Never writes it.
func RunBitcoinConfMigrations ¶
func RunBitcoinConfMigrations(config *BitcoinConfig) (bool, []Network)
RunBitcoinConfMigrations applies pending migrations to a BitcoinConfig. Returns whether any migration was applied, plus the networks whose chain data must be wiped. A wipe fires only when a migration carrying WipeChainData actually changed a value — a config that already matches (or a fresh default, which never runs migrations) is left alone.
func (Network) CoreChainDir ¶
ReadableName returns a human-readable network name. Dart: toReadableNet() extension CoreChainDir is the subdirectory Bitcoin Core writes under its datadir. Matches ReadableName everywhere except testnet, which Core stores as testnet3.
func (Network) CoreSection ¶
CoreSection returns the Bitcoin Core config section name for this network.
func (Network) ReadableName ¶
type ProcessLogEntry ¶
ProcessLogEntry stores a single process log line. Dart: ProcessLogEntry class (L2027-2035)
type ShutdownProgressInfo ¶
type ShutdownProgressInfo struct {
TotalCount int
CompletedCount int
CurrentBinary string
IsForceKill bool
}
ShutdownProgressInfo reports progress during shutdown. Dart: ShutdownProgress class (L1954-1966)
type SidechainConfManager ¶
type SidechainConfManager struct {
Config *GenericAppConfig
ConfigPath string
Spec SidechainConfSpec
// BitcoinConf is the mainchain conf the sidechain network follows.
BitcoinConf *BitcoinConfManager
// contains filtered or unexported fields
}
SidechainConfManager manages a sidechain's key-value config file. Generic replacement for ThunderConfManager and ZSideConfManager.
func NewSidechainConfManager ¶
func NewSidechainConfManager(spec SidechainConfSpec, bitcoinConf *BitcoinConfManager, log zerolog.Logger) (*SidechainConfManager, error)
NewSidechainConfManager creates a new conf manager for the given sidechain.
func SidechainConfByName ¶
func SidechainConfByName(confs map[string]*SidechainConfManager, name string) *SidechainConfManager
SidechainConfByName finds the manager for a binary name. The chains config writes a display name like "Thunder", and the specs are keyed "thunder".
func (*SidechainConfManager) GetCliArgs ¶
func (m *SidechainConfManager) GetCliArgs() []string
GetCliArgs converts the named config keys to CLI args, and adds the network the daemon runs on.
func (*SidechainConfManager) GetDefaultConfig ¶
func (m *SidechainConfManager) GetDefaultConfig() string
GetDefaultConfig generates the default config content.
func (*SidechainConfManager) GetNetwork ¶
func (m *SidechainConfManager) GetNetwork() string
GetNetwork returns the network the sidechain follows. It reads the mainchain conf, never the sidechain file, so the two can never disagree.
func (*SidechainConfManager) LoadConfig ¶
func (m *SidechainConfManager) LoadConfig() error
LoadConfig loads the config from file, or creates default if not exists.
func (*SidechainConfManager) StartWatching ¶
func (m *SidechainConfManager) StartWatching() error
StartWatching watches the config directory for file changes.
func (*SidechainConfManager) StopWatching ¶
func (m *SidechainConfManager) StopWatching()
func (*SidechainConfManager) SyncNetworkFromBitcoinConf ¶
func (m *SidechainConfManager) SyncNetworkFromBitcoinConf() error
SyncNetworkFromBitcoinConf points the generated endpoints at the network the mainchain runs. A value the user typed is not the generated value on any network, so the sync keeps it.
func (*SidechainConfManager) WriteConfig ¶
func (m *SidechainConfManager) WriteConfig(content string) error
WriteConfig writes raw config content to file.
type SidechainConfSpec ¶
type SidechainConfSpec struct {
// Name is the sidechain name (e.g. "thunder", "bitassets").
Name string
// ConfigFilename is the config file name (e.g. "thunder.conf").
ConfigFilename string
// BasePort is the signet RPC port (e.g. 6009 for thunder).
BasePort int
// CliArgKeys are the conf keys the launch path passes on the command
// line, in order. An empty list passes nothing. Name a key only after you
// read the daemon's own CLI: a flag it does not know stops it on the first
// boot, and a port it does not share with BinaryConfig.Port hides it from
// the health check.
CliArgKeys []string
// EnforcerArg is the daemon flag for its mainchain URL or host.
EnforcerArg string
// PortStyle names the second endpoint the daemon binds, next to its RPC
// and P2P ports.
// "grpc" = mainchain-grpc-url (thunder, zside, photon, etc.)
// "zmq" = zmq-addr, the block hash publisher (bitassets, bitnames)
PortStyle string
// RPCKey is the conf key that holds the RPC endpoint. The daemons differ:
// bitassets takes a bare port on --rpc-port, and the rest take a socket
// address on --rpc-addr. An empty value reads as "rpc-addr".
RPCKey string
// DirKey is the chains_config.json key for the data directory lookup.
DirKey string
// LegacyRootDirName is the folder an older release kept this chain's conf
// in, under the same platform base. The first load moves the conf out of
// it, so a value the user set by hand survives the move.
LegacyRootDirName string
}
SidechainConfSpec defines how a sidechain's configuration should be managed.
func SidechainSpecByName ¶
func SidechainSpecByName(name string) (SidechainConfSpec, bool)
SidechainSpecByName finds the spec for a binary name, by the same rule as SidechainConfByName.
func (SidechainConfSpec) EnforcerArgs ¶
func (s SidechainConfSpec) EnforcerArgs(endpoint string) ([]string, error)
EnforcerArgs returns the daemon arguments for a mainchain endpoint.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package netcatalog resolves the network catalog published at https://drivechain.dev/config: the per-network service endpoints, explorer URL templates and — for the eCash family — the live network id ("alphanet", "betanet", ...).
|
Package netcatalog resolves the network catalog published at https://drivechain.dev/config: the per-network service endpoints, explorer URL templates and — for the eCash family — the live network id ("alphanet", "betanet", ...). |