use of io.nem.symbol.catapult.builders.EmbeddedTransactionBuilder in project nem2-sdk-java by nemtech.
the class BinarySerializationImpl method serializeEmbedded.
/**
* Serialized the transfer transaction to embedded bytes.
*
* @param transaction the transaction
* @param <T> the transaction class
* @return bytes of the transaction.
*/
public <T extends Transaction> byte[] serializeEmbedded(T transaction) {
Validate.notNull(transaction, "Transaction must not be null");
EmbeddedTransactionBuilder embeddedTransactionBuilder = EmbeddedTransactionBuilder.create(new KeyDto(getRequiredSignerBytes(transaction.getSigner())), transaction.getVersion().byteValue(), NetworkTypeDto.rawValueOf((byte) transaction.getNetworkType().getValue()), EntityTypeDto.rawValueOf((short) transaction.getType().getValue()));
return serializeTransaction(embeddedTransactionBuilder.serialize(), transaction);
}
use of io.nem.symbol.catapult.builders.EmbeddedTransactionBuilder in project nem2-sdk-java by nemtech.
the class BinarySerializationImpl method deserializeEmbedded.
/**
* It deserializes a payload of a embedded transaction into a transact model.
*
* @param payload the payload as {@link DataInputStream}
* @return the {@link Transaction} model.
*/
public Transaction deserializeEmbedded(DataInputStream payload) {
return ExceptionUtils.propagate(() -> {
Validate.notNull(payload, "Payload must not be null");
EmbeddedTransactionBuilder builder = EmbeddedTransactionBuilderHelper.loadFromBinary(payload);
return toTransaction(builder);
});
}
Aggregations