mirror of
https://github.com/corda/corda.git
synced 2024-12-19 21:17:58 +00:00
Cash: add a TODO comment
This commit is contained in:
parent
aeca56df72
commit
c0238b1f21
15
src/Cash.kt
15
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<CashState>): TransactionForTest {
|
||||
|
Loading…
Reference in New Issue
Block a user