From c0238b1f21288456a22c8b0752ae0ca1f7be27c5 Mon Sep 17 00:00:00 2001 From: Mike Hearn Date: Fri, 6 Nov 2015 12:59:52 +0100 Subject: [PATCH] Cash: add a TODO comment --- src/Cash.kt | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Cash.kt b/src/Cash.kt index 66bead9104..f37f6cfd2e 100644 --- a/src/Cash.kt +++ b/src/Cash.kt @@ -1,5 +1,4 @@ import java.security.PublicKey -import java.util.* ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // @@ -85,7 +84,12 @@ object CashContract : Contract { val inputAmount = inputs.map { it.amount }.sum() val outputAmount = outputs.map { it.amount }.sumOrZero(currency) - val issuerCommand = args.filter { it.signingInstitution == deposit.institution }.map { it.command as? ExitCashCommand }.filterNotNull().singleOrNull() + val issuerCommand = args. + filter { it.signingInstitution == deposit.institution }. + // TODO: this map+filterNotNull pattern will become a single function in the next Kotlin beta. + map { it.command as? ExitCashCommand }. + filterNotNull(). + singleOrNull() val amountExitingLedger = issuerCommand?.amount ?: Amount(0, inputAmount.currency) requireThat { @@ -100,11 +104,16 @@ object CashContract : Contract { // data by the platform before execution. val owningPubKeys = cashInputs.map { it.owner }.toSortedSet() val keysThatSigned = args.filter { it.command is MoveCashCommand }.map { it.signer }.toSortedSet() - requireThat { "the owning keys are the same as the signing keys" by (owningPubKeys == keysThatSigned) } + requireThat { + "the owning keys are the same as the signing keys" by (owningPubKeys == keysThatSigned) + } // Accept. } + // TODO: craftSpend should work more like in bitcoinj, where it takes and modifies a transaction template. + // This would allow multiple contracts to compose properly (e.g. bond trade+cash movement). + /** Generate a transaction that consumes one or more of the given input states to move money to the given pubkey. */ @Throws(InsufficientBalanceException::class) fun craftSpend(amount: Amount, to: PublicKey, wallet: List): TransactionForTest {