Search in sources :

Example 1 with Hash256Dto

use of io.nem.symbol.catapult.builders.Hash256Dto in project nem2-sdk-java by nemtech.

the class HashLockInfo method serialize.

/**
 * @return serializes the state of this object.
 */
public byte[] serialize() {
    AddressDto ownerAddress = SerializationUtils.toAddressDto(getOwnerAddress());
    MosaicBuilder mosaic = MosaicBuilder.create(SerializationUtils.toMosaicIdDto(getMosaicId()), SerializationUtils.toAmount(getAmount()));
    HeightDto endHeight = new HeightDto(getEndHeight().longValue());
    LockStatusDto status = LockStatusDto.rawValueOf(getStatus().getValue());
    Hash256Dto hash = SerializationUtils.toHash256Dto(getHash());
    return HashLockInfoBuilder.create((short) getVersion(), ownerAddress, mosaic, endHeight, status, hash).serialize();
}
Also used : Hash256Dto(io.nem.symbol.catapult.builders.Hash256Dto) MosaicBuilder(io.nem.symbol.catapult.builders.MosaicBuilder) AddressDto(io.nem.symbol.catapult.builders.AddressDto) HeightDto(io.nem.symbol.catapult.builders.HeightDto) LockStatusDto(io.nem.symbol.catapult.builders.LockStatusDto)

Example 2 with Hash256Dto

use of io.nem.symbol.catapult.builders.Hash256Dto in project nem2-sdk-java by nemtech.

the class SecretLockInfo method serialize.

/**
 * @return serializes the state of this object.
 */
public byte[] serialize() {
    short version = (short) getVersion();
    AddressDto ownerAddress = SerializationUtils.toAddressDto(getOwnerAddress());
    MosaicBuilder mosaic = MosaicBuilder.create(SerializationUtils.toMosaicIdDto(getMosaicId()), SerializationUtils.toAmount(getAmount()));
    HeightDto endHeight = new HeightDto(getEndHeight().longValue());
    LockStatusDto status = LockStatusDto.rawValueOf(getStatus().getValue());
    Hash256Dto secret = SerializationUtils.toHash256Dto(getSecret());
    AddressDto recipient = SerializationUtils.toAddressDto(getRecipientAddress());
    LockHashAlgorithmDto hashAlgorithm = LockHashAlgorithmDto.rawValueOf((byte) this.hashAlgorithm.getValue());
    return SecretLockInfoBuilder.create(version, ownerAddress, mosaic, endHeight, status, hashAlgorithm, secret, recipient).serialize();
}
Also used : Hash256Dto(io.nem.symbol.catapult.builders.Hash256Dto) MosaicBuilder(io.nem.symbol.catapult.builders.MosaicBuilder) LockHashAlgorithmDto(io.nem.symbol.catapult.builders.LockHashAlgorithmDto) AddressDto(io.nem.symbol.catapult.builders.AddressDto) HeightDto(io.nem.symbol.catapult.builders.HeightDto) LockStatusDto(io.nem.symbol.catapult.builders.LockStatusDto)

Aggregations

AddressDto (io.nem.symbol.catapult.builders.AddressDto)2 Hash256Dto (io.nem.symbol.catapult.builders.Hash256Dto)2 HeightDto (io.nem.symbol.catapult.builders.HeightDto)2 LockStatusDto (io.nem.symbol.catapult.builders.LockStatusDto)2 MosaicBuilder (io.nem.symbol.catapult.builders.MosaicBuilder)2 LockHashAlgorithmDto (io.nem.symbol.catapult.builders.LockHashAlgorithmDto)1