tryLockFungibleStatesForSpending

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.

Return

Returns a locked subset of the eligibleStatesQuery sufficient to satisfy the requested amount, or else an empty list and no change in the stored lock states when their are insufficient resources available.

Parameters

lockId

The FlowLogic.runId's UUID of the current flow used to soft lock the states.

eligibleStatesQuery

A custom query object that selects down to the appropriate subset of all states of the contractStateType. e.g. by selecting on account, issuer, etc. The query is internally augmented with the StateStatus.UNCONSUMED, soft lock and contract type requirements.

amount

The required amount of the asset. It is assumed that compatible issuer states will be filtered out by the eligibleStatesQuery. This method accepts both Amount> and Amount<>. Amount> is automatically unwrapped to Amount<>.

contractStateType

class type of the result set.