diff --git a/docs/api/openapi.yaml b/docs/api/openapi.yaml index 572062453..383c7adf7 100644 --- a/docs/api/openapi.yaml +++ b/docs/api/openapi.yaml @@ -1,500 +1,346 @@ -openapi: 3.0.3 +openapi: 3.0.0 info: title: RustChain Node API - description: | - API specification for RustChain blockchain nodes. - - RustChain is a blockchain that supports multiple hardware architectures with - antiquity-weighted mining rewards. This API provides endpoints for querying - chain state, miner information, wallet balances, and submitting signed transfers. - - ## Authentication - Currently, the API does not require authentication for read operations. - Write operations (transfers) require cryptographic signatures. - - ## Base URL - Production: `https://rustchain.org` - - **Note:** The server uses a self-signed TLS certificate. - version: 2.2.1 - contact: - name: RustChain Development Team - url: https://github.com/Scottcjn/Rustchain - license: - name: MIT - url: https://opensource.org/licenses/MIT - + description: Public API documentation for the RustChain Node endpoints. + version: 1.0.0 servers: - url: https://rustchain.org - description: RustChain Mainnet Node - -tags: - - name: Health - description: Node health and status endpoints - - name: Chain - description: Blockchain statistics and information - - name: Miners - description: Miner registry and attestation data - - name: Wallet - description: Balance queries and transfers - + description: Public Live Node paths: /health: get: - tags: - - Health summary: Node health check - description: | - Returns the health status of the RustChain node including database - connectivity, chain tip age, uptime, and version information. - operationId: getHealth + description: Returns health status, uptime, and version. responses: '200': - description: Health status response + description: OK content: application/json: schema: - $ref: '#/components/schemas/HealthResponse' + type: object + properties: + ok: + type: boolean + uptime_s: + type: integer + version: + type: string + backup_age_hours: + type: number + db_rw: + type: boolean + tip_age_slots: + type: integer example: ok: true + uptime_s: 58480 version: "2.2.1-rip200" - uptime_s: 97300 + backup_age_hours: 13.65 db_rw: true tip_age_slots: 0 - backup_age_hours: 16.589909323586358 - /api/stats: + /ready: + get: + summary: Readiness probe + description: Indicates if the node is fully synced and ready to serve traffic. + responses: + '200': + description: OK + content: + application/json: + schema: + type: object + properties: + ready: + type: boolean + example: + ready: true + + /epoch: get: - tags: - - Chain - summary: Chain statistics - description: | - Returns comprehensive blockchain statistics including total balance, - miner count, current epoch, supported features, and security settings. - operationId: getStats + summary: Current epoch status + description: Returns current epoch, slot, and enrolled miners. responses: '200': - description: Chain statistics response + description: OK content: application/json: schema: - $ref: '#/components/schemas/StatsResponse' + type: object + properties: + epoch: + type: integer + slot: + type: integer + enrolled_miners: + type: integer + blocks_per_epoch: + type: integer + epoch_pot: + type: number + total_supply_rtc: + type: number example: - chain_id: "rustchain-mainnet-v2" - version: "2.2.1-security-hardened" - epoch: 61 - block_time: 600 - total_miners: 11614 - total_balance: 5213.41835243 - pending_withdrawals: 0 - features: - - "RIP-0005" - - "RIP-0008" - - "RIP-0009" - - "RIP-0142" - - "RIP-0143" - - "RIP-0144" - security: - - "no_mock_sigs" - - "mandatory_admin_key" - - "replay_protection" - - "validated_json" + epoch: 91 + slot: 13227 + enrolled_miners: 20 + blocks_per_epoch: 144 + epoch_pot: 1.5 + total_supply_rtc: 8388608 /api/miners: get: - tags: - - Miners - summary: List all miners - description: | - Returns a list of all registered miners with their hardware information, - antiquity multipliers, entropy scores, and last attestation timestamps. - - The `antiquity_multiplier` reflects the age-based reward bonus: - - Vintage hardware (PowerPC, etc.): 2.0-2.5x - - Modern hardware (x86-64, Apple Silicon): 0.8x - operationId: getMiners + summary: Active miners + description: Returns list of active miners with attestation data. responses: '200': - description: List of miners + description: OK content: application/json: schema: type: array items: - $ref: '#/components/schemas/Miner' + type: object + properties: + miner_id: + type: string + attested: + type: boolean example: - - miner: "eafc6f14eab6d5c5362fe651e5e6c23581892a37RTC" - hardware_type: "PowerPC G4 (Vintage)" - device_family: "PowerPC" - device_arch: "G4" - antiquity_multiplier: 2.5 - entropy_score: 0.0 - last_attest: 1770062200 - - miner: "modern-sophia-Pow-9862e3be" - hardware_type: "x86-64 (Modern)" - device_family: "x86_64" - device_arch: "modern" - antiquity_multiplier: 0.8 - entropy_score: 0.0 - last_attest: 1770062191 + - miner_id: "m_12345" + attested: true - /wallet/balance: + /api/stats: get: - tags: - - Wallet - summary: Get wallet balance - description: | - Returns the current balance for a specific miner ID. - Balance is returned in both raw integer format (`amount_i64`) - and decimal RTC format (`amount_rtc`). - operationId: getBalance - parameters: - - name: miner_id - in: query - required: true - description: The unique identifier of the miner - schema: - type: string - example: "modern-sophia-Pow-9862e3be" + summary: Network statistics + description: Returns overall network statistics. responses: '200': - description: Balance response + description: OK content: application/json: schema: - $ref: '#/components/schemas/BalanceResponse' + type: object + properties: + total_blocks: + type: integer + total_transactions: + type: integer example: - miner_id: "modern-sophia-Pow-9862e3be" - amount_i64: 42653071 - amount_rtc: 0.42653071 - '400': - description: Missing miner_id parameter + total_blocks: 150000 + total_transactions: 1205000 + + /api/hall_of_fame: + get: + summary: Hall of Fame leaderboard + description: Leaderboard for 5 categories of miners/participants. + responses: + '200': + description: OK content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + type: object + properties: + top_miners: + type: array + items: + type: object example: - ok: false - error: "miner_id required" + top_miners: [] - /wallet/transfer/signed: - post: - tags: - - Wallet - summary: Submit signed transfer - description: | - Submits a cryptographically signed transfer transaction. - - The transaction must include: - - Source and destination addresses - - Transfer amount (positive value required) - - Ed25519 signature over the transaction data - - Public key for signature verification - - Nonce for replay protection - - ## Signing Process - 1. Construct the transaction payload - 2. Sign with Ed25519 private key - 3. Submit with hex-encoded signature and public key - operationId: submitTransfer - requestBody: - required: true - content: - application/json: - schema: - $ref: '#/components/schemas/SignedTransferRequest' - example: - from_address: "eafc6f14eab6d5c5362fe651e5e6c23581892a37RTC" - to_address: "modern-sophia-Pow-9862e3be" - amount_rtc: 1.5 - nonce: 42 - signature: "a1b2c3d4e5f6..." - public_key: "abc123def456..." + /api/fee_pool: + get: + summary: Fee pool statistics + description: RIP-301 fee pool statistics (fees recycled to mining pool). responses: '200': - description: Transfer submitted successfully + description: OK content: application/json: schema: - $ref: '#/components/schemas/TransferResponse' + type: object + properties: + description: + type: string + destination: + type: string + destination_balance_rtc: + type: number + rip: + type: integer + total_fee_events: + type: integer + total_fees_collected_rtc: + type: number + withdrawal_fee_rtc: + type: number example: - ok: true - tx_hash: "0xabc123..." - from_address: "eafc6f14eab6d5c5362fe651e5e6c23581892a37RTC" - to_address: "modern-sophia-Pow-9862e3be" - amount_rtc: 1.5 - '400': - description: Invalid request + description: "Fee Pool Statistics" + destination: "founder_community" + destination_balance_rtc: 83246.13 + rip: 301 + total_fee_events: 0 + total_fees_collected_rtc: 0 + withdrawal_fee_rtc: 0.01 + + /balance: + get: + summary: Miner balance lookup + description: Returns the RTC balance for a specific miner ID. + parameters: + - name: miner_id + in: query + required: true + schema: + type: string + description: Miner ID or public key + responses: + '200': + description: OK content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' - examples: - missing_fields: - summary: Missing required fields - value: - error: "Missing required fields (from_address, to_address, signature, public_key, nonce)" - invalid_amount: - summary: Invalid amount - value: - error: "Amount must be positive" - invalid_signature: - summary: Invalid signature - value: - error: "Invalid signature" - '500': - description: Internal server error + type: object + properties: + balance: + type: number + example: + balance: 150.5 + + /lottery/eligibility: + get: + summary: Epoch eligibility check + description: Checks if a miner is eligible for the current epoch block lottery. + parameters: + - name: miner_id + in: query + required: true + schema: + type: string + description: Miner ID or public key + responses: + '200': + description: OK content: application/json: schema: - $ref: '#/components/schemas/ErrorResponse' + type: object + properties: + eligible: + type: boolean + reason: + type: string + rotation_size: + type: integer + slot: + type: integer example: - error: "Internal server error" - -components: - schemas: - HealthResponse: - type: object - required: - - ok - - version - - uptime_s - - db_rw - - tip_age_slots - properties: - ok: - type: boolean - description: Overall health status - example: true - version: - type: string - description: Node software version - example: "2.2.1-rip200" - uptime_s: - type: integer - format: int64 - description: Node uptime in seconds - example: 97300 - db_rw: - type: boolean - description: Database read/write status - example: true - tip_age_slots: - type: integer - description: Age of chain tip in slots (0 = fully synced) - example: 0 - backup_age_hours: - type: number - format: double - description: Hours since last backup - example: 16.589909323586358 + eligible: false + reason: "not_attested" + rotation_size: 20 + slot: 13227 - StatsResponse: - type: object - required: - - chain_id - - version - - epoch - - block_time - - total_miners - - total_balance - properties: - chain_id: - type: string - description: Unique chain identifier - example: "rustchain-mainnet-v2" - version: - type: string - description: Chain version with security flags - example: "2.2.1-security-hardened" - epoch: - type: integer - description: Current epoch number - example: 61 - block_time: - type: integer - description: Target block time in seconds - example: 600 - total_miners: - type: integer - description: Total number of registered miners - example: 11614 - total_balance: - type: number - format: double - description: Total RTC balance across all accounts - example: 5213.41835243 - pending_withdrawals: - type: integer - description: Number of pending withdrawal requests - example: 0 - features: - type: array - description: List of enabled RIP (RustChain Improvement Proposal) features - items: - type: string - example: - - "RIP-0005" - - "RIP-0008" - - "RIP-0009" - - "RIP-0142" - - "RIP-0143" - - "RIP-0144" - security: - type: array - description: Active security features - items: - type: string - example: - - "no_mock_sigs" - - "mandatory_admin_key" - - "replay_protection" - - "validated_json" + /explorer: + get: + summary: Block explorer page + description: Returns the HTML page for the block explorer. + responses: + '200': + description: HTML page returned + content: + text/html: + schema: + type: string + example: "..." - Miner: - type: object - required: - - miner - - hardware_type - - device_family - - device_arch - - antiquity_multiplier - - last_attest - properties: - miner: - type: string - description: Unique miner identifier - example: "modern-sophia-Pow-9862e3be" - hardware_type: - type: string - description: Human-readable hardware description - example: "x86-64 (Modern)" - device_family: - type: string - description: Device family category - enum: - - PowerPC - - x86_64 - - x86 - - Apple Silicon - example: "x86_64" - device_arch: - type: string - description: Specific architecture identifier - example: "modern" - antiquity_multiplier: - type: number - format: double - description: | - Reward multiplier based on hardware age. - Vintage hardware (PowerPC) receives higher multipliers (2.0-2.5x) - while modern hardware receives 0.8x. - minimum: 0 - example: 0.8 - entropy_score: - type: number - format: double - description: Hardware entropy contribution score - example: 0.0 - last_attest: - type: integer - format: int64 - description: Unix timestamp of last attestation - example: 1770062191 + /attest/submit: + post: + summary: Submit hardware attestation + description: Submit an attestation proof. Requires X-Admin-Key. + security: + - AdminKeyAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + miner_id: + type: string + proof: + type: string + responses: + '200': + description: Attestation accepted - BalanceResponse: - type: object - required: - - miner_id - - amount_i64 - - amount_rtc - properties: - miner_id: - type: string - description: Miner identifier - example: "modern-sophia-Pow-9862e3be" - amount_i64: - type: integer - format: int64 - description: Balance in smallest unit (1 RTC = 100,000,000 units) - example: 42653071 - amount_rtc: - type: number - format: double - description: Balance in RTC (decimal format) - example: 0.42653071 + /wallet/transfer/signed: + post: + summary: Ed25519 signed transfer + description: Submit a signed transfer transaction. Requires X-Admin-Key. + security: + - AdminKeyAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + tx_payload: + type: string + signature: + type: string + responses: + '200': + description: Transfer accepted - SignedTransferRequest: - type: object - required: - - from_address - - to_address - - signature - - public_key - - nonce - properties: - from_address: - type: string - description: Source miner/wallet address - example: "eafc6f14eab6d5c5362fe651e5e6c23581892a37RTC" - to_address: - type: string - description: Destination miner/wallet address - example: "modern-sophia-Pow-9862e3be" - amount_rtc: - type: number - format: double - description: Amount to transfer in RTC (must be positive) - minimum: 0 - exclusiveMinimum: true - example: 1.5 - nonce: - type: integer - format: int64 - description: Transaction nonce for replay protection - example: 42 - signature: - type: string - description: Hex-encoded Ed25519 signature - example: "a1b2c3d4e5f6..." - public_key: - type: string - description: Hex-encoded Ed25519 public key - example: "abc123def456..." + /wallet/transfer: + post: + summary: Admin transfer + description: Transfer funds directly as admin. Requires X-Admin-Key. + security: + - AdminKeyAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + to: + type: string + amount: + type: number + responses: + '200': + description: Transfer executed - TransferResponse: - type: object - properties: - ok: - type: boolean - description: Success status - example: true - tx_hash: - type: string - description: Transaction hash - example: "0xabc123..." - from_address: - type: string - description: Source address - example: "eafc6f14eab6d5c5362fe651e5e6c23581892a37RTC" - to_address: - type: string - description: Destination address - example: "modern-sophia-Pow-9862e3be" - amount_rtc: - type: number - format: double - description: Transferred amount - example: 1.5 + /withdraw/request: + post: + summary: Withdrawal request + description: Request a withdrawal. Requires X-Admin-Key. + security: + - AdminKeyAuth: [] + requestBody: + required: true + content: + application/json: + schema: + type: object + properties: + miner_id: + type: string + amount: + type: number + responses: + '200': + description: Withdrawal requested - ErrorResponse: - type: object - properties: - ok: - type: boolean - description: Always false for errors - example: false - error: - type: string - description: Error message - example: "miner_id required" +components: + securitySchemes: + AdminKeyAuth: + type: apiKey + in: header + name: X-Admin-Key diff --git a/docs/api/swagger.html b/docs/api/swagger.html index 8369ba29d..d3dac72f2 100644 --- a/docs/api/swagger.html +++ b/docs/api/swagger.html @@ -1,76 +1,25 @@ - - + + + RustChain Node API - Swagger UI - - + -
- - - - +
+ + - + \ No newline at end of file