RustChain Read-Only API Contract

September 5, 2026 ยท View on GitHub

Canonical compatibility contract for the stable public RustChain health, epoch, active-miner, and wallet-balance reads. It reflects the production Flask handlers and intentionally excludes unregistered or write-capable routes.

The canonical machine-readable source is compatibility_lab/read_only_api.openapi.json. This reference is checked in for review and must be regenerated whenever the contract changes.

Safety Boundary

The compatibility surface is public and read-only. The lab sends only GET, never sends a request body or credentials, keeps TLS verification enabled, and is never pointed at a live node by CI.

Endpoints

MethodPathOperationImplementation
GET/healthRead node healthapi_health
GET/epochRead current epoch stateget_epoch
GET/api/minersList recently attested minersapi_miners
GET/wallet/balanceRead a miner wallet balanceapi_wallet_balance

GET /health

Returns process uptime, database availability, backup age, and tip freshness. An unhealthy node returns the same body schema with HTTP 503.

Query parameters: none.

Responses

StatusSchemaMeaning
200HealthResponseThe node reports healthy.
503HealthResponseThe database or backup freshness check reports unhealthy.

Offline fixtures:

GET /epoch

Returns the current absolute slot and epoch plus the configured reward pot, epoch size, enrollment count, and fixed RTC supply.

Query parameters: none.

Responses

StatusSchemaMeaning
200EpochResponseCurrent epoch state.

Offline fixtures:

GET /api/miners

Returns miners whose latest accepted attestation is less than one hour old, with bounded pagination and current-epoch enrollment metadata.

Query Parameters

NameRequiredTypeConstraintsDescription
limitnointeger>= 1; <= 1000; default 100Maximum miners returned.
offsetnointeger>= 0; default 0Zero-based result offset.

Responses

StatusSchemaMeaning
200MinersResponseA page of active miners and pagination metadata.
400ValidationErrorResponseA pagination parameter is malformed or outside its accepted range.
429RateLimitResponseThe per-client miner-list rate limit has been reached.

Offline fixtures:

GET /wallet/balance

Returns a valid miner identifier and its balance in integer micro-RTC and decimal RTC. A valid unknown identifier returns a zero balance.

Query Parameters

NameRequiredTypeConstraintsDescription
miner_idyesstringmin length 1; max length 80; pattern ^[A-Za-z0-9._:-]+$Canonical miner or wallet identifier. The endpoint also implements address as a legacy alias, but this contract standardizes miner_id.

Responses

StatusSchemaMeaning
200WalletBalanceResponseThe wallet balance, including zero for a valid unknown identifier.
400ValidationErrorResponseThe miner identifier is missing, malformed, or conflicts with the legacy address alias.

Offline fixtures:

Schemas

HealthResponse

Health body returned for both healthy and unhealthy status codes.

FieldTypeRequiredConstraintsDescription
okbooleanyes-Combined database and backup-freshness result.
versionstringyesmin length 1Running node application version.
uptime_sintegeryes>= 0Whole seconds since this process started.
db_rwbooleanyes-Whether the node database quick check completed.
backup_age_hoursnumber or nullyes>= 0Age of the newest known backup, or null when no backup timestamp is available.
tip_age_slotsinteger or nullyes>= 0Tip freshness indicator, or null when no header can be read. The current implementation reports zero when a header exists.

EpochResponse

Current epoch and immutable/configured emission values.

FieldTypeRequiredConstraintsDescription
epochintegeryes-Current epoch number derived from the absolute slot.
slotintegeryes-Absolute slot number derived from genesis time.
epoch_potnumberyes>= 0RTC distributed across an epoch.
enrolled_minersintegeryes>= 0Rows enrolled for the current epoch.
blocks_per_epochintegeryes>= 1Configured slots per epoch.
total_supply_rtcnumberyes>= 0Fixed total RTC supply configured by the node.

MinerInfo

One miner with an accepted attestation in the active one-hour window.

FieldTypeRequiredConstraintsDescription
minerstringyesmin length 1Miner wallet identifier.
last_attestintegeryes>= 0Unix timestamp of the latest accepted attestation.
first_attestinteger or nullyes>= 0Unix timestamp of the first retained attestation, or null when absent.
device_familystring or nullyes-Attested device family as stored by the node.
device_archstring or nullyes-Attested device architecture as stored by the node.
hardware_typestringyesmin length 1Display classification derived by the node.
entropy_scorenumberyes-Stored hardware entropy score, defaulting to zero when falsey.
antiquity_multipliernumberyes>= 0Reward multiplier selected from the hardware weight table.

MinersPagination

Pagination and enrollment metadata for an active-miner page.

FieldTypeRequiredConstraintsDescription
totalintegeryes>= 0Total miners in the active one-hour window.
total_enrolledintegeryes>= 0Miner enrollments in the current epoch.
limitintegeryes>= 1; <= 1000Applied page size.
offsetintegeryes>= 0Applied zero-based offset.
countintegeryes>= 0; <= 1000Number of miners in this response page.

MinersResponse

Paginated active-miner response envelope.

FieldTypeRequiredConstraintsDescription
minersMinerInfo[]yes-Miners ordered by latest attestation descending.
paginationMinersPaginationyes-Page and epoch-enrollment metadata.

WalletBalanceResponse

Balance for a canonical miner identifier. Success intentionally has no ok field.

FieldTypeRequiredConstraintsDescription
miner_idstringyesmin length 1; max length 80; pattern ^[A-Za-z0-9._:-]+$The validated identifier supplied by the caller.
amount_i64integeryes-Balance in integer micro-RTC.
amount_rtcnumberyes-Balance expressed in RTC.

ValidationErrorResponse

Public input-validation error used by miner pagination and wallet lookup.

FieldTypeRequiredConstraintsDescription
okbooleanyesconstant falseAlways false for this error body.
errorstringyesmin length 1Stable human-readable validation reason.

RateLimitResponse

Rate-limit body returned by the active-miner endpoint.

FieldTypeRequiredConstraintsDescription
okbooleanyesconstant falseAlways false for this error body.
errorstringyesconstant "rate_limited"Stable rate-limit error code.
limitstringyespattern ^[0-9]+/[0-9]+s$Configured request count and window, such as 30/60s.

Verification

From the repository root:

python3 -m compatibility_lab validate
python3 -m compatibility_lab generate-docs --check
python3 -m compatibility_lab check-links

A live compatibility probe is explicit and optional:

python3 -m compatibility_lab probe https://node.example --miner-id compatibility-probe