TransactionSubmitter

class TransactionSubmitter(nodeRpcClient: NodeRpcClient, proofServerClient: ProofServerClient, indexerClient: IndexerClient, serializer: TransactionSerializer, utxoManager: UtxoManager, dustActionsBuilder: DustActionsBuilder? = null, dustRepository: DustRepository? = null, provingKeyManager: <Error class: unknown class>? = null, var provingMode: <Error class: unknown class> = ProvingMode.DEFAULT, networkClientProvider: TransactionSubmitter.NetworkClientProvider? = null)

Orchestrates transaction submission and confirmation for Midnight blockchain.

Process (WebSocket-based - the correct way):

  1. Serialize signed transaction (SCALE codec)

  2. Prove transaction via proof server

  3. Seal proven transaction

  4. Submit via WebSocket and wait for finalization from NODE

  5. Mark UTXOs as SPENT only after node confirms finalization

  6. Return result

Why WebSocket instead of Indexer:

  • Indexer can lag behind the node (causes race conditions)

  • WebSocket gives us real-time confirmation directly from the node

  • This matches the Midnight SDK's implementation exactly

Dust Fee Payment: Use submitWithFees() to automatically build and pay dust fees.

Constructors

Link copied to clipboard
constructor(nodeRpcClient: NodeRpcClient, proofServerClient: ProofServerClient, indexerClient: IndexerClient, serializer: TransactionSerializer, utxoManager: UtxoManager, dustActionsBuilder: DustActionsBuilder? = null, dustRepository: DustRepository? = null, provingKeyManager: <Error class: unknown class>? = null, provingMode: <Error class: unknown class> = ProvingMode.DEFAULT, networkClientProvider: TransactionSubmitter.NetworkClientProvider? = null)

Types

Link copied to clipboard
object Companion
Link copied to clipboard
fun interface NetworkClientProvider

Functional interface for resolving network-aware clients. Injected by the Hilt module; creates fresh clients for the currently-selected network.

Link copied to clipboard
data class ResolvedClients(val networkId: String, val node: NodeRpcClient, val proofServer: ProofServerClient, val indexer: IndexerClient)

Clients bound to a specific network, identified by networkId. The networkId is used for cache-invalidation: when the user switches networks in Settings, the next resolveClients call detects the name change and creates fresh HTTP clients.

Link copied to clipboard
sealed class SubmissionResult

Result of transaction submission.

Properties

Link copied to clipboard
var lastProvingMode: <Error class: unknown class>

Which proving mode was used for the last transaction (for display).

Link copied to clipboard
var provingMode: <Error class: unknown class>

Current proving mode — LOCAL or REMOTE. Defaults to LOCAL when keys are available.

Functions

Link copied to clipboard
suspend fun submitAndWait(signedIntent: Intent, fromAddress: String, timeoutMs: Long = DEFAULT_TIMEOUT_MS): TransactionSubmitter.SubmissionResult

Submit a signed transaction and wait for finalization.

Link copied to clipboard
suspend fun submitOnly(signedIntent: Intent): String

Submit transaction without waiting for confirmation (fire-and-forget).

Link copied to clipboard
suspend fun submitPrebuiltTransaction(unprovenTxHex: String, timeoutMs: Long = DEFAULT_TIMEOUT_MS): TransactionSubmitter.SubmissionResult

Submit a pre-built unproven transaction (e.g., from ZswapTransferBuilder).

Link copied to clipboard
suspend fun submitWithFees(signedIntent: Intent, ledgerParamsHex: String, fromAddress: String, seed: ByteArray, timeoutMs: Long = DEFAULT_TIMEOUT_MS): TransactionSubmitter.SubmissionResult

Submit transaction WITH automatic dust fee payment.