Search in sources :

Example 1 with EmbeddedTransactionBuilder

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);
}
Also used : EmbeddedTransactionBuilder(io.nem.symbol.catapult.builders.EmbeddedTransactionBuilder) VotingKeyDto(io.nem.symbol.catapult.builders.VotingKeyDto) KeyDto(io.nem.symbol.catapult.builders.KeyDto)

Example 2 with EmbeddedTransactionBuilder

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);
    });
}
Also used : EmbeddedTransactionBuilder(io.nem.symbol.catapult.builders.EmbeddedTransactionBuilder)

Aggregations

EmbeddedTransactionBuilder (io.nem.symbol.catapult.builders.EmbeddedTransactionBuilder)2 KeyDto (io.nem.symbol.catapult.builders.KeyDto)1 VotingKeyDto (io.nem.symbol.catapult.builders.VotingKeyDto)1