Expand description
The library behind stratum, the operator’s client for a Stratum node.
Pre-release: this is 0.1.0-alpha. The commands, output and API may
change before 0.1.0, and nothing built on it has been deployed yet.
A Stratum node serves an administrative API on loopback only. stratum
talks to that API over plain HTTP and holds the operator’s own Nostr key;
it never sees the node key or the node’s state volume, except that
stratum setup reads the bootstrap token file the operator points it at.
- URLs.
LoopbackUrlacceptshttp://URLs whose host is an IPv4 address in127.0.0.0/8,[::1]orlocalhost, and nothing else: Step 1 has no TLS.localhostis connected to127.0.0.1without a name lookup. - Operator keys.
generate_key_filewrites a fresh key as onensec1…line to a file created exclusively with mode0600;load_key_filerefuses symbolic links and modes wider than0600. The secret is never printed, logged or returned as text. - Changes.
parse_changesreads--set path=valuearguments typed by the schema instratum-node-config. - Commands.
Sessionruns each command against one node:status,config(schema,show,preview,apply),setup,sign-challenge,audit checkpointandbackup. Every authenticated request is signed withNostrSecretKey::sign_requestover the exact URL, method and body bytes sent. - Exit codes. Failures are
CliErrors, each mapped to a stable code inexit.
The crate targets Unix: key files rely on Unix permission bits.
§Example
use stratum_node_cli::{Output, OutputFormat, Session};
let output = Output::new(OutputFormat::Human);
let session = Session::new("http://127.0.0.1:7460".parse()?, Some("operator.nsec".into()), output);
let code = session.status().unwrap_or_else(|err| {
output.error(&err);
err.exit_code()
});
std::process::exit(i32::from(code));Modules§
- exit
- The process exit codes of
stratum, stable across releases.
Structs§
- Apply
Options - Options for
Session::config_apply. - Bootstrap
Token - The bootstrap token: 64 lowercase hex digits proving entitlement to claim a node.
- Loopback
Url - A plain-HTTP URL whose host is a loopback literal, kept in canonical form.
- Output
- The terminal writer used by every command.
- Session
- One node, one optional operator key file and one output format: the
context every
stratumcommand runs in. - Setup
Options - Options for
Session::setup.
Enums§
- CliError
- Why a
stratumcommand failed. - Confirmation
- Whether a command that changes the node may proceed without asking.
- KeyFile
Error - Why an operator key file could not be created or loaded.
- Output
Format - How results are written to standard output.
- Parse
Change Error - Why a
--setargument could not be parsed. - Parse
UrlError - The reasons a URL is refused by
LoopbackUrl. - Private
File Error - Why a private file could not be created or read.
- Token
File Error - Why the bootstrap token file could not be read.
Constants§
- DEFAULT_
URL - The default node URL: the loopback address the controller listens on by default.
Functions§
- generate_
key_ file - Creates a new operator key file holding a freshly generated key.
- load_
key_ file - Loads an operator key file written by
generate_key_file. - parse_
changes - Parses
--set path=valuearguments into configuration changes, typed by the schema instratum-node-config.