ProofServerClientImpl

class ProofServerClientImpl(httpClient: HttpClient, proofServerUrl: String = "http://localhost:6300", developmentMode: Boolean = true) : ProofServerClient

Ktor-based implementation of ProofServerClient for Midnight proof server.

Connection:

  • HTTP endpoint: POST to {proofServerUrl}/prove-tx

  • Binary protocol (SCALE codec)

  • Timeout: 300 seconds (5 minutes) - proof generation is slow

Retry Logic:

  • Retries on 502, 503, 504 (server overload/unavailable)

  • Exponential backoff: 2s, 4s, 8s

  • Maximum 3 attempts

  • Does NOT retry on 400-499 (client errors)

Security:

  • Development mode: Allows HTTP to localhost (testing only)

  • Production mode: Requires HTTPS

Parameters

httpClient

HTTP client for making requests (injectable for testing)

proofServerUrl

Proof server endpoint URL (e.g., "http://localhost:6300")

developmentMode

If true, allows HTTP to localhost (INSECURE - testing only)

Constructors

Link copied to clipboard
constructor(proofServerUrl: String = "http://localhost:6300", developmentMode: Boolean = true)

Convenience constructor for production use (creates default HTTP client).

constructor(httpClient: HttpClient, proofServerUrl: String = "http://localhost:6300", developmentMode: Boolean = true)

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open override fun close()

Close the client and release resources.

Link copied to clipboard
open suspend override fun isHealthy(): Boolean

Check if proof server is healthy and reachable.

Link copied to clipboard
open suspend override fun proveTransaction(unprovenTxHex: String): String

Prove an unproven transaction.