kotlin - 如何从Corda流中的多个状态参与者那里收集签名?

标签 kotlin corda

我正在研究一个涉及三个参与方的用例,比如说PartyA,PartyB和PartyC。

在这种情况下,

  • PartyA发出dealState(A是唯一的参与者),
  • PartyA将其出售给PartyB(A,B是参与者),
  • 现在,PartyB希望将该状态出售给PartyC,但我们需要A和B的签名,以及C接受出售过程的签名。

  • 在第三种情况下,如何从原始发行方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签署交易?

    最佳答案

    经过一些试验,我发现问题出在以下方面:

    您必须创建一个setOf(flowSessions),将每个参与者映射到必须传递给CollectSignaturesFlow()的其对应的initializeFlow(),其语法类似于以下内容:

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

    关于kotlin - 如何从Corda流中的多个状态参与者那里收集签名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48174694/

    相关文章:

    kotlin - 如何检查它是否是kotlin中的mac地址

    android - Android Kotlin API请求|在gson流程之后访问列表

    Kotlin:无法调用表达式,因为找不到函数 invoke()

    android - 无法将使用 JVM 目标 1.8 构建的字节码内联到使用 JVM 目标 1.6 构建的字节码

    Corda IsRelevant() 解决方法?

    spring - 节点找不到contractState(Corda,Spring)

    android - Kotlin 多平台 : How to mock objects in a unit test for iOS

    kotlin - 有没有办法在 Kotlin 中构造带有初始化函数的 HashSet?

    corda - 法律散文用法 Corda

    java - 胶囊异常(exception)