use of org.ethereum.core.Account in project rskj by rsksmart.
the class WalletTest method addAccountWithPassphraseAndTwoAccountsWithSeed.
@Test
public void addAccountWithPassphraseAndTwoAccountsWithSeed() {
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);
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 unlockAccountWithPassphrase.
@Test
public void unlockAccountWithPassphrase() {
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 account0 = wallet.getAccount(new RskAddress(address));
Assert.assertNull(account0);
Assert.assertTrue(wallet.unlockAccount(new RskAddress(address), "passphrase"));
Account account = wallet.getAccount(new RskAddress(address));
Assert.assertNotNull(account);
Assert.assertArrayEquals(address, account.getAddress().getBytes());
}
use of org.ethereum.core.Account in project rskj by rsksmart.
the class WalletTest method addAccountWithPassphraseAndWithSeed.
@Test
public void addAccountWithPassphraseAndWithSeed() {
Wallet wallet = WalletFactory.createWallet();
RskAddress addr1 = wallet.addAccount("passphrase");
Assert.assertNotNull(addr1);
byte[] address2 = wallet.addAccountWithSeed("seed");
Assert.assertNotNull(address2);
List<byte[]> addresses = wallet.getAccountAddresses();
Assert.assertNotNull(addresses);
Assert.assertFalse(addresses.isEmpty());
Assert.assertEquals(2, addresses.size());
byte[] addr = addresses.get(0);
Assert.assertNotNull(addr);
Assert.assertArrayEquals(address2, addr);
addr = addresses.get(1);
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 TxPoolModuleImplTest method createSampleTransaction.
private Transaction createSampleTransaction(int from, int to, long value, int nonce) {
Account sender = getAccount(from);
Account receiver = getAccount(to);
Transaction tx = new TransactionBuilder().sender(sender).receiver(receiver).nonce(nonce).value(BigInteger.valueOf(value)).build();
return tx;
}
use of org.ethereum.core.Account in project rskj by rsksmart.
the class TransactionFactoryHelper method createSampleTransaction.
public static Transaction createSampleTransaction(long nonce) {
Account sender = new AccountBuilder().name("sender").build();
Account receiver = new AccountBuilder().name("receiver").build();
Transaction tx = new TransactionBuilder().nonce(nonce).sender(sender).receiver(receiver).value(BigInteger.TEN).build();
return tx;
}
Aggregations