Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Corda 实施要求参与者在IOUContract代码中签署事务的约束_Corda - Fatal编程技术网

Corda 实施要求参与者在IOUContract代码中签署事务的约束

Corda 实施要求参与者在IOUContract代码中签署事务的约束,corda,Corda,我正在阅读Corda培训材料,其中有一项活动是“对IOUContract.verify中所需的签名施加约束”。如何实施要求参与者(贷款人和借款人)签署 交易 如果有人知道,请告诉我。 我的代码: 你的代码看起来是合法的。 如果您无法通过测试,请确保贷款人和借款人的获取者在IOUState类中是正确的 如果你不确定,你可以调查一下 此外,您还可以检查替代语法来实现contract类。粘贴的代码来自cordapp的contract。您将在cordapp流程中启动签名收集 假设此交易中只有贷方和借方(

我正在阅读Corda培训材料,其中有一项活动是“对IOUContract.verify中所需的签名施加约束”。如何实施要求参与者(贷款人和借款人)签署 交易 如果有人知道,请告诉我。 我的代码:

你的代码看起来是合法的。
如果您无法通过测试,请确保贷款人和借款人的获取者在IOUState类中是正确的

如果你不确定,你可以调查一下


此外,您还可以检查替代语法来实现contract类。

粘贴的代码来自cordapp的
contract
。您将在cordapp流程中启动签名收集

假设此交易中只有贷方和借方(没有第三方版主),贷方是流程发起人。贷款人将起草状态并亲自签署,并通过会话向借款人发送半签署的交易,借款人将检查并通过响应者签署

此时,您将有一个完全签名的交易。 至于代码,我建议您看看这个简单的应用程序,以供参考

  • 州合同将强制执行谁是所需的签署人。在中,合同预期(即贷款人和借款人)使用
    Create
    命令
  • 当流正在制作一个事务以创建一个新的IOU时,它必须指定使用(
    create
    IOU);谁将签署这个命令(因此流将收集这些签名)
  • 该流程将在签署之前运行,反过来,该流程将运行合同;如果流中的
    Create
    命令中指定的请求签名与合同期望看到的要求签名者不匹配;那么合同将使交易失败。否则,合同将通过事务处理,流程将继续收集,然后收集
    因此,简而言之,合同将说明谁是某个状态命令所需的签名者,为该状态/命令组合创建事务的流程必须遵守合同规则,指定相同的签名者集并收集他们的签名。

    谢谢大家的详细解释。我已经实现了下面的代码,它现在运行良好

    List<PublicKey> signers = tx.getCommands().get(0).getSigners();
    HashSet<PublicKey> signersSet = new HashSet<>();
    for (PublicKey key: signers) {signersSet.add(key);}
    
    List<AbstractParty> participants = tx.getOutputStates().get(0).getParticipants();
    HashSet<PublicKey> participantKeys = new HashSet<>();
    for (AbstractParty party: participants) {participantKeys.add(party.getOwningKey());}
    
    require.using("Both lender and borrower together only may sign IOU issue transaction.", signersSet.containsAll(participantKeys) && signersSet.size() == 2);
    
    List signers=tx.getCommands().get(0.getSigners();
    HashSet signersSet=新HashSet();
    for(PublicKey:signers){signersSet.add(key);}
    List participants=tx.getOutputState().get(0.getParticipants();
    HashSet participantKeys=新HashSet();
    对于(AbstractParty party:participants){participantKeys.add(party.getOwningKey());}
    要求。使用(“贷款人和借款人只能一起签署借据发行交易。”,signersSet.containsAll(participantKeys)和&signersSet.size()==2);
    
     val partStx = serviceHub.signInitialTransaction(txBuilder)
    
     // Gathering the counterparty's signature.
     val counterparty = if (ourIdentity == input.proposer) input.proposee else input.proposer
     val counterpartySession = initiateFlow(counterparty)
     val fullyStx = subFlow(CollectSignaturesFlow(partStx, listOf(counterpartySession)))
    
    List<PublicKey> signers = tx.getCommands().get(0).getSigners();
    HashSet<PublicKey> signersSet = new HashSet<>();
    for (PublicKey key: signers) {signersSet.add(key);}
    
    List<AbstractParty> participants = tx.getOutputStates().get(0).getParticipants();
    HashSet<PublicKey> participantKeys = new HashSet<>();
    for (AbstractParty party: participants) {participantKeys.add(party.getOwningKey());}
    
    require.using("Both lender and borrower together only may sign IOU issue transaction.", signersSet.containsAll(participantKeys) && signersSet.size() == 2);