Java 交易3CA098上缺少密钥的签名:--由签名者:com.template.contracts.IOUContract.Create

Java 交易3CA098上缺少密钥的签名:--由签名者:com.template.contracts.IOUContract.Create,java,corda,Java,Corda,我的合同类中声明了Create类,我是否也必须在Create类中编写一些内容?对于corda来说是新的,因此,如果有人有任何参考资料、教程、使用“Java”学习corda的示例,请在评论中分享,加上文档中已经完成的关键概念。提前谢谢 ``` package com.template.contracts; import com.template.states.IOUState; import net.corda.core.contracts.CommandData;

我的合同类中声明了Create类,我是否也必须在Create类中编写一些内容?对于corda来说是新的,因此,如果有人有任何参考资料、教程、使用“Java”学习corda的示例,请在评论中分享,加上文档中已经完成的关键概念。提前谢谢

```

    package com.template.contracts;

    import com.template.states.IOUState;
    import net.corda.core.contracts.CommandData;
    import net.corda.core.contracts.Contract;
    import net.corda.core.transactions.LedgerTransaction;
    import net.corda.core.contracts.CommandWithParties;
    import net.corda.core.identity.Party;

    import java.security.PublicKey;
    import java.util.Arrays;
    import java.util.List;


    import static net.corda.core.contracts.ContractsDSL.requireSingleCommand;

    // ************
    // * Contract *
    // ************
    public class IOUContract implements Contract {
        // This is used to identify our contract when building a transaction.
        public static final String ID = "com.template.contracts.IOUContract";

        //our Create Command
        public static class Create implements CommandData{

        }

        // A transaction is valid if the verify() function of the contract of all the transaction's input and output states
        // does not throw an exception.
        @Override
        public void verify(LedgerTransaction tx) {
            final CommandWithParties<IOUContract.Create> command =requireSingleCommand(tx.getCommands(),IOUContract.Create.class);

            //Constraints on the shape of the transaction

            if(!tx.getInputs().isEmpty())
                throw new IllegalArgumentException("No inputs should be consumed when issuisng an IOU.");
            if(!(tx.getOutputs().size()==1))
                throw new IllegalArgumentException("There should be one output state of type IOUState.");

            //IOU-specific constraints.
            final IOUState  output =tx.outputsOfType(IOUState.class).get(0);
            final Party lender = output.getLender();
            final Party borrower =output.getBorrower();
            if(output.getValue()<=0)
                throw new IllegalArgumentException("This IOU's value must be non-negative");
            if(lender.equals(borrower))
                throw new IllegalArgumentException("The lender and the borrower cannot be same entity");

            //Constraints on the signers.
            final List<PublicKey> requiredSigners =command.getSigners();
            final List<PublicKey> exceptedSigners =Arrays.asList(borrower.getOwningKey(),lender.getOwningKey());
            if(requiredSigners.size() !=  2)
                throw new IllegalArgumentException("There must be two signers");
            if(!(requiredSigners.containsAll(exceptedSigners)))
                throw new IllegalArgumentException("The borrower and lender must be signers.");
        }

        // Used to indicate the transaction's intent.
        public interface Commands extends CommandData {
            class Action implements Commands {}
        }
```
  • 在州合同中,您设置了验证规则。例如,在
    Create
    上,借款人和贷款人都必须是签名人:
  • 在您的流程中,当您将命令分配给事务时,您必须指定所需的签名者(该签名者应符合您的合同要求):
  • 假设流的发起节点是贷方,则该节点签署交易:
  • 在响应者流程中,借款人还签署了交易:
  • 这样你就收集了两个签名

    Followed the link:- "https://docs.corda.r3.com/tut-two-party-contract.html"