Search in sources :

Example 1 with RequestAnnounce

use of com.github.rosklyar.client.transaction.domain.RequestAnnounce in project nem-library by rosklyar.

the class SecureTransactionClient method multisigCreateMosaic.

@Override
public NemAnnounceResult multisigCreateMosaic(String privateKey, MosaicId mosaicId, String mosaicDescription, MosaicProperties mosaicProperties, Levy levy, String multisigPublicKey, int timeToLiveInSeconds) {
    Signer signer = new DefaultSigner(privateKey);
    int currentTime = nodeClient.extendedInfo().nisInfo.currentTime;
    MosaicDefinitionCreationTransaction mosaicDefinitionCreationTransaction = mosaicDefinitionCreationTransaction(mosaicId, mosaicDescription, mosaicProperties, levy, multisigPublicKey, currentTime, timeToLiveInSeconds);
    MultisigTransaction<MosaicDefinitionCreationTransaction> transaction = MultisigTransaction.<MosaicDefinitionCreationTransaction>builder().type(MULTISIG_TRANSACTION.type).version(versionProvider.version(network, MULTISIG_TRANSACTION)).timeStamp(currentTime).signer(signer.publicKey()).fee(feeCalculator.multisigTransactionFee()).deadline(currentTime + timeToLiveInSeconds).otherTrans(mosaicDefinitionCreationTransaction).build();
    byte[] data = transactionEncoder.dataMultisigMosaicCreation(transaction);
    return feignTransactionClient.prepare(new RequestAnnounce(hexConverter.getString(data), signer.sign(data)));
}
Also used : DefaultSigner(com.github.rosklyar.client.transaction.encode.DefaultSigner) Signer(com.github.rosklyar.client.transaction.encode.Signer) DefaultSigner(com.github.rosklyar.client.transaction.encode.DefaultSigner) RequestAnnounce(com.github.rosklyar.client.transaction.domain.RequestAnnounce)

Example 2 with RequestAnnounce

use of com.github.rosklyar.client.transaction.domain.RequestAnnounce in project nem-library by rosklyar.

the class SecureTransactionClient method changeMosaicSupply.

@Override
public NemAnnounceResult changeMosaicSupply(String privateKey, MosaicId mosaicId, SupplyType supplyType, long amount, int timeToLiveInSeconds) {
    Signer signer = new DefaultSigner(privateKey);
    int currentTime = nodeClient.extendedInfo().nisInfo.currentTime;
    String publicKey = signer.publicKey();
    MosaicSupplyChangeTransaction transaction = mosaicSupplyChangeTransaction(mosaicId, supplyType, amount, publicKey, currentTime, timeToLiveInSeconds);
    byte[] data = transactionEncoder.data(transaction);
    return feignTransactionClient.prepare(new RequestAnnounce(hexConverter.getString(data), signer.sign(data)));
}
Also used : DefaultSigner(com.github.rosklyar.client.transaction.encode.DefaultSigner) Signer(com.github.rosklyar.client.transaction.encode.Signer) DefaultSigner(com.github.rosklyar.client.transaction.encode.DefaultSigner) RequestAnnounce(com.github.rosklyar.client.transaction.domain.RequestAnnounce)

Example 3 with RequestAnnounce

use of com.github.rosklyar.client.transaction.domain.RequestAnnounce in project nem-library by rosklyar.

the class SecureTransactionClient method createMultisigAccount.

