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

后端 未结 1 575
醉酒成梦
醉酒成梦 2021-01-25 06:56

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 reci

相关标签:
1条回答
  • 2021-01-25 07:53

    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.

    0 讨论(0)
提交回复
热议问题