Corda:一个事务的输出是否可以在具有多个相同签名者的同一流中的另一个事务中使用? [英] Corda: Can the output of one transaction be used in another transaction within the same flow with multiple same signers?

查看:164
本文介绍了Corda:一个事务的输出是否可以在具有多个相同签名者的同一流中的另一个事务中使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

按照下面的方案有一个流程.
发起方:PartyA
响应方:PartyB
事务1:输入StateA-ContractA产生输出StateB-ContractA.参加者是甲方和乙方
事务2:输入StateB-ContractA,但没有输出.参加者是甲方和乙方
在科尔达有可能吗?请与响应分享一个例子.谢谢.

There is a flow as per below scenario.
Initiating Party : PartyA
Responding Party : PartyB
Transaction 1: Input StateA - ContractA results in output StateB - ContractA. Participants are PartyA and PartyB
Transaction 2: Input StateB - ContractA and no output. Participants are PartyA and PartyB
Is this possible in Corda? Please do share an example with response. Thanks.

推荐答案

听起来您会收到两个不同的错误消息:

It sounds like you're getting two different error messages:

  • 如果您不尝试启动第二个流会话以获取第二个签名,则会得到类似以下内容的信息:

  • If you don't try and initiate a second flow-session to get the second signature, you get something like:

net.corda.core.flows.UnexpectedFlowEndException:交易对手流在 O =模拟公司2,L =伦敦,C = GB已完成但未发送数据

net.corda.core.flows.UnexpectedFlowEndException: Counterparty flow on O=Mock Company 2, L=London, C=GB has completed without sending data

  • 如果您确实启动第二个流会话以获取第二个签名,则会得到类似以下内容的信息:

  • While if you do initiate a second flow-session to get the second signature, you get something like:

    java.lang.IllegalStateException:尝试在两次中初始化InitialFlow() 相同的InitiatingFlow com.example.flow.ExampleFlow$Initiator@312d7fe4对于同一方 O =模拟公司2,L =伦敦,C = GB.此版本不支持此功能 科尔达.或者,您可以通过调用以下命令来启动新流程 @InitiatingFlow子流中的initializeFlow().

    java.lang.IllegalStateException: Attempted to initiateFlow() twice in the same InitiatingFlow com.example.flow.ExampleFlow$Initiator@312d7fe4 for the same party O=Mock Company 2, L=London, C=GB. This isn't supported in this version of Corda. Alternatively you may initiate a new flow by calling initiateFlow() in an @InitiatingFlow sub-flow.

  • 在第一种情况下,错误是由于交易对手的流程已经完成而引起的.您可以尝试通过创建第二个流程会话来解决此问题,但是每个Initiating流程只能与给定的交易对手发起一个流程会话.

    In the first case, the error is caused by the fact that the counterparty's flow has already completed. You try and get around this by creating a second flow session, but each Initiating flow can only initiate a single flow-session with a given counterparty.

    相反,您只需要修改响应者流程以进行两次签名.例如:

    Instead, you simply need to modify the responder flow to sign twice. For example:

    @InitiatedBy(Initiator::class)
    class Acceptor(val otherPartyFlow: FlowSession) : FlowLogic<Unit>() {
        @Suspendable
        override fun call() {
            val signTransactionFlow = object : SignTransactionFlow(otherPartyFlow) {
                override fun checkTransaction(stx: SignedTransaction) = requireThat {
                    // Transaction checks...
                }
            }
    
            subFlow(signTransactionFlow)
            subFlow(signTransactionFlow)
        }
    }
    

    这篇关于Corda:一个事务的输出是否可以在具有多个相同签名者的同一流中的另一个事务中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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