Corda: Can the output of one transaction be used in another transaction within the same flow with multiple same signers?

南楼画角 提交于 2019-12-11 15:58:37

问题


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.


回答1:


yes it is possible .Please find the link to know more

https://docs.corda.net/key-concepts-transactions.html




回答2:


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

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)
    }
}


来源:https://stackoverflow.com/questions/52983150/corda-can-the-output-of-one-transaction-be-used-in-another-transaction-within-t

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