Corda:用于验证从发起方节点接收到的交易请求的用户交互 [英] Corda: User interaction for verifying the transaction request received from the initiator node

查看:56
本文介绍了Corda:用于验证从发起方节点接收到的交易请求的用户交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个用例,需要执行以下步骤:
(1)发起方通过UI触发事务流
(2)该流已启动,由发起方签名并发送给接收者验证和签名(在Corda中)
(3)应该暂停发起者的流程,直到接收者通过验证合同代码来验证交易并通过UI
再次提交已验证为止(4)这应该重新开始发起人的流程和其余过程应按Corda的预期进行。

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

几周前提到,Corda中尚不支持用户交互;这个功能还不存在吗?将来,我们甚至可能希望通过UI添加州的属性,因为它使我们能够灵活地提出我们想要的交易,而不是对其进行硬编码。知道将来的发行版中是否可能?

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?

推荐答案

有关如何在Windows 2000中工作的示例,请参见Negotiation Cordapp示例。在此处

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

暂停流程目前尚未实现人机交互(自Corda V3.0起)。

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

您将拥有三个命令:

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

和两个流:


  • 提案流:在此流中,发起者创建并签署 P ropose 事务,使用 Propose 命令和 accepted 标志将状态发布到分类帐设置为 false

  • 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:


  • 创建 Reject 交易,该交易消耗拟议状态并且不输出任何内容。该状态已从分类帐中删除,并被有效拒绝。

  • 创建一个 Accept 交易,该交易会更新建议的状态,从而使接受 true 。该状态现已被接受,并且该事实已在分类帐中注册

  • 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

您将为接受流程提供一个参数,该参数确定是否接受提案。当通过API或直接通过RPC启动流时,用户将提供此参数。

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.

这篇关于Corda:用于验证从发起方节点接收到的交易请求的用户交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