public static class OnLedgerAsset.Companion
@JvmStatic @NotNull public <S extends FungibleAsset<T>,T> kotlin.Pair<net.corda.core.transactions.TransactionBuilder,java.util.List> generateSpend(@NotNull TransactionBuilder tx, @NotNull Amount<T> amount, @NotNull AbstractParty to, @NotNull java.util.List<? extends net.corda.core.contracts.StateAndRef<? extends S>> acceptableStates, @NotNull AbstractParty payChangeTo, @NotNull kotlin.jvm.functions.Function3<? super net.corda.core.contracts.TransactionState<? extends S>,? super net.corda.core.contracts.Amount<net.corda.core.contracts.Issued<T>>,? super net.corda.core.identity.AbstractParty,? extends net.corda.core.contracts.TransactionState<? extends S>> deriveState, @NotNull kotlin.jvm.functions.Function0<? extends net.corda.core.contracts.CommandData> generateMoveCommand)
Generate a transaction that moves an amount of currency to the given pubkey.
Note: an class Amount
of Currency is only fungible for a given Issuer Party within a interface FungibleAsset
tx
- A builder, which may contain inputs, outputs and commands already. The relevant components needed to move the cash will be added on top.amount
- How much currency to send.to
- a key of the recipient.acceptableStates
- a list of acceptable input states to use.payChangeTo
- party to pay any change to; this is normally a confidential identity of the callingparty.deriveState
- a function to derive an output state based on an input state, amount for the outputand public key to pay to.tx
, and the list of keys that need to sign
the resulting transaction for it to be valid.InsufficientBalanceException
- when a cash spending transaction fails because
there is insufficient quantity for a given currency (and optionally set of Issuer Parties).class Amount
,
Currency,
interface FungibleAsset
@JvmStatic @NotNull public <S extends FungibleAsset<T>,T> kotlin.Pair<net.corda.core.transactions.TransactionBuilder,java.util.List> generateSpend(@NotNull TransactionBuilder tx, @NotNull java.util.List<net.corda.finance.contracts.asset.PartyAndAmount> payments, @NotNull java.util.List<? extends net.corda.core.contracts.StateAndRef<? extends S>> acceptableStates, @NotNull AbstractParty payChangeTo, @NotNull kotlin.jvm.functions.Function3<? super net.corda.core.contracts.TransactionState<? extends S>,? super net.corda.core.contracts.Amount<net.corda.core.contracts.Issued<T>>,? super net.corda.core.identity.AbstractParty,? extends net.corda.core.contracts.TransactionState<? extends S>> deriveState, @NotNull kotlin.jvm.functions.Function0<? extends net.corda.core.contracts.CommandData> generateMoveCommand)
Adds to the given transaction states that move amounts of a fungible asset to the given parties, using only the provided acceptable input states to find a solution (not all of them may be used in the end). A change output will be generated if the state amounts don't exactly fit.
The fungible assets must all be of the same type and the amounts must be summable i.e. amounts of the same token.
S
- A fungible asset state type
T
- A type representing a token
tx
- A builder, which may contain inputs, outputs and commands already. The relevant components needed to move the cash will be added on top.acceptableStates
- a list of acceptable input states to use.payChangeTo
- party to pay any change to; this is normally a confidential identity of the callingparty. We use a new confidential identity here so that the recipient is not identifiable.deriveState
- a function to derive an output state based on an input state, amount for the outputand public key to pay to.tx
, and the list of keys that need to sign
the resulting transaction for it to be valid.InsufficientBalanceException
- when a cash spending transaction fails because
there is insufficient quantity for a given currency (and optionally set of Issuer Parties).@JvmStatic @Deprecated @NotNull public <S extends FungibleAsset<T>,T> java.util.Set<java.security.PublicKey> generateExit(@NotNull TransactionBuilder tx, @NotNull Amount<net.corda.core.contracts.Issued> amountIssued, @NotNull java.util.List<? extends net.corda.core.contracts.StateAndRef<? extends S>> assetStates, @NotNull kotlin.jvm.functions.Function3<? super net.corda.core.contracts.TransactionState<? extends S>,? super net.corda.core.contracts.Amount<net.corda.core.contracts.Issued<T>>,? super net.corda.core.identity.AbstractParty,? extends net.corda.core.contracts.TransactionState<? extends S>> deriveState, @NotNull kotlin.jvm.functions.Function0<? extends net.corda.core.contracts.CommandData> generateMoveCommand, @NotNull kotlin.jvm.functions.Function1<? super net.corda.core.contracts.Amount<net.corda.core.contracts.Issued<T>>,? extends net.corda.core.contracts.CommandData> generateExitCommand)
Generate an transaction exiting fungible assets from the ledger.
tx
- transaction builder to add states and commands to.amountIssued
- the amount to be exited, represented as a quantity of issued currency.assetStates
- the asset states to take funds from. No checks are done about ownership of these states, it isthe responsibility of the caller to check that they do not attempt to exit funds held by others.@JvmStatic @NotNull public <S extends FungibleAsset<T>,T> java.util.Set<java.security.PublicKey> generateExit(@NotNull TransactionBuilder tx, @NotNull Amount<net.corda.core.contracts.Issued> amountIssued, @NotNull java.util.List<? extends net.corda.core.contracts.StateAndRef<? extends S>> assetStates, @NotNull AbstractParty payChangeTo, @NotNull kotlin.jvm.functions.Function3<? super net.corda.core.contracts.TransactionState<? extends S>,? super net.corda.core.contracts.Amount<net.corda.core.contracts.Issued<T>>,? super net.corda.core.identity.AbstractParty,? extends net.corda.core.contracts.TransactionState<? extends S>> deriveState, @NotNull kotlin.jvm.functions.Function0<? extends net.corda.core.contracts.CommandData> generateMoveCommand, @NotNull kotlin.jvm.functions.Function1<? super net.corda.core.contracts.Amount<net.corda.core.contracts.Issued<T>>,? extends net.corda.core.contracts.CommandData> generateExitCommand)
Generate an transaction exiting fungible assets from the ledger.
tx
- transaction builder to add states and commands to.amountIssued
- the amount to be exited, represented as a quantity of issued currency.assetStates
- the asset states to take funds from. No checks are done about ownership of these states, it isthe responsibility of the caller to check that they do not attempt to exit funds held by others.payChangeTo
- party to pay any change to; this is normally a confidential identity of the callingparty.@JvmStatic @NotNull public <S extends FungibleAsset<T>,T> java.util.Set<java.security.PublicKey> generateIssue(@NotNull TransactionBuilder tx, @NotNull TransactionState<? extends S> transactionState, @NotNull CommandData issueCommand)
Puts together an issuance transaction for the specified state. Normally contracts will provide convenient wrappers around this function, which build the state for you, and those should be used in preference.