Joel
Joel

Reputation: 23140

In Corda, how can I see pending transactions in uncompleted flows?

In Corda, suppose I am running a flow that creates a transaction. I have signed the transaction, but now the flow is suspended waiting for the counterparty to sign.

Is there any way for me to see a list of transactions that are pending in this way?

Upvotes: 0

Views: 190

Answers (1)

Joel
Joel

Reputation: 23140

As of Corda 3, you cannot see the contents of these transactions.

However, you can use flow progress-tracker steps to find out where each flow is in its lifecyle. For example, you could count the number of flows that are paused at some user-defined Transaction is pending. progress-tracker step as follows:

class Client {
    val proxy: CordaRPCOps

    init {
        val nodeAddress = NetworkHostAndPort.parse("localhost:10006")
        val client = CordaRPCClient(nodeAddress)
        proxy = client.start("user1", "test").proxy
    }

    fun currentNumberOfPendingTxs(): Int {
        val stateMachineInfos = proxy.stateMachinesSnapshot()
        val stateMachinesPendingTxs = stateMachineInfos.filter { info ->
            val progressTracker = info.progressTrackerStepAndUpdates
            if (progressTracker == null) {
                false
            } else {
                progressTracker.snapshot == "Transaction is pending."
            }
        }
        return stateMachinesPendingTxs.size
    }
}

Upvotes: 1

Related Questions