CashUtils.generateSpend - corda

corda / net.corda.finance.workflows.asset / CashUtils / generateSpend

# generateSpend

`@JvmStatic @Suspendable fun generateSpend(services: ServiceHub, tx: TransactionBuilder, amount: Amount<Currency>, to: AbstractParty, onlyFromParties: Set<AbstractParty> = emptySet()): Pair<TransactionBuilder, List<PublicKey>>`
Deprecated: Our identity should be specified

Generate a transaction that moves an amount of currency to the given party, and sends any change back to sole identity of the calling node. Fails for nodes with multiple identities.

Note: an Amount of Currency is only fungible for a given Issuer Party within a FungibleAsset

### Parameters

`services` - The ServiceHub to provide access to the database session.

`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` - the recipient party.

`onlyFromParties` - if non-null, the asset states will be filtered to only include those issued by the set of given parties. This can be useful if the party you're trying to pay has expectations about which type of asset claims they are willing to accept.

### Exceptions

`InsufficientBalanceException` - when a cash spending transaction fails because there is insufficient quantity for a given currency (and optionally set of Issuer Parties).

Return
A Pair of the same transaction builder passed in as tx, and the list of keys that need to sign the resulting transaction for it to be valid.

`@JvmStatic @JvmOverloads @Suspendable fun generateSpend(services: ServiceHub, tx: TransactionBuilder, amount: Amount<Currency>, ourIdentity: PartyAndCertificate, to: AbstractParty, onlyFromParties: Set<AbstractParty> = emptySet(), anonymous: Boolean = true): Pair<TransactionBuilder, List<PublicKey>>`

Generate a transaction that moves an amount of currency to the given party.

Note: an Amount of Currency is only fungible for a given Issuer Party within a FungibleAsset

### Parameters

`services` - The ServiceHub to provide access to the database session.

`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` - the recipient party.

`ourIdentity` - ourIdentity is used to determine the where the change will be sent. If anonymous is true then an anonymous identity will be generated from this and the change will be spent to that, otherwise ourIdentity will be used as is.

`onlyFromParties` - if non-null, the asset states will be filtered to only include those issued by the set of given parties. This can be useful if the party you're trying to pay has expectations about which type of asset claims they are willing to accept.

`anonymous` - whether or not to use CI to send the change to

### Exceptions

`InsufficientBalanceException` - when a cash spending transaction fails because there is insufficient quantity for a given currency (and optionally set of Issuer Parties).

Return
A Pair of the same transaction builder passed in as tx, and the list of keys that need to sign the resulting transaction for it to be valid.

`@JvmStatic @Suspendable fun generateSpend(services: ServiceHub, tx: TransactionBuilder, payments: List<PartyAndAmount<Currency>>, onlyFromParties: Set<AbstractParty> = emptySet()): Pair<TransactionBuilder, List<PublicKey>>`
Deprecated: Our identity should be specified

Generate a transaction that moves money of the given amounts to the recipients specified, and sends any change back to sole identity of the calling node. Fails for nodes with multiple identities.

Note: an Amount of Currency is only fungible for a given Issuer Party within a FungibleAsset

### Parameters

`services` - The ServiceHub to provide access to the database session.

`tx` - A builder, which may contain inputs, outputs and commands already. The relevant components needed to move the cash will be added on top.

`payments` - A list of amounts to pay, and the party to send the payment to.

`onlyFromParties` - if non-null, the asset states will be filtered to only include those issued by the set of given parties. This can be useful if the party you're trying to pay has expectations about which type of asset claims they are willing to accept.

### Exceptions

`InsufficientBalanceException` - when a cash spending transaction fails because there is insufficient quantity for a given currency (and optionally set of Issuer Parties).

Return
A Pair of the same transaction builder passed in as tx, and the list of keys that need to sign the resulting transaction for it to be valid.

`@JvmStatic @JvmOverloads @Suspendable fun generateSpend(services: ServiceHub, tx: TransactionBuilder, payments: List<PartyAndAmount<Currency>>, ourIdentity: PartyAndCertificate, onlyFromParties: Set<AbstractParty> = emptySet(), anonymous: Boolean = true): Pair<TransactionBuilder, List<PublicKey>>`

Generate a transaction that moves money of the given amounts to the recipients specified.

Note: an Amount of Currency is only fungible for a given Issuer Party within a FungibleAsset

### Parameters

`services` - The ServiceHub to provide access to the database session.

`tx` - A builder, which may contain inputs, outputs and commands already. The relevant components needed to move the cash will be added on top.

`payments` - A list of amounts to pay, and the party to send the payment to.

`ourIdentity` - ourIdentity is used to determine the where the change will be sent. If anonymous is true then an anonymous identity will be generated from this and the change will be spent to that, otherwise ourIdentity will be used as is.

`onlyFromParties` - if non-null, the asset states will be filtered to only include those issued by the set of given parties. This can be useful if the party you're trying to pay has expectations about which type of asset claims they are willing to accept.

`anonymous` - whether or not to use CI to send the change to

### Exceptions

`InsufficientBalanceException` - when a cash spending transaction fails because there is insufficient quantity for a given currency (and optionally set of Issuer Parties).

Return
A Pair of the same transaction builder passed in as tx, and the list of keys that need to sign the resulting transaction for it to be valid.