Search in sources :

Example 1 with NemAnnounceResult

use of com.github.rosklyar.client.transaction.domain.NemAnnounceResult 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 2 with NemAnnounceResult

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

the class SecureTransactionClient method addCosignatoriesToMultisigAccount.

@Override
public NemAnnounceResult addCosignatoriesToMultisigAccount(String privateKey, List<String> cosignatories, int relativeChange, String multisigPublicKey, int timeToLiveInSeconds) {
    Signer signer = new DefaultSigner(privateKey);
    int currentTime = nodeClient.extendedInfo().nisInfo.currentTime;
    List<Modification> modifications = cosignatories.stream().map(cosignatory -> new Modification(ADD_COSIGNATORY.type, cosignatory)).collect(toList());
    return modifyMultisigAccountTransaction(signer, modifications, relativeChange, multisigPublicKey, currentTime, timeToLiveInSeconds);
}
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)

Example 3 with NemAnnounceResult

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

the class TransactionClientTest method multisigNemTransfer.

@Test
void multisigNemTransfer() {
    NemAnnounceResult nemAnnounceResult = transactionClient.multisigTransferNem("2ee2a08ad2ebc1371330c9977d15e52f482aa514554e085bec5ed076e8b11581", "TCHCCSUCSBE2OSYXLISPYGOVLOVZYCYYI5V73K4Y", 1000000, "test multisig", "d9728f3002d6292d54aa2e5c75f1e72bb7f7b800645c46e91171935285e77747", 3600);
    assertNotNull(nemAnnounceResult.innerTransactionHash);
    NemAnnounceResult cosignNemAnnounceResult = transactionClient.cosignTransaction("fcf0dadc958510dca65651df81aa22c82b2bfe5b29bf8dfb92816bc5f1f11a54", nemAnnounceResult.innerTransactionHash.data, "TD4F657BT4MDBAJXMOZR37MN5T2CRXQW66MPSONE", 3600);
    assertEquals(1, cosignNemAnnounceResult.code);
}
Also used : NemAnnounceResult(com.github.rosklyar.client.transaction.domain.NemAnnounceResult) Test(org.junit.jupiter.api.Test)

Example 4 with NemAnnounceResult

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

the class TransactionClientTest method importanceTransfer.

@Test
void importanceTransfer() {
    NemAnnounceResult nemAnnounceResult = transactionClient.importanceTransfer("fcf0dadc958510dca65651df81aa22c82b2bfe5b29bf8dfb92816bc5f1f11a54", ACTIVATE, "82bfa081e42631c0edc1f16b7a5b0534a5b2e4b88cbce709c623a70192e93b7a", 3600);
    assertEquals(1, nemAnnounceResult.code);
}
Also used : NemAnnounceResult(com.github.rosklyar.client.transaction.domain.NemAnnounceResult) Test(org.junit.jupiter.api.Test)

Example 5 with NemAnnounceResult

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

the class TransactionClientTest method makeMosaicTransfer.

@Test
void makeMosaicTransfer() {
    MosaicTransfer mosaicTransfer = MosaicTransfer.builder().mosaicId(new MosaicId("library", "testcoin")).quantity(3000).build();
    NemAnnounceResult nemAnnounceResult = transactionClient.transferMosaics("fcf0dadc958510dca65651df81aa22c82b2bfe5b29bf8dfb92816bc5f1f11a54", "TDIOE7BZR4J3DXNJ4SL6WOE4HM3QUI3PVUWW3YI3", newArrayList(mosaicTransfer), 2, "test mosaic", 3600);
    assertEquals(1, nemAnnounceResult.code);
}
Also used : MosaicTransfer(com.github.rosklyar.client.transaction.domain.mosaic.MosaicTransfer) MosaicId(com.github.rosklyar.client.transaction.domain.mosaic.MosaicId) NemAnnounceResult(com.github.rosklyar.client.transaction.domain.NemAnnounceResult) Test(org.junit.jupiter.api.Test)

Aggregations

NemAnnounceResult (com.github.rosklyar.client.transaction.domain.NemAnnounceResult)18 Test (org.junit.jupiter.api.Test)15 MosaicId (com.github.rosklyar.client.transaction.domain.mosaic.MosaicId)6 Levy (com.github.rosklyar.client.mosaic.domain.Levy)4 Hash (com.github.rosklyar.client.account.domain.Hash)3 Message (com.github.rosklyar.client.account.domain.Message)3 MosaicProperty (com.github.rosklyar.client.mosaic.domain.MosaicProperty)3 NodeClient (com.github.rosklyar.client.node.NodeClient)3 TransactionType (com.github.rosklyar.client.transaction.TransactionType)3 ProvisionNamespaceTransaction (com.github.rosklyar.client.transaction.domain.ProvisionNamespaceTransaction)3 RequestAnnounce (com.github.rosklyar.client.transaction.domain.RequestAnnounce)3 Transaction (com.github.rosklyar.client.transaction.domain.Transaction)3 Action (com.github.rosklyar.client.transaction.domain.importance.Action)3 ImportanceTransferTransaction (com.github.rosklyar.client.transaction.domain.importance.ImportanceTransferTransaction)3 com.github.rosklyar.client.transaction.domain.mosaic (com.github.rosklyar.client.transaction.domain.mosaic)3 Modification (com.github.rosklyar.client.transaction.domain.multisig.Modification)3 ADD_COSIGNATORY (com.github.rosklyar.client.transaction.domain.multisig.ModificationType.ADD_COSIGNATORY)3 REMOVE_COSIGNATORY (com.github.rosklyar.client.transaction.domain.multisig.ModificationType.REMOVE_COSIGNATORY)3 MultisigTransaction (com.github.rosklyar.client.transaction.domain.multisig.MultisigTransaction)3 RelativeChange (com.github.rosklyar.client.transaction.domain.multisig.RelativeChange)3