如何从corda流中的多个州参与者收集签名?

时间:2018-01-09 18:39:58

标签: kotlin corda

我正在处理涉及三方的用例,让我们说PartyA,PartyB和PartyC。

在这种情况下,

  1. PartyA发出dealState(A是唯一的参与者),

  2. PartyA将其出售给PartyB(A,B为参与者),

  3. 现在,PartyB希望将此州出售给PartyC,但我们需要A和B的签名,以及C接受销售流程的签名。

  4. 如何在第三种情况下收集原始发行人PartyA的签名以使流程有效?

    流程中的代码就是这个(我作为PartyB出售)

    val newOwnerFlow = initiateFlow(PartyC)
    
    progressTracker.currentStep = GATHERING_SIGS
    
    println("Finished gathering signatures stage 9")
    
    // Send the state to the counterparty, and receive it back with their signature.
    val fullySignedTx = subFlow(CollectSignaturesFlow(partSignedTx, setOf(newOwnerFlow), GATHERING_SIGS.childProgressTracker()))
    
    // Stage 10.
    progressTracker.currentStep = FINALISING_TRANSACTION
    
    println("Finalizing transaction")
    
    // Notarise and record the transaction in both parties' vaults.
    
    return subFlow(FinalityFlow(fullySignedTx, FINALISING_TRANSACTION.childProgressTracker()))
    

    如何让PartyA签署交易?

1 个答案:

答案 0 :(得分:1)

经过一些实验,我发现问题如下:

你必须创建一个setOf(flowSessions),将每个参与者映射到必须传递给CollectSignaturesFlow()的相应的initiateFlow(),语法如下:

 val participantsParties = dealState.participants.map { serviceHub.identityService.wellKnownPartyFromAnonymous(it)!! }

 val flowSessions = (participantsParties - myIdentity).map { initiateFlow(it) }.toSet()

 progressTracker.currentStep = GATHERING_SIGS

 println("Finished gathering signatures stage 9")

 // Send the state to the counterparty, and receive it back with their signature.

 val fullySignedTx = subFlow(CollectSignaturesFlow(partSignedTx, flowSessions, GATHERING_SIGS.childProgressTracker()))