Corda: Can the output of one transaction be used i

2019-08-28 21:39发布

问题:

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


标签: kotlin corda