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

馋奶兔 提交于 2019-12-02 06:45:38

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.

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