【问题标题】:Cannot Issue an IOU on Corda-Training-Template Java-Src无法在 Corda-Training-Template Java-Src 上发出 IOU
【发布时间】:2020-01-06 13:51:06
【问题描述】:

IOUIssueFlow 的参数为IOUState state。如creating-an-instance-of-a-class 中所述,我们可以通过崩溃外壳将状态对象提供给流(也尝试不使用美元符号):

flow start IOUIssueFlow$InitiatorFlow state: { amount: $10, lender: "O=ParticipantB, L=New York, C=GB", borrower: "O=ParticipantC, L=Paris, C=FR" }

此语句适用于 Corda-training-template 的 Kotlin 版本,但在 Java 版本中会引发以下错误:

No matching constructor found:
- [net.corda.training.state.IOUState]: Could not parse as a command: Cannot construct instance of `net.corda.training.state.IOUState` (no Creators, like default construct, exist): cannot deserialize from Object value (no delegate- or property-based Creator)
 at [Source: UNKNOWN; line: -1, column: -1]

虽然我没有使用默认构造函数,但默认构造函数还是应该被this()调用:

@ConstructorForDeserialization
    public IOUState(Amount<Currency> amount, Party lender, Party borrower, UniqueIdentifier linearId){
        this.amount = amount;
        this.lender = lender;
        this.borrower = borrower;
        this.linearId = linearId;
    }

    public IOUState(Amount<Currency> amount, Party lender, Party borrower) {
        this(amount, lender, borrower, new UniqueIdentifier());
    }

corda-training-template 中发出 IOU 状态的正确语法是什么?

【问题讨论】:

  • 这个问题主要是因为注解@ConstructorForDeserialization,你还需要传递一个linearId,或者只传递一个UUID字符串并在构造函数中创建一个UniqueIdentifier实例。

标签: java corda


【解决方案1】:

启动 IOUIssueFlow 金额:10 美元,贷方:ParticipantB,借方:ParticipantC

这应该会启动所需的 IOU 流程。

【讨论】:

  • 流构造函数只带一个参数,状态对象: public static class InitiatorFlow extends FlowLogic { private final IOUState state; public InitiatorFlow(IOUState state) { this.state = state; }
【解决方案2】:

问题可能出在lender: "O=ParticipantB, L=New York, C=**GB**"。必须是C=US

【讨论】:

    猜你喜欢
    • 2019-12-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-24
    • 2017-04-16
    • 1970-01-01
    • 2021-10-05
    • 2018-05-25
    相关资源
    最近更新 更多