mirror of
https://github.com/corda/corda.git
synced 2025-01-03 19:54:13 +00:00
Add new RPC operation getCashBalances() to Node.
This commit is contained in:
parent
cd5dde70e0
commit
4cc377cbf4
@ -65,4 +65,14 @@ class CordaRPCClientTest : DriverBasedTest() {
|
|||||||
}
|
}
|
||||||
println("Result: ${flowHandle.returnValue.toBlocking().first()}")
|
println("Result: ${flowHandle.returnValue.toBlocking().first()}")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun `get cash balances`() {
|
||||||
|
println("Starting client")
|
||||||
|
client.start(rpcUser.username, rpcUser.password)
|
||||||
|
println("Creating proxy")
|
||||||
|
val proxy = client.proxy()
|
||||||
|
val cash = proxy.getCashBalances()
|
||||||
|
println("Cash Balances: $cash")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.corda.core.messaging
|
package net.corda.core.messaging
|
||||||
|
|
||||||
|
import net.corda.core.contracts.Amount
|
||||||
import net.corda.core.contracts.ContractState
|
import net.corda.core.contracts.ContractState
|
||||||
import net.corda.core.contracts.StateAndRef
|
import net.corda.core.contracts.StateAndRef
|
||||||
import net.corda.core.crypto.CompositeKey
|
import net.corda.core.crypto.CompositeKey
|
||||||
@ -15,6 +16,7 @@ import net.corda.core.transactions.SignedTransaction
|
|||||||
import rx.Observable
|
import rx.Observable
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
data class StateMachineInfo(
|
data class StateMachineInfo(
|
||||||
val id: StateMachineRunId,
|
val id: StateMachineRunId,
|
||||||
@ -92,6 +94,12 @@ interface CordaRPCOps : RPCOps {
|
|||||||
*/
|
*/
|
||||||
fun getVaultTransactionNotes(txnId: SecureHash): Iterable<String>
|
fun getVaultTransactionNotes(txnId: SecureHash): Iterable<String>
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Returns a map of how much cash we have in each currency, ignoring details like issuer. Note: currencies for
|
||||||
|
* which we have no cash evaluate to null (not present in map), not 0.
|
||||||
|
*/
|
||||||
|
fun getCashBalances(): Map<Currency, Amount<Currency>>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether an attachment with the given hash is stored on the node.
|
* Checks whether an attachment with the given hash is stored on the node.
|
||||||
*/
|
*/
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package net.corda.node.internal
|
package net.corda.node.internal
|
||||||
|
|
||||||
|
import net.corda.core.contracts.Amount
|
||||||
import net.corda.core.contracts.ContractState
|
import net.corda.core.contracts.ContractState
|
||||||
import net.corda.core.contracts.StateAndRef
|
import net.corda.core.contracts.StateAndRef
|
||||||
import net.corda.core.crypto.CompositeKey
|
import net.corda.core.crypto.CompositeKey
|
||||||
@ -27,6 +28,7 @@ import org.jetbrains.exposed.sql.Database
|
|||||||
import rx.Observable
|
import rx.Observable
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
import java.time.Instant
|
import java.time.Instant
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Server side implementations of RPCs available to MQ based client tools. Execution takes place on the server
|
* Server side implementations of RPCs available to MQ based client tools. Execution takes place on the server
|
||||||
@ -90,6 +92,12 @@ class CordaRPCOpsImpl(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun getCashBalances(): Map<Currency, Amount<Currency>> {
|
||||||
|
return databaseTransaction(database) {
|
||||||
|
services.vaultService.cashBalances
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Check that this flow is annotated as being intended for RPC invocation
|
// TODO: Check that this flow is annotated as being intended for RPC invocation
|
||||||
override fun <T : Any> startFlowDynamic(logicType: Class<out FlowLogic<T>>, vararg args: Any?): FlowHandle<T> {
|
override fun <T : Any> startFlowDynamic(logicType: Class<out FlowLogic<T>>, vararg args: Any?): FlowHandle<T> {
|
||||||
requirePermission(startFlowPermission(logicType))
|
requirePermission(startFlowPermission(logicType))
|
||||||
|
@ -175,6 +175,7 @@ private class RPCKryo(observableSerializer: Serializer<Observable<Any>>? = null)
|
|||||||
register(UUID::class.java)
|
register(UUID::class.java)
|
||||||
register(UniqueIdentifier::class.java)
|
register(UniqueIdentifier::class.java)
|
||||||
register(LinkedHashSet::class.java)
|
register(LinkedHashSet::class.java)
|
||||||
|
register(HashMap::class.java)
|
||||||
register(StateAndRef::class.java)
|
register(StateAndRef::class.java)
|
||||||
register(setOf<Unit>().javaClass) // EmptySet
|
register(setOf<Unit>().javaClass) // EmptySet
|
||||||
register(StateRef::class.java)
|
register(StateRef::class.java)
|
||||||
|
Loading…
Reference in New Issue
Block a user