node: Address review comments

This commit is contained in:
Andras Slemmer
2016-09-30 16:20:21 +01:00
parent 5af0e97444
commit 8e471c6768
2 changed files with 16 additions and 9 deletions

View File

@ -63,14 +63,20 @@ class ServerRPCOps(
val builder: TransactionBuilder = TransactionType.General.Builder(null) val builder: TransactionBuilder = TransactionType.General.Builder(null)
// TODO: Have some way of restricting this to states the caller controls // TODO: Have some way of restricting this to states the caller controls
try { try {
Cash().generateSpend(builder, req.amount.withoutIssuer(), req.recipient.owningKey, val vaultCashStates = services.vaultService.currentVault.statesOfType<Cash.State>()
// TODO: Move cash state filtering by issuer down to the contract itself // TODO: Move cash state filtering by issuer down to the contract itself
services.vaultService.currentVault.statesOfType<Cash.State>().filter { it.state.data.amount.token == req.amount.token }, val cashStatesOfRightCurrency = vaultCashStates.filter { it.state.data.amount.token == req.amount.token }
setOf(req.amount.token.issuer.party)) val keysForSigning = Cash().generateSpend(
.forEach { tx = builder,
val key = services.keyManagementService.keys[it] ?: throw IllegalStateException("Could not find signing key for ${it.toStringShort()}") amount = req.amount.withoutIssuer(),
builder.signWith(KeyPair(it, key)) 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 tx = builder.toSignedTransaction(checkSufficientSignatures = false)
val protocol = FinalityProtocol(tx, setOf(req), setOf(req.recipient)) val protocol = FinalityProtocol(tx, setOf(req), setOf(req.recipient))
return TransactionBuildResult.ProtocolStarted( return TransactionBuildResult.ProtocolStarted(

View File

@ -97,7 +97,8 @@ interface CordaRPCOps : RPCOps {
fun verifiedTransactions(): Pair<List<SignedTransaction>, Observable<SignedTransaction>> fun verifiedTransactions(): Pair<List<SignedTransaction>, Observable<SignedTransaction>>
/** /**
* 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 @RPCReturnsObservables
fun stateMachineRecordedTransactionMapping(): Pair<List<StateMachineTransactionMapping>, Observable<StateMachineTransactionMapping>> fun stateMachineRecordedTransactionMapping(): Pair<List<StateMachineTransactionMapping>, Observable<StateMachineTransactionMapping>>