voddan
voddan

Reputation: 33769

How do I serialize TransactionBuilder

I need several nodes to build one transaction. To achieve that I create a TransactionBuilder and pass it to nodes that then add their states to it.

This seems to be a legit practice since the official documentation mentions [TransactionBuilder] is intended to be passed around contracts that may edit it by adding new states/commands.

However when running a unit test the network throws this exception:

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.

I tried white-listing TransactionBuilder, but the it threw this:

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.

What am I doing wrong? How do I work around it?

We use Corda 3.3

Upvotes: 0

Views: 169

Answers (1)

Joel
Joel

Reputation: 23140

Based on the error message, you also need to add TransportAgreement.State to the whitelist, as you are sending it as part of the transaction builder.

Upvotes: 1

Related Questions