Search in sources :

Example 11 with PublicKey

use of io.nem.symbol.core.crypto.PublicKey in project nem2-sdk-java by nemtech.

the class VrfKeyLinkTransactionMapper method createFactory.

@Override
protected TransactionFactory<VrfKeyLinkTransaction> createFactory(NetworkType networkType, Deadline deadline, VrfKeyLinkTransactionDTO transaction) {
    PublicKey linkedPublicKey = PublicKey.fromHexString(transaction.getLinkedPublicKey());
    LinkAction linkAction = LinkAction.rawValueOf(transaction.getLinkAction().getValue());
    return VrfKeyLinkTransactionFactory.create(networkType, deadline, linkedPublicKey, linkAction);
}
Also used : PublicKey(io.nem.symbol.core.crypto.PublicKey) LinkAction(io.nem.symbol.sdk.model.transaction.LinkAction)

Example 12 with PublicKey

use of io.nem.symbol.core.crypto.PublicKey in project nem2-sdk-java by nemtech.

the class AbstractTransactionMapper method mapTransaction.

private D mapTransaction(Transaction transaction, boolean embedded) {
    TransactionDTO dto = new TransactionDTO();
    dto.setSignerPublicKey(transaction.getSigner().map(PublicAccount::getPublicKey).map(PublicKey::toHex).orElse(null));
    dto.setVersion(transaction.getVersion());
    dto.setType(transaction.getType().getValue());
    dto.setNetwork(NetworkTypeEnum.fromValue(transaction.getNetworkType().getValue()));
    if (!embedded) {
        dto.setSize(transaction.getSize());
        dto.setMaxFee(transaction.getMaxFee());
        dto.setDeadline(transaction.getDeadline().toBigInteger());
        dto.setSignature(transaction.getSignature().orElse(null));
    }
    D specificDto = getJsonHelper().parse(getJsonHelper().print(dto), transactionDtoClass);
    copyToDto((T) transaction, specificDto);
    return specificDto;
}
Also used : TransactionDTO(io.nem.symbol.sdk.openapi.vertx.model.TransactionDTO) PublicKey(io.nem.symbol.core.crypto.PublicKey)

Example 13 with PublicKey

use of io.nem.symbol.core.crypto.PublicKey in project nem2-sdk-java by nemtech.

the class NodeKeyLinkTransactionMapper method createFactory.

@Override
protected TransactionFactory<NodeKeyLinkTransaction> createFactory(NetworkType networkType, Deadline deadline, NodeKeyLinkTransactionDTO transaction) {
    PublicKey linkedPublicKey = PublicKey.fromHexString(transaction.getLinkedPublicKey());
    LinkAction linkAction = LinkAction.rawValueOf(transaction.getLinkAction().getValue());
    return NodeKeyLinkTransactionFactory.create(networkType, deadline, linkedPublicKey, linkAction);
}
Also used : PublicKey(io.nem.symbol.core.crypto.PublicKey) LinkAction(io.nem.symbol.sdk.model.transaction.LinkAction)

Example 14 with PublicKey

use of io.nem.symbol.core.crypto.PublicKey in project nem2-sdk-java by nemtech.

the class AccountRepositoryOkHttpImpl method toDto.

private SupplementalAccountKeys toDto(SupplementalPublicKeysDTO dto) {
    if (dto == null) {
        return new SupplementalAccountKeys(null, null, null, Collections.emptyList());
    }
    PublicKey linked = toPublicKey(dto.getLinked());
    PublicKey node = toPublicKey(dto.getNode());
    PublicKey vrf = toPublicKey(dto.getVrf());
    List<AccountLinkVotingKey> voting = dto.getVoting() == null || dto.getVoting().getPublicKeys() == null ? Collections.emptyList() : dto.getVoting().getPublicKeys().stream().map(p -> new AccountLinkVotingKey(p.getPublicKey(), (p.getStartEpoch()), (p.getEndEpoch()))).collect(Collectors.toList());
    return new SupplementalAccountKeys(linked, node, vrf, voting);
}
Also used : SupplementalAccountKeys(io.nem.symbol.sdk.model.account.SupplementalAccountKeys) AccountLinkVotingKey(io.nem.symbol.sdk.model.account.AccountLinkVotingKey) PublicKey(io.nem.symbol.core.crypto.PublicKey)

Example 15 with PublicKey

use of io.nem.symbol.core.crypto.PublicKey in project nem2-sdk-java by nemtech.

the class VotingKeyLinkTransactionMapper method createFactory.

@Override
protected TransactionFactory<VotingKeyLinkTransaction> createFactory(NetworkType networkType, Deadline deadline, VotingKeyLinkTransactionDTO transaction) {
    PublicKey linkedPublicKey = PublicKey.fromHexString(transaction.getLinkedPublicKey());
    LinkAction linkAction = LinkAction.rawValueOf(transaction.getLinkAction().getValue());
    return VotingKeyLinkTransactionFactory.create(networkType, deadline, linkedPublicKey, transaction.getStartEpoch(), transaction.getEndEpoch(), linkAction);
}
Also used : PublicKey(io.nem.symbol.core.crypto.PublicKey) LinkAction(io.nem.symbol.sdk.model.transaction.LinkAction)

Aggregations

PublicKey (io.nem.symbol.core.crypto.PublicKey)31 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)11 EnumSource (org.junit.jupiter.params.provider.EnumSource)8 Test (org.junit.jupiter.api.Test)7 LinkAction (io.nem.symbol.sdk.model.transaction.LinkAction)6 KeyPair (io.nem.symbol.core.crypto.KeyPair)5 Account (io.nem.symbol.sdk.model.account.Account)5 PrivateKey (io.nem.symbol.core.crypto.PrivateKey)4 KeyGenerator (io.nem.symbol.core.crypto.KeyGenerator)3 KeyGeneratorTest (io.nem.symbol.core.crypto.KeyGeneratorTest)3 Address (io.nem.symbol.sdk.model.account.Address)3 MethodSource (org.junit.jupiter.params.provider.MethodSource)3 CryptoEngine (io.nem.symbol.core.crypto.CryptoEngine)2 Ed25519GroupElement (io.nem.symbol.core.crypto.ed25519.arithmetic.Ed25519GroupElement)2 BlockPaginationStreamer (io.nem.symbol.sdk.api.BlockPaginationStreamer)2 BlockRepository (io.nem.symbol.sdk.api.BlockRepository)2 BlockSearchCriteria (io.nem.symbol.sdk.api.BlockSearchCriteria)2 TransactionPaginationStreamer (io.nem.symbol.sdk.api.TransactionPaginationStreamer)2 TransactionRepository (io.nem.symbol.sdk.api.TransactionRepository)2 TransactionSearchCriteria (io.nem.symbol.sdk.api.TransactionSearchCriteria)2