JDK 11
String seed = "fragile because fox snap picnic mean art observe vicious program chicken purse text hidden chest";
AccountFactory af = new AccountFactory(AccountFactory.testnetByte());
Account acc = af.createFromSeed(seed);
import com.ltonetwork.client.types.PublicKey;
import com.ltonetwork.client.core.AccountFactory;
PublicKey signPublicKey = new PublicKey("wJ4WH8dD88fSkNdFQRjaAhjFUZzZhV5yiDLDwNUnp6bYwRXrvWV8MJhQ9HL9uqMDG1n7XpTGZx7PafqaayQV8Rp", Encoding.BASE58);
AccountFactory af = new AccountFactory(AccountFactory.testnetByte());
Account acc = af.createPublic(signPublicKey);
import com.ltonetwork.client.types.Key;
import com.ltonetwork.client.types.KeyPair;
import com.ltonetwork.client.core.AccountFactory;
KeyPair signKeyPair = new KeyPair (
new PublicKey("wJ4WH8dD88fSkNdFQRjaAhjFUZzZhV5yiDLDwNUnp6bYwRXrvWV8MJhQ9HL9uqMDG1n7XpTGZx7PafqaayQV8Rp", Encoding.BASE58),
new PrivateKey("FkU1XyfrCftc4pQKXCrrDyRLSnifX1SMvmx1CYiiyB3Y", Encoding.BASE58)
);
KeyPair encryptKeyPair = new KeyPair (
new PublicKey("BVv1ZuE3gKFa6krwWJQwEmrLYUESuUabNCXgYTmCoBt6", Encoding.BASE58),
new PrivateKey("BnjFJJarge15FiqcxrB7Mzt68nseBXXR4LQ54qFBsWJN", Encoding.BASE58)
);
Address address = new Address("3JmCa4jLVv7Yn2XkCnBUGsa7WNFVEMxAfWe");
AccountFactory af = new AccountFactory(AccountFactory.testnetByte());
Account acc = af.create(
signKeyPair,
encryptKeyPair,
address);
Properties that are specified will be verified. Properties that are omitted will be generated where possible.
import com.ltonetwork.seasalt.sign.Signature;
Signature sig = account.sign("my message");
import com.ltonetwork.seasalt.sign.Signature;
String message = "my message";
Signature sig = account.sign(message);
boolean isValid = account.verify(sig, message); // True
String message = "my message";
byte[] encrypted = senderAccount.encrypt(recipientAccount, message);
You can use senderAccount.encrypt(senderAccount, message);
to encrypt a message for yourself.
String message = "my message";
byte[] decrypted = recipientAccount.decrypt(senderAccount, message);
You can use senderAccount.encrypt(senderAccount, message);
to decrypt a message from yourself.
PublicNode publicNode = new PublicNode(new URI("https://testnet.lto.network"), "myApiKey");
int amount = 1000; // Amount of LTO to transfer
Address recipient = new Address("3JmCa4jLVv7Yn2XkCnBUGsa7WNFVEMxAfWe");
Transfer tx = new Transfer(amount, recipient);
tx.signWith(myAccount);
publicNode.broadcast(tx);