0
votes

I have implemented the user interaction flow described here: Corda: User interaction for verifying the transaction request received from the initiator node.

As the proposer, how can I check whether the transaction is accepted or rejected?

1

1 Answers

0
votes

You can use an RPC client such as the following:

fun main(args: Array<String>) {
    val nodeAddress = parse(args[0])
    val client = CordaRPCClient(nodeAddress)
    val proxy = client.start("user1", "test").proxy

    // Observe FooState updates from the vault.
    val (_, updates) = proxy.vaultTrack(FooState::class.java)

    // Check each update.
    updates.toBlocking().subscribe { update ->

        // If the update produced a state with the `accepted` flag, the proposal was accepted.
        if (update.produced.size == 1 && update.produced.single().state.data.accepted) {
            logger.info("Proposal was accepted.")

        // If the update didn't produce a state, the proposal was rejected.
        } else if (update.produced.isEmpty()) {
            logger.info("Proposal was rejected.")
        }
    }
}