Corda: User interaction for verifying the transaction request received from the initiator node

半腔热情 提交于 2019-12-20 05:31:53

问题


We have a use case which requires the following steps: (1) Initiator triggers the transaction flow through UI (2) The flow is initiated, signed by the initiator and sent to recipient for his verification and signatures (in Corda) (3) The initiator's flow should get suspended until the recipient validates the transaction by verifying the contract code and submits "verified" again through the UI (4) This should restart the initiator's flow and the remaining process should be followed as expected in Corda

It was mentioned a few weeks back that user interaction is not yet supported in Corda; is this feature still not present? In the future, we may even want to add the state's attributes through a UI since it gives us the flexibility to propose a transaction we want rather than have it hard-coded. Any idea if this could be possible in future releases?


回答1:


See the Negotiation Cordapp sample for an example of how this would work in practice here.

Suspending a flow for human interaction isn't currently implemented (as of Corda V3.0).

Instead, you'd implement this by adding a status flag to your state:

class FooState(
    override val participants: List<Party>,
    val accepted: Boolean) : ContractState

You'd have three commands:

interface Commands : CommandData {
    class Propose : Commands
    class Reject: Commands
    class Accept: Commands
}

And two flows:

  • A proposal flow: In this flow, the initiator creates and signs a Propose transaction to issue the state onto the ledger with a Propose command and the accepted flag set to false

  • An accept flow: In this flow, the recipient either:

    • Creates a Reject transaction that consumes the proposed state and outputs nothing. The state has been removed from the ledger and is effectively rejected
    • Creates an Accept transaction that updates the proposed state so that accepted is true. The state has now been accepted, and this fact is registered on the ledger

You'd give the accept flow a parameter which determines whether or not to accept the proposal. This parameter would be provided by the user when the flow is kicked off either via an API or directly over RPC.



来源:https://stackoverflow.com/questions/45845262/corda-user-interaction-for-verifying-the-transaction-request-received-from-the

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!