use of org.ethereum.core.Account in project rskj by rsksmart.
the class ImmutableTransactionTest method createImmutableTransaction.
private static Transaction createImmutableTransaction() {
Account sender = new AccountBuilder().name("sender").build();
Account receiver = new AccountBuilder().name("receiver").build();
Transaction tx = new TransactionBuilder().sender(sender).receiver(receiver).value(BigInteger.TEN).nonce(2).immutable().build();
return tx;
}
use of org.ethereum.core.Account in project rskj by rsksmart.
the class WalletTest method lockAccount.
@Test
public void lockAccount() {
Wallet wallet = WalletFactory.createWallet();
byte[] address = wallet.addAccount("passphrase").getBytes();
Assert.assertNotNull(address);
Assert.assertTrue(wallet.unlockAccount(new RskAddress(address), "passphrase"));
Account account = wallet.getAccount(new RskAddress(address));
Assert.assertNotNull(account);
Assert.assertArrayEquals(address, account.getAddress().getBytes());
Assert.assertTrue(wallet.lockAccount(new RskAddress(address)));
Account account2 = wallet.getAccount(new RskAddress(address));
Assert.assertNull(account2);
}
use of org.ethereum.core.Account in project rskj by rsksmart.
the class WalletTest method addAccountWithPassphrase.
@Test
public void addAccountWithPassphrase() {
Wallet wallet = WalletFactory.createWallet();
byte[] address = wallet.addAccount("passphrase").getBytes();
Assert.assertNotNull(address);
List<byte[]> addresses = wallet.getAccountAddresses();
Assert.assertNotNull(addresses);
Assert.assertFalse(addresses.isEmpty());
Assert.assertEquals(1, addresses.size());
byte[] addr = addresses.get(0);
Assert.assertNotNull(addr);
Assert.assertArrayEquals(address, addr);
Account account = wallet.getAccount(new RskAddress(address), "passphrase");
Assert.assertNotNull(account);
Assert.assertArrayEquals(address, account.getAddress().getBytes());
}
use of org.ethereum.core.Account in project rskj by rsksmart.
the class WalletTest method addAndUnlockAccountWithPassphraseAndTwoAccountsWithSeed.
@Test
public void addAndUnlockAccountWithPassphraseAndTwoAccountsWithSeed() {
Wallet wallet = WalletFactory.createWallet();
RskAddress addr1 = wallet.addAccount("passphrase");
Assert.assertNotNull(addr1);
byte[] address2 = wallet.addAccountWithSeed("seed");
Assert.assertNotNull(address2);
byte[] address3 = wallet.addAccountWithSeed("seed2");
Assert.assertNotNull(address3);
wallet.unlockAccount(addr1, "passphrase", 10000);
List<byte[]> addresses = wallet.getAccountAddresses();
Assert.assertNotNull(addresses);
Assert.assertFalse(addresses.isEmpty());
Assert.assertEquals(3, addresses.size());
byte[] addr = addresses.get(0);
Assert.assertNotNull(addr);
Assert.assertArrayEquals(address2, addr);
addr = addresses.get(1);
Assert.assertNotNull(addr);
Assert.assertArrayEquals(address3, addr);
addr = addresses.get(2);
Assert.assertNotNull(addr);
Assert.assertArrayEquals(addr1.getBytes(), addr);
Account account = wallet.getAccount(addr1, "passphrase");
Assert.assertNotNull(account);
Assert.assertEquals(addr1, account.getAddress());
}
use of org.ethereum.core.Account in project rskj by rsksmart.
the class WalletTest method getUnknownAccount.
@Test
public void getUnknownAccount() {
Wallet wallet = WalletFactory.createWallet();
RskAddress addr = new RskAddress("0x0000000000000000000000000000000000000023");
Account account = wallet.getAccount(addr);
Assert.assertNull(account);
}
Aggregations