VaultService

A VaultService is responsible for securely and safely persisting the current state of a vault to storage. The vault service vends immutable snapshots of the current vault for working with: if you build a transaction based on a vault that isn't current, be aware that it may end up being invalid if the states that were used have been consumed by someone else first!

Note that transactions we've seen are held by the storage service, not the vault.

Properties

Link copied to clipboard
abstract val rawUpdates: <Error class: unknown class><Vault.Update<ContractState>>

Prefer the use of updates unless you know why you want to use this instead.

Link copied to clipboard
abstract val updates: <Error class: unknown class><Vault.Update<ContractState>>

Get a synchronous Observable of updates. When observations are pushed to the Observer, the Vault will already incorporate the update and the database transaction associated with the update will have been committed and closed.

Functions

Link copied to clipboard
abstract fun <T : ContractState> _queryBy(criteria: QueryCriteria, paging: PageSpecification, sorting: Sort, contractStateType: Class<out T>): Vault.Page<T>

Generic vault query function which takes a QueryCriteria object to define filters, optional PageSpecification and optional Sort modification criteria (default unsorted), and returns a Vault.Page object containing the following:

Link copied to clipboard
abstract fun <T : ContractState> _trackBy(criteria: QueryCriteria, paging: PageSpecification, sorting: Sort, contractStateType: Class<out T>): DataFeed<Vault.Page<T>, Vault.Update<T>>

Generic vault query function which takes a QueryCriteria object to define filters, optional PageSpecification and optional Sort modification criteria (default unsorted), and returns a DataFeed object containing:

Link copied to clipboard
abstract fun addNoteToTransaction(txnId: SecureHash, noteText: String)

Add a note to an existing LedgerTransaction given by its unique SecureHash id. Multiple notes may be attached to the same LedgerTransaction. These are additively and immutably persisted within the node local vault database in a single textual field. using a semi-colon separator.

Link copied to clipboard
Link copied to clipboard
open fun <T : ContractState> queryBy(contractStateType: Class<out T>): Vault.Page<T>
open fun <T : ContractState> queryBy(contractStateType: Class<out T>, paging: PageSpecification): Vault.Page<T>
open fun <T : ContractState> queryBy(contractStateType: Class<out T>, criteria: QueryCriteria): Vault.Page<T>
open fun <T : ContractState> queryBy(contractStateType: Class<out T>, criteria: QueryCriteria, paging: PageSpecification): Vault.Page<T>
open fun <T : ContractState> queryBy(contractStateType: Class<out T>, criteria: QueryCriteria, sorting: Sort): Vault.Page<T>
open fun <T : ContractState> queryBy(contractStateType: Class<out T>, criteria: QueryCriteria, paging: PageSpecification, sorting: Sort): Vault.Page<T>
Link copied to clipboard
Link copied to clipboard
abstract fun softLockRelease(lockId: UUID, stateRefs: NonEmptySet<StateRef>? = null)

Release all or an explicitly specified set of StateRef for a given UUID unique identifier. A Vault soft-lock manager is automatically notified from flows that are terminated, such that any soft locked states may be released. In the case of coin selection, soft-locks are automatically released once previously gathered unconsumed input refs are consumed as part of cash spending.

Link copied to clipboard
abstract fun softLockReserve(lockId: UUID, stateRefs: NonEmptySet<StateRef>)

Reserve a set of StateRef for a given UUID unique identifier. Typically, the unique identifier will refer to a FlowLogic.runId's UUID associated with an in-flight flow. In this case if the flow terminates the locks will automatically be freed, even if there is an error. However, the user can specify their own UUID and manage this manually, possibly across the lifetime of multiple flows, or from other thread contexts e.g. CordaService instances. In the case of coin selection, soft locks are automatically taken upon gathering relevant unconsumed input refs.

Link copied to clipboard
open fun <T : ContractState> trackBy(contractStateType: Class<out T>): DataFeed<Vault.Page<T>, Vault.Update<T>>
open fun <T : ContractState> trackBy(contractStateType: Class<out T>, paging: PageSpecification): DataFeed<Vault.Page<T>, Vault.Update<T>>
open fun <T : ContractState> trackBy(contractStateType: Class<out T>, criteria: QueryCriteria): DataFeed<Vault.Page<T>, Vault.Update<T>>
open fun <T : ContractState> trackBy(contractStateType: Class<out T>, criteria: QueryCriteria, paging: PageSpecification): DataFeed<Vault.Page<T>, Vault.Update<T>>
open fun <T : ContractState> trackBy(contractStateType: Class<out T>, criteria: QueryCriteria, sorting: Sort): DataFeed<Vault.Page<T>, Vault.Update<T>>
open fun <T : ContractState> trackBy(contractStateType: Class<out T>, criteria: QueryCriteria, paging: PageSpecification, sorting: Sort): DataFeed<Vault.Page<T>, Vault.Update<T>>
Link copied to clipboard
abstract fun <T : FungibleState<*>> tryLockFungibleStatesForSpending(lockId: UUID, eligibleStatesQuery: QueryCriteria, amount: Amount<*>, contractStateType: Class<out T>): List<StateAndRef<T>>

Helper function to determine spendable states and soft locking them. Currently performance will be worse than for the hand optimised version in net.corda.finance.workflows.asset.selection.AbstractCashSelection.unconsumedCashStatesForSpending. However, this is fully generic and can operate with custom FungibleState and FungibleAsset states.

Link copied to clipboard

Provide a CordaFuture for when a StateRef is consumed, which can be very useful in building tests.