@Override
public NemAnnounceResult createMultisigAccount(String privateKey, List<String> cosignatories, int minCosignatories, int timeToLiveInSeconds) {
    Signer signer = new DefaultSigner(privateKey);
    int currentTime = nodeClient.extendedInfo().nisInfo.currentTime;
    List<Modification> modifications = cosignatories.stream().map(publicKey -> new Modification(1, publicKey)).collect(toList());
    Transaction transaction = aggregateModificationTransaction(signer.publicKey(), modifications, minCosignatories, currentTime, timeToLiveInSeconds);
    byte[] data = transactionEncoder.data(transaction);
    return feignTransactionClient.prepare(new RequestAnnounce(hexConverter.getString(data), signer.sign(data)));
}
Also used : DefaultSigner(com.github.rosklyar.client.transaction.encode.DefaultSigner) Signer(com.github.rosklyar.client.transaction.encode.Signer) DefaultSigner(com.github.rosklyar.client.transaction.encode.DefaultSigner) Action(com.github.rosklyar.client.transaction.domain.importance.Action) ProvisionNamespaceTransaction(com.github.rosklyar.client.transaction.domain.ProvisionNamespaceTransaction) Network(com.github.rosklyar.client.transaction.version.Network) RequestAnnounce(com.github.rosklyar.client.transaction.domain.RequestAnnounce) RelativeChange(com.github.rosklyar.client.transaction.domain.multisig.RelativeChange) HexConverter(com.github.rosklyar.client.transaction.encode.HexConverter) NemAnnounceResult(com.github.rosklyar.client.transaction.domain.NemAnnounceResult) MultisigTransaction(com.github.rosklyar.client.transaction.domain.multisig.MultisigTransaction) Signer(com.github.rosklyar.client.transaction.encode.Signer) TransactionEncoder(com.github.rosklyar.client.transaction.encode.TransactionEncoder) TEN(java.math.BigInteger.TEN) Hash(com.github.rosklyar.client.account.domain.Hash) TransactionType(com.github.rosklyar.client.transaction.TransactionType) FeeCalculator(com.github.rosklyar.client.transaction.fee.FeeCalculator) ImportanceTransferTransaction(com.github.rosklyar.client.transaction.domain.importance.ImportanceTransferTransaction) Transaction(com.github.rosklyar.client.transaction.domain.Transaction) NodeClient(com.github.rosklyar.client.node.NodeClient) Modification(com.github.rosklyar.client.transaction.domain.multisig.Modification) com.github.rosklyar.client.transaction.domain.mosaic(com.github.rosklyar.client.transaction.domain.mosaic) MosaicProperty(com.github.rosklyar.client.mosaic.domain.MosaicProperty) List(java.util.List) Collectors.toList(java.util.stream.Collectors.toList) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) VersionProvider(com.github.rosklyar.client.transaction.version.VersionProvider) Message(com.github.rosklyar.client.account.domain.Message) REMOVE_COSIGNATORY(com.github.rosklyar.client.transaction.domain.multisig.ModificationType.REMOVE_COSIGNATORY) Levy(com.github.rosklyar.client.mosaic.domain.Levy) ADD_COSIGNATORY(com.github.rosklyar.client.transaction.domain.multisig.ModificationType.ADD_COSIGNATORY) Modification(com.github.rosklyar.client.transaction.domain.multisig.Modification) DefaultSigner(com.github.rosklyar.client.transaction.encode.DefaultSigner) RequestAnnounce(com.github.rosklyar.client.transaction.domain.RequestAnnounce) ProvisionNamespaceTransaction(com.github.rosklyar.client.transaction.domain.ProvisionNamespaceTransaction) MultisigTransaction(com.github.rosklyar.client.transaction.domain.multisig.MultisigTransaction) ImportanceTransferTransaction(com.github.rosklyar.client.transaction.domain.importance.ImportanceTransferTransaction) Transaction(com.github.rosklyar.client.transaction.domain.Transaction)

Example 4 with RequestAnnounce

use of com.github.rosklyar.client.transaction.domain.RequestAnnounce in project nem-library by rosklyar.

the class SecureTransactionClient method createNamespace.

@Override
public NemAnnounceResult createNamespace(String privateKey, String parentNamespace, String namespace, int timeToLiveInSeconds) {
    Signer signer = new DefaultSigner(privateKey);
    int currentTime = nodeClient.extendedInfo().nisInfo.currentTime;
    ProvisionNamespaceTransaction transaction = provisionNamespaceTransaction(signer.publicKey(), parentNamespace, namespace, currentTime, timeToLiveInSeconds);
    byte[] data = transactionEncoder.data(transaction);
    return feignTransactionClient.prepare(new RequestAnnounce(hexConverter.getString(data), signer.sign(data)));
}
Also used : DefaultSigner(com.github.rosklyar.client.transaction.encode.DefaultSigner) Signer(com.github.rosklyar.client.transaction.encode.Signer) DefaultSigner(com.github.rosklyar.client.transaction.encode.DefaultSigner) ProvisionNamespaceTransaction(com.github.rosklyar.client.transaction.domain.ProvisionNamespaceTransaction) RequestAnnounce(com.github.rosklyar.client.transaction.domain.RequestAnnounce)

Example 5 with RequestAnnounce

use of com.github.rosklyar.client.transaction.domain.RequestAnnounce in project nem-library by rosklyar.

the class SecureTransactionClient method cosignTransaction.

@Override
public NemAnnounceResult cosignTransaction(String privateKey, String transactionHash, String multisigAddress, int timeToLiveInSeconds) {
    Signer signer = new DefaultSigner(privateKey);
    int currentTime = nodeClient.extendedInfo().nisInfo.currentTime;
    Transaction transaction = Transaction.builder().type(MULTISIG_SIGNATURE.type).version(versionProvider.version(network, MULTISIG_SIGNATURE)).timeStamp(currentTime).signer(signer.publicKey()).fee(feeCalculator.cosigningFee()).deadline(currentTime + timeToLiveInSeconds).otherAccount(multisigAddress).otherHash(new Hash(transactionHash)).build();
    byte[] data = transactionEncoder.data(transaction);
    return feignTransactionClient.prepare(new RequestAnnounce(hexConverter.getString(data), signer.sign(data)));
}
Also used : DefaultSigner(com.github.rosklyar.client.transaction.encode.DefaultSigner) Signer(com.github.rosklyar.client.transaction.encode.Signer) DefaultSigner(com.github.rosklyar.client.transaction.encode.DefaultSigner) RequestAnnounce(com.github.rosklyar.client.transaction.domain.RequestAnnounce) ProvisionNamespaceTransaction(com.github.rosklyar.client.transaction.domain.ProvisionNamespaceTransaction) MultisigTransaction(com.github.rosklyar.client.transaction.domain.multisig.MultisigTransaction) ImportanceTransferTransaction(com.github.rosklyar.client.transaction.domain.importance.ImportanceTransferTransaction) Transaction(com.github.rosklyar.client.transaction.domain.Transaction) Hash(com.github.rosklyar.client.account.domain.Hash)

Aggregations

RequestAnnounce (com.github.rosklyar.client.transaction.domain.RequestAnnounce)15 DefaultSigner (com.github.rosklyar.client.transaction.encode.DefaultSigner)14 Signer (com.github.rosklyar.client.transaction.encode.Signer)14 ProvisionNamespaceTransaction (com.github.rosklyar.client.transaction.domain.ProvisionNamespaceTransaction)9 ImportanceTransferTransaction (com.github.rosklyar.client.transaction.domain.importance.ImportanceTransferTransaction)9 Transaction (com.github.rosklyar.client.transaction.domain.Transaction)7 MultisigTransaction (com.github.rosklyar.client.transaction.domain.multisig.MultisigTransaction)7 Hash (com.github.rosklyar.client.account.domain.Hash)2 Message (com.github.rosklyar.client.account.domain.Message)1 Levy (com.github.rosklyar.client.mosaic.domain.Levy)1 MosaicProperty (com.github.rosklyar.client.mosaic.domain.MosaicProperty)1 NodeClient (com.github.rosklyar.client.node.NodeClient)1 TransactionType (com.github.rosklyar.client.transaction.TransactionType)1 NemAnnounceResult (com.github.rosklyar.client.transaction.domain.NemAnnounceResult)1 Action (com.github.rosklyar.client.transaction.domain.importance.Action)1 com.github.rosklyar.client.transaction.domain.mosaic (com.github.rosklyar.client.transaction.domain.mosaic)1 Modification (com.github.rosklyar.client.transaction.domain.multisig.Modification)1 ADD_COSIGNATORY (com.github.rosklyar.client.transaction.domain.multisig.ModificationType.ADD_COSIGNATORY)1 REMOVE_COSIGNATORY (com.github.rosklyar.client.transaction.domain.multisig.ModificationType.REMOVE_COSIGNATORY)1 RelativeChange (com.github.rosklyar.client.transaction.domain.multisig.RelativeChange)1