Documentation
¶
Index ¶
- Constants
- func ConfigDir() string
- func ExpandTildePath(path string) (string, error)
- func LogDir() string
- func RegisterService(cfg ServiceConfig) error
- func StartService() error
- func StopService() error
- func SummarizeFilter(f FilterConfig) string
- func UnregisterService() error
- func ValidateAssetFingerprint(p string) error
- func ValidateDRepID(p string) error
- func ValidatePolicyID(p string) error
- func ValidatePoolID(p string) error
- func ValidateWalletAddr(p string) error
- type APIConfig
- type AppBinaryFinder
- type AppConfig
- type ApplyResult
- type BinaryFinder
- type ConfigStore
- type Connector
- type FilterConfig
- type LocalStore
- type NetworkConfig
- type NotificationPrefs
- type OSManager
- type OutputConfig
- type ServiceConfig
- type ServiceManager
- type ServiceStatus
- type SetupPlan
- type SetupRunner
- type TrayConfig
Constants ¶
const ( // NotifyPrefBlocksMinted is the preference key for block minting alerts. NotifyPrefBlocksMinted = "Blocks minted" // NotifyPrefIncomingTx is the preference key for incoming transaction alerts. NotifyPrefIncomingTx = "Incoming transactions" // NotifyPrefOutgoingTx is the preference key for outgoing transaction alerts. NotifyPrefOutgoingTx = "Outgoing transactions" // NotifyPrefTokenTransfers is the preference key for token transfer alerts. NotifyPrefTokenTransfers = "Token transfers" // NotifyPrefGovProposals is the preference key for new governance proposals. NotifyPrefGovProposals = "New governance proposals" // NotifyPrefVotesCast is the preference key for votes cast alerts. NotifyPrefVotesCast = "Votes cast" // NotifyPrefRegChanges is the preference key for registration change alerts. NotifyPrefRegChanges = "Registration changes" // NotifyPrefPoolParams is the preference key for pool parameter change alerts. NotifyPrefPoolParams = "Pool parameter changes" // NotifyPrefAssetActivity is the preference key for events touching // any followed asset fingerprint (mint, burn, transfer). NotifyPrefAssetActivity = "Asset activity" // NotifyPrefPolicyActivity is the preference key for events touching // any followed minting policy ID. NotifyPrefPolicyActivity = "Policy activity" // NotifyPrefConnectionIssues is the preference key for connection status // alerts. NotifyPrefConnectionIssues = "Connection issues" )
const ( DefaultNotifyRateLimit = 1 DefaultNotifyRateWindow = 5 * time.Second )
Default values for the notification rate limiter. Used when the YAML config omits the fields or leaves them at zero.
Variables ¶
This section is empty.
Functions ¶
func ConfigDir ¶
func ConfigDir() string
ConfigDir returns the platform-specific directory for storing configuration files. It can be overridden by the ADDER_TRAY_CONFIG_DIR environment variable.
func ExpandTildePath ¶
ExpandTildePath expands the '~' prefix in a file path to the user's home directory. Returns the original path if no expansion is needed.
func LogDir ¶
func LogDir() string
LogDir returns the platform-specific directory for storing log files. It can be overridden by the ADDER_TRAY_LOG_DIR environment variable.
func RegisterService ¶
func RegisterService(cfg ServiceConfig) error
RegisterService installs adder as a system service using the platform-specific mechanism (systemd user unit, launchd plist, or Windows Task Scheduler).
func StartService ¶
func StartService() error
StartService starts the adder system service using the platform-specific mechanism.
func StopService ¶
func StopService() error
StopService stops the adder system service using the platform-specific mechanism.
func SummarizeFilter ¶ added in v0.42.0
func SummarizeFilter(f FilterConfig) string
SummarizeFilter returns a human-readable one-line description of a FilterConfig for use in dialogs, notifications, and the wizard's "Current configuration" line. Examples:
"everything" "2 wallets, 1 DRep, 1 pool" "2 wallets, 3 assets, 1 policy" "nothing configured"
func UnregisterService ¶
func UnregisterService() error
UnregisterService removes the adder system service.
func ValidateAssetFingerprint ¶ added in v0.42.0
ValidateAssetFingerprint checks that p is a CIP-14 asset fingerprint (asset1-prefixed bech32). Hex is NOT accepted here because the natural hex form of an asset is `<policy>.<assetName>`, not a flat hex string — accepting flat hex would silently let policy IDs pass.
func ValidateDRepID ¶ added in v0.42.0
ValidateDRepID checks that p is a DRep ID (drep1-prefixed bech32 or hex bytes). Surfaces a cross-template hint when the input's HRP matches a different template.
func ValidatePolicyID ¶ added in v0.42.0
ValidatePolicyID checks that p is a 56-character hex string (28-byte minting policy script hash). Length matters: a shorter or longer value is almost certainly the wrong field, so we reject it visibly rather than letting it flow into a never-matching rule.
func ValidatePoolID ¶ added in v0.42.0
ValidatePoolID checks that p is a stake-pool ID (pool1-prefixed bech32 or hex bytes). Surfaces a cross-template hint when the input's HRP matches a different template.
func ValidateWalletAddr ¶ added in v0.42.0
ValidateWalletAddr checks that p is a Cardano payment or stake address (Phase 1: prefix check only — bech32 checksum validation is a follow-up). Surfaces a cross-template hint when the input's HRP matches a different template.
Types ¶
type AppBinaryFinder ¶
type AppBinaryFinder struct {
// DevLookup, when true, lets Find() fall back to the current working
// directory (development/debug mode). It defaults to false and is never
// set by production code, so shipped builds never resolve a binary from an
// attacker-influenceable CWD.
//
// A build tag (//go:build dev) would compile the fallback out of release
// binaries entirely — a stronger guarantee — but a struct field is used
// here so the dev path stays exercisable under the standard `go test`
// run. The guarantee therefore rests on no production caller ever setting
// this true; keep it that way.
DevLookup bool
}
AppBinaryFinder locates a trusted `adder` binary to register and run as a system service. The resolved path is embedded into the OS service definition (systemd ExecStart, launchd ProgramArguments, schtasks /TR) and executed, so resolution must never trust an attacker-influenceable location.
func (*AppBinaryFinder) Find ¶
func (f *AppBinaryFinder) Find() (string, error)
type AppConfig ¶
type AppConfig struct {
AutoStart bool
// NotifyRateLimit / NotifyRateWindow override the engine's
// notification rate limiter. Zero values resolve to
// DefaultNotifyRateLimit / DefaultNotifyRateWindow at engine
// construction time via TrayConfig.ResolvedNotifyRate.
NotifyRateLimit int
NotifyRateWindow time.Duration
}
AppConfig defines tray-specific application settings.
type ApplyResult ¶ added in v0.42.0
type ApplyResult struct {
// BinaryFindErr is non-nil when Finder.Find failed; the service
// was NOT (re)started.
BinaryFindErr error
// ServiceRestartErr is non-nil when the service manager failed
// to (re)start adder; the running process may not reflect the
// new config.
ServiceRestartErr error
}
ApplyResult carries the soft (non-fatal) errors from Apply so callers can surface them to the user. Apply still succeeds (config is saved) but the running service may not reflect the change.
func (ApplyResult) HasSoftErrors ¶ added in v0.42.0
func (r ApplyResult) HasSoftErrors() bool
HasSoftErrors reports whether the result carries any non-fatal error worth surfacing to the user.
type BinaryFinder ¶
BinaryFinder defines the interface for locating the adder binary.
type ConfigStore ¶
type ConfigStore interface {
LoadEngine(path string) (config.Config, error)
SaveEngineAtomic(path string, cfg config.Config) error
LoadTray() (TrayConfig, error)
SaveTrayAtomic(cfg TrayConfig) error
}
ConfigStore defines the interface for persisting engine and tray configurations.
type Connector ¶
type Connector interface {
Connect() error
Disconnect()
Reconnect() error
SetAddress(addr string)
SetPort(port uint)
}
Connector defines the interface for managing the API connection.
type FilterConfig ¶
type FilterConfig struct {
MonitorEverything bool `yaml:"monitor_everything"`
Wallets []string `yaml:"wallets,omitempty"`
DReps []string `yaml:"dreps,omitempty"`
Pools []string `yaml:"pools,omitempty"`
Assets []string `yaml:"assets,omitempty"`
Policies []string `yaml:"policies,omitempty"`
}
FilterConfig defines the user's monitoring targets. The five lists are independent — the engine emits one rule per kind and OR-matches across them. MonitorEverything ignores the per-target lists and emits one coarse rule per event type. Persisted on TrayConfig (the sidecar engine config carries no per-target lists, since the cardano filter would AND-combine them on transaction events).
func CloneFilter ¶ added in v0.42.0
func CloneFilter(f FilterConfig) FilterConfig
CloneFilter returns a deep copy of f with fresh slice backing arrays so mutations on one side don't leak to the other.
type LocalStore ¶
type LocalStore struct {
TrayConfigPath string
}
LocalStore implements ConfigStore using the local filesystem.
func (*LocalStore) LoadEngine ¶
func (s *LocalStore) LoadEngine(path string) (config.Config, error)
func (*LocalStore) LoadTray ¶
func (s *LocalStore) LoadTray() (TrayConfig, error)
func (*LocalStore) SaveEngineAtomic ¶
func (s *LocalStore) SaveEngineAtomic(path string, cfg config.Config) error
func (*LocalStore) SaveTrayAtomic ¶
func (s *LocalStore) SaveTrayAtomic(cfg TrayConfig) error
type NetworkConfig ¶
type NetworkConfig struct {
Name string // mainnet, preprod, preview
CustomAddress string // For custom node connections
CustomPort uint
}
NetworkConfig defines the Cardano network settings.
type NotificationPrefs ¶
NotificationPrefs defines the user's desktop alert preferences.
type OSManager ¶
type OSManager struct{}
OSManager implements ServiceManager by delegating to platform-specific logic, ensuring operations are idempotent.
func (*OSManager) EnsureRegistered ¶
func (*OSManager) EnsureRunning ¶
func (*OSManager) RestartIfConfigChanged ¶
func (*OSManager) Status ¶
func (m *OSManager) Status() (ServiceStatus, error)
type OutputConfig ¶
type OutputConfig struct {
Type string // none, log, webhook, telegram
Config map[string]string // Key-value pairs for plugin options
}
OutputConfig defines the external event destination.
type ServiceConfig ¶
type ServiceConfig struct {
// BinaryPath is the absolute path to the adder binary.
BinaryPath string
// ConfigPath is the optional path to the adder configuration file.
ConfigPath string
// LogDir is the directory for log output (used by platforms that
// do not support journal-style logging).
LogDir string
}
ServiceConfig holds the configuration needed for service registration.
func (ServiceConfig) Validate ¶
func (c ServiceConfig) Validate() error
Validate checks that the ServiceConfig contains the minimum required fields.
type ServiceManager ¶
type ServiceManager interface {
EnsureRegistered(binPath, cfgPath string) error
EnsureRunning() error
RestartIfConfigChanged(binPath, cfgPath string) error
Stop() error
Status() (ServiceStatus, error)
}
ServiceManager defines the interface for idempotent service lifecycle management.
type ServiceStatus ¶
type ServiceStatus int
ServiceStatus represents the state of the system service.
const ( // ServiceNotRegistered indicates no service is installed. ServiceNotRegistered ServiceStatus = iota // ServiceRegistered indicates the service is installed but not running. ServiceRegistered // ServiceRunning indicates the service is installed and currently running. ServiceRunning )
func ServiceStatusCheck ¶
func ServiceStatusCheck() (ServiceStatus, error)
ServiceStatusCheck returns the current status of the adder system service.
func (ServiceStatus) String ¶
func (s ServiceStatus) String() string
String returns a human-readable representation of the ServiceStatus.
type SetupPlan ¶
type SetupPlan struct {
Network NetworkConfig
Filter FilterConfig
Output OutputConfig
API APIConfig
Notify NotificationPrefs
App AppConfig
}
SetupPlan represents the desired configuration state of the Adder ecosystem, decoupled from UI display strings and engine-specific map structures.
func SetupPlanFromEngineConfig ¶
func SetupPlanFromEngineConfig(c config.Config, tray TrayConfig) SetupPlan
SetupPlanFromEngineConfig reconstructs a SetupPlan from an existing engine configuration and tray settings.
type SetupRunner ¶
type SetupRunner struct {
Store ConfigStore
Service ServiceManager
Conn Connector
Finder BinaryFinder
}
SetupRunner orchestrates the application of a SetupPlan.
func (*SetupRunner) Apply ¶
func (r *SetupRunner) Apply( ctx context.Context, plan SetupPlan, ) (ApplyResult, error)
type TrayConfig ¶
type TrayConfig struct {
APIAddress string `yaml:"api_address"`
APIPort uint `yaml:"api_port"`
AdderConfig string `yaml:"adder_config"`
AutoStart bool `yaml:"auto_start"`
NotifyPrefs map[string]bool `yaml:"notify_prefs"`
Filter FilterConfig `yaml:"filter,omitempty"`
// NotifyRateLimit caps emitted notifications per
// NotifyRateWindow. Matches beyond the cap are coalesced into a
// single "Multiple events occurred" batch fired at the window
// boundary. A non-positive value disables the limiter (every
// match fires immediately). Zero (the YAML default for omitted
// fields) is resolved to DefaultNotifyRateLimit at load time.
NotifyRateLimit int `yaml:"notify_rate_limit,omitempty"`
// NotifyRateWindow is the limiter window. Zero is resolved to
// DefaultNotifyRateWindow at load time.
NotifyRateWindow time.Duration `yaml:"notify_rate_window,omitempty"`
}
TrayConfig holds the configuration for the adder-tray application. Filter is the authoritative source of monitoring targets — the sidecar engine config carries no per-target lists, because the cardano filter would AND-combine them on transaction events.
func (TrayConfig) ResolvedNotifyRate ¶ added in v0.42.0
func (c TrayConfig) ResolvedNotifyRate() (int, time.Duration)
ResolvedNotifyRate returns the rate-limit + window the engine should use, substituting defaults for zero values. A negative NotifyRateLimit is passed through (disables the limiter) so power users can opt out of coalescing entirely.