Search in sources :

Example 1 with Ed25519PrivateKey

use of com.hedera.hashgraph.sdk.crypto.ed25519.Ed25519PrivateKey in project hedera-sdk-java by hashgraph.

the class PrivateKeyFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    privateKey = view.findViewById(R.id.privateKey);
    publicKey = view.findViewById(R.id.publicKey);
    view.findViewById(R.id.button).setOnClickListener(v -> {
        final Ed25519PrivateKey key = Ed25519PrivateKey.generate();
        privateKey.setText(key.toString());
        publicKey.setText(key.publicKey.toString());
    });
}
Also used : Ed25519PrivateKey(com.hedera.hashgraph.sdk.crypto.ed25519.Ed25519PrivateKey)

Example 2 with Ed25519PrivateKey

use of com.hedera.hashgraph.sdk.crypto.ed25519.Ed25519PrivateKey in project hedera-sdk-java by hashgraph.

the class AccountBalanceFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    accountBalance = view.findViewById(R.id.accountBalance);
    accountId = view.findViewById(R.id.accountId);
    view.findViewById(R.id.button).setOnClickListener(v -> {
        try {
            final AccountId operatorId = AccountId.fromString(view.getResources().getString(R.string.operator_id));
            final Ed25519PrivateKey operatorKey = Ed25519PrivateKey.fromString(view.getResources().getString(R.string.operator_key));
            Client client = Client.forTestnet().setOperator(operatorId, operatorKey);
            final AccountId id = AccountId.fromString(accountId.getText().toString());
            new AccountBalanceAsyncTask(id).execute(client);
        } catch (IllegalArgumentException e) {
            accountBalance.setText("Error: " + e.getMessage());
        }
    });
}
Also used : Ed25519PrivateKey(com.hedera.hashgraph.sdk.crypto.ed25519.Ed25519PrivateKey) AccountId(com.hedera.hashgraph.sdk.account.AccountId) Client(com.hedera.hashgraph.sdk.Client)

Example 3 with Ed25519PrivateKey

use of com.hedera.hashgraph.sdk.crypto.ed25519.Ed25519PrivateKey in project hedera-sdk-java by hashgraph.

the class CryptoTransferFragment method onViewCreated.

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
    recipientAccountId = view.findViewById(R.id.recipientAccountId);
    amountToSend = view.findViewById(R.id.amountToSend);
    resultText = view.findViewById(R.id.transferResult);
    view.findViewById(R.id.sendHbar).setOnClickListener(v -> {
        try {
            final AccountId operatorId = AccountId.fromString(view.getResources().getString(R.string.operator_id));
            final Ed25519PrivateKey operatorKey = Ed25519PrivateKey.fromString(view.getResources().getString(R.string.operator_key));
            Client client = Client.forTestnet().setOperator(operatorId, operatorKey);
            final AccountId recipientId = AccountId.fromString(recipientAccountId.getText().toString());
            final Hbar amount = new Hbar(new BigDecimal(amountToSend.getText().toString()).longValueExact());
            new TransferAsyncTask(operatorId, recipientId, amount).execute(client);
        } catch (Throwable e) {
            resultText.setText("Error: " + e.getMessage());
        }
    });
}
Also used : Ed25519PrivateKey(com.hedera.hashgraph.sdk.crypto.ed25519.Ed25519PrivateKey) AccountId(com.hedera.hashgraph.sdk.account.AccountId) Hbar(com.hedera.hashgraph.sdk.Hbar) Client(com.hedera.hashgraph.sdk.Client) BigDecimal(java.math.BigDecimal)

Aggregations

Ed25519PrivateKey (com.hedera.hashgraph.sdk.crypto.ed25519.Ed25519PrivateKey)3 Client (com.hedera.hashgraph.sdk.Client)2 AccountId (com.hedera.hashgraph.sdk.account.AccountId)2 Hbar (com.hedera.hashgraph.sdk.Hbar)1 BigDecimal (java.math.BigDecimal)1