Package-level declarations

Types

Link copied to clipboard
sealed class Cap

Single cap evaluated against an estimated spend.

Link copied to clipboard
interface ChainAccount

On-chain account owned by a Trusted Domain on one specific chain.

Link copied to clipboard
interface DomainTreasury

The domain-scoped on-chain payment authority. Owns:

Link copied to clipboard
class InMemoryChainAccount(val chainId: String, val address: String, val keyRef: KmsKeyRef, anchorClient: BlockchainAnchorClient, kms: KeyManagementService) : ChainAccount

Phase 2 in-memory ChainAccount adapter.

Link copied to clipboard
class InMemoryDomainTreasury(val domainId: DomainId, accounts: Map<String, ChainAccount>, spendPolicy: SpendPolicy = SpendPolicy.DEFAULT, store: TreasuryLedgerStore = InMemoryTreasuryLedgerStore(), config: TreasuryConfig = TreasuryConfig(), eventSink: DomainEventSink = NoopDomainEventSink) : DomainTreasury

Reference DomainTreasury implementation. In-memory reservation accounting over a swappable TreasuryLedgerStore. Production deployments may swap the store for a durable backend; the reservation lock state is volatile by design — reservations are short-lived (default 30 min) and orphaned ones expire harmlessly.

Link copied to clipboard

In-memory implementation of TreasuryLedgerStore. Default for tests and for the testkit module. Production deployments swap in a SQL-backed store (separate module — out of scope for Phase 1).

Link copied to clipboard
data class KmsKeyRef(val kmsId: String, val keyId: String)

Opaque reference to a key held in the configured KMS. The treasury layer resolves this against a org.trustweave.kms.KeyManagementService at signing time; the key material never crosses module boundaries.

Link copied to clipboard
data class PolicyEvaluationContext(val now: Instant, val windowStates: List<SpendPolicy.WindowState>)

Lightweight projection of treasury ledger state used by policy evaluation. Returned by TreasuryLedger.windowState and consumed by the treasury when deciding whether a Cap.PerWindow is exhausted.

Link copied to clipboard
data class Reservation(val id: String, val domainId: DomainId, val chainId: String, val locked: TokenAmount, val correlationId: String, val createdAt: Instant, val ttl: Duration = DEFAULT_TTL)

Handle returned by DomainTreasury.reserve. Captures the amount locked against a ChainAccount for the duration of a single ledger-touching operation. The reservation must be settled or cancelled — orphaned reservations are auto-cancelled after their ttl.

Link copied to clipboard
Link copied to clipboard
data class SignedTx(val chainId: String, val bytes: ByteArray)
Link copied to clipboard
data class SpendPolicy(val caps: List<Cap> = emptyList(), val allowedStrategies: Set<KClass<out FeeStrategy>> = setOf( FeeStrategy.DomainPays::class, ), val requireSponsorAllowList: Boolean = false, val sponsorAllowList: Set<String> = emptySet())

The set of rules a domain treasury evaluates at reserve time. Exhausting any cap raises org.trustweave.anchor.exceptions.TreasuryException.CapExceeded before the operation reaches the SPI — never silently degraded.

Link copied to clipboard
data class TreasuryConfig(val safetyMarginNumerator: Int = 11, val safetyMarginDenominator: Int = 10, val reservationTtl: Duration = Reservation.DEFAULT_TTL, val clock: Clock = Clock.System)

Clock + safety-margin knobs lifted out of the interface so production deployments can tune them without subclassing.

Link copied to clipboard

Read view over a domain's ledger, exposed to callers and to policy evaluation. Backed by a TreasuryLedgerStore.

Link copied to clipboard
@Serializable
data class TreasuryLedgerEntry(val correlationId: String, val domainId: String, val payerDid: String, val chainId: String, val operation: String, val estimatedFeeAmount: String, val actualFeeAmount: String, val asset: String, val txHash: String? = null, val status: SettlementStatus, val atEpochMillis: Long)

Append-only audit entry for one ledger-touching operation. The treasury writes one entry per reservation (RESERVED), then updates it in place with the terminal status (SETTLED / CANCELLED / FAILED).

Link copied to clipboard

The treasury-facing read/write port. Concrete stores plug in via the TrustedDomainManager config — default is JSONL on local disk, optional is SQL/Postgres for SaaS deployments.

Link copied to clipboard
data class UnsignedTx(val chainId: String, val bytes: ByteArray, val domainSeparation: String? = null)

Opaque unsigned transaction handed from a plugin to a ChainAccount for signing. The plugin populates bytes with chain-canonical encoded form (RLP, MsgPack, CBOR, PSBT — chain's choice).