如何序列化TransactionBuilder

时间:2018-12-11 13:53:26

标签: corda

我需要几个节点来建立一个事务。为此,我创建了一个TransactionBuilder并将其传递给节点,然后将其状态添加到其中。

official documentation提到[TransactionBuilder] is intended to be passed around contracts that may edit it by adding new states/commands.

以来,这似乎是合法的做法

但是,在运行单元测试时,网络会抛出此异常:

Class class net.corda.core.transactions.TransactionBuilder is not on the whitelist or annotated with @CordaSerializable. java.io.NotSerializableException: Class class net.corda.core.transactions.TransactionBuilder is not on the whitelist or annotated with @CordaSerializable.

我曾尝试将TransactionBuilder列入白名单,但这引发了这个问题:

net.corda.core.transactions.TransactionBuilder -> outputs(java.util.List<net.corda.core.contracts.TransactionState<net.corda.core.contracts.ContractState>>) -> java.util.List<net.corda.core.contracts.TransactionState<net.corda.core.contracts.ContractState>> -> net.corda.core.contracts.TransactionState<net.corda.core.contracts.ContractState> -> data(net.corda.core.contracts.ContractState) -> state(com.luxoft.poc.mobi.data.state.TransportAgreement$State) -> Class class com.luxoft.poc.mobi.data.state.TransportAgreement$State is not on the whitelist or annotated with @CordaSerializable. java.io.NotSerializableException: net.corda.core.transactions.TransactionBuilder -> outputs(java.util.List<net.corda.core.contracts.TransactionState<net.corda.core.contracts.ContractState>>) -> java.util.List<net.corda.core.contracts.TransactionState<net.corda.core.contracts.ContractState>> -> net.corda.core.contracts.TransactionState<net.corda.core.contracts.ContractState> -> data(net.corda.core.contracts.ContractState) -> state(com.luxoft.poc.mobi.data.state.TransportAgreement$State) -> Class class com.luxoft.poc.mobi.data.state.TransportAgreement$State is not on the whitelist or annotated with @CordaSerializable.

我在做什么错?我该如何解决?

我们使用Corda 3.3

1 个答案:

答案 0 :(得分:1)

根据错误消息,您还需要将TransportAgreement.State添加到白名单中,因为它是作为事务构建器的一部分发送的。

相关问题