diff --git a/node/src/main/kotlin/com/r3corda/node/internal/ServerRPCOps.kt b/node/src/main/kotlin/com/r3corda/node/internal/ServerRPCOps.kt index 13286064c4..ab3c5643ca 100644 --- a/node/src/main/kotlin/com/r3corda/node/internal/ServerRPCOps.kt +++ b/node/src/main/kotlin/com/r3corda/node/internal/ServerRPCOps.kt @@ -63,14 +63,20 @@ class ServerRPCOps( val builder: TransactionBuilder = TransactionType.General.Builder(null) // TODO: Have some way of restricting this to states the caller controls try { - Cash().generateSpend(builder, req.amount.withoutIssuer(), req.recipient.owningKey, - // TODO: Move cash state filtering by issuer down to the contract itself - services.vaultService.currentVault.statesOfType().filter { it.state.data.amount.token == req.amount.token }, - setOf(req.amount.token.issuer.party)) - .forEach { - val key = services.keyManagementService.keys[it] ?: throw IllegalStateException("Could not find signing key for ${it.toStringShort()}") - builder.signWith(KeyPair(it, key)) - } + val vaultCashStates = services.vaultService.currentVault.statesOfType() + // TODO: Move cash state filtering by issuer down to the contract itself + val cashStatesOfRightCurrency = vaultCashStates.filter { it.state.data.amount.token == req.amount.token } + val keysForSigning = Cash().generateSpend( + tx = builder, + amount = req.amount.withoutIssuer(), + to = req.recipient.owningKey, + assetsStates = cashStatesOfRightCurrency, + onlyFromParties = setOf(req.amount.token.issuer.party) + ) + keysForSigning.forEach { + val key = services.keyManagementService.keys[it] ?: throw IllegalStateException("Could not find signing key for ${it.toStringShort()}") + builder.signWith(KeyPair(it, key)) + } val tx = builder.toSignedTransaction(checkSufficientSignatures = false) val protocol = FinalityProtocol(tx, setOf(req), setOf(req.recipient)) return TransactionBuildResult.ProtocolStarted( diff --git a/node/src/main/kotlin/com/r3corda/node/services/messaging/CordaRPCOps.kt b/node/src/main/kotlin/com/r3corda/node/services/messaging/CordaRPCOps.kt index de263fc8df..1bf0740629 100644 --- a/node/src/main/kotlin/com/r3corda/node/services/messaging/CordaRPCOps.kt +++ b/node/src/main/kotlin/com/r3corda/node/services/messaging/CordaRPCOps.kt @@ -97,7 +97,8 @@ interface CordaRPCOps : RPCOps { fun verifiedTransactions(): Pair, Observable> /** - * Returns a pair of state machine id - recorded transaction hash pairs + * Returns a snapshot list of existing state machine id - recorded transaction hash mappings, and a stream of future + * such mappings as well. */ @RPCReturnsObservables fun stateMachineRecordedTransactionMapping(): Pair, Observable>