TrustedDomainManager

class TrustedDomainManager(val domainId: DomainId, val payerDid: String, treasury: DomainTreasury, registry: BlockchainAnchorRegistry, eventSink: DomainEventSink = NoopDomainEventSink)

Orchestrates the payment plane for one Trusted Domain. The single broker between caller code and the anchor SPI: every ledger-touching operation that should be billed to a domain treasury flows through anchor.

Lifecycle of one call (see the design doc, §6):

  1. resolve the active DomainTreasury for domainId

  2. pick a FeeStrategy (caller-supplied, defaults to DomainPays)

  3. estimate the fee against the corresponding BlockchainAnchorClient

  4. enforce caller-cap, per-op cap, per-window cap, sponsor allow-list (delegated to DomainTreasury.reserve)

  5. reserve funds → handed-down PaymentContext

  6. call client.writePayload(payload, ctx)

  7. settle on success (or cancel on failure)

Construction takes one treasury per domain; multi-tenant deployments wrap this in a registry keyed by DomainId.

Constructors

Link copied to clipboard
constructor(domainId: DomainId, payerDid: String, treasury: DomainTreasury, registry: BlockchainAnchorRegistry, eventSink: DomainEventSink = NoopDomainEventSink)

Properties

Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
suspend fun anchor(operationKind: String, chainId: String, payload: JsonElement, feeStrategy: FeeStrategy = FeeStrategy.DomainPays, maxFee: TokenAmount? = null, mediaType: String = "application/json"): AnchorResult

Anchor payload on chainId paid for by this domain's treasury (by default). Returns the AnchorResult from the underlying plugin; the fee actually charged is reflected on the result and in the treasury ledger.

Link copied to clipboard

Direct access to the underlying treasury — for inspection / dashboards.