corda / net.corda.core.node.services / VaultService / generateSpend

# generateSpend

`abstract fun generateSpend(tx: TransactionBuilder, amount: Amount<Currency>, to: CompositeKey, onlyFromParties: Set<AbstractParty>? = null): Pair<TransactionBuilder, List<CompositeKey>>`

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

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

### Parameters

`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.

`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.