use of co.rsk.bitcoinj.core.Address in project rskj by rsksmart.
the class LockWhitelistTest method createWhitelist.
@Before
public void createWhitelist() {
NetworkParameters params = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
int existingPrivate = 300;
addresses = Arrays.stream(new Integer[] { 100, 200, existingPrivate, 400 }).map(i -> {
Address address = BtcECKey.fromPrivate(BigInteger.valueOf(i)).toAddress(params);
if (i == existingPrivate) {
existingAddress = address;
}
return address;
}).collect(Collectors.toMap(Function.identity(), i -> Coin.CENT));
whitelist = new LockWhitelist(addresses, 0);
}
use of co.rsk.bitcoinj.core.Address in project rskj by rsksmart.
the class LockWhitelistTest method add.
@Test
public void add() {
Address randomAddress = Address.fromBase58(NetworkParameters.fromID(NetworkParameters.ID_REGTEST), "n3WzdjG7S2GjDbY1pJYxsY1VSQDkm4KDcm");
Assert.assertFalse(whitelist.isWhitelisted(randomAddress));
Assert.assertFalse(whitelist.isWhitelisted(randomAddress.getHash160()));
Assert.assertTrue(whitelist.put(randomAddress, Coin.CENT));
Assert.assertTrue(whitelist.isWhitelisted(randomAddress));
Assert.assertTrue(whitelist.isWhitelisted(randomAddress.getHash160()));
Assert.assertFalse(whitelist.put(randomAddress, Coin.CENT));
}
use of co.rsk.bitcoinj.core.Address in project rskj by rsksmart.
the class LockWhitelistTest method isWhitelisted.
@Test
public void isWhitelisted() {
for (Address addr : addresses.keySet()) {
Assert.assertTrue(whitelist.isWhitelisted(addr));
Assert.assertTrue(whitelist.isWhitelisted(addr.getHash160()));
}
Address randomAddress = Address.fromBase58(NetworkParameters.fromID(NetworkParameters.ID_REGTEST), "n3PLxDiwWqa5uH7fSbHCxS6VAjD9Y7Rwkj");
Assert.assertFalse(whitelist.isWhitelisted(randomAddress));
Assert.assertFalse(whitelist.isWhitelisted(randomAddress.getHash160()));
}
use of co.rsk.bitcoinj.core.Address in project rskj by rsksmart.
the class RskForksBridgeTest method buildReleaseTx.
private Transaction buildReleaseTx() throws AddressFormatException {
String btcAddressString = "mhoDGMzHHDq2ZD6cFrKV9USnMfpxEtLwGm";
Address btcAddress = Address.fromBase58(RegTestParams.get(), btcAddressString);
long nonce = 2;
long value = 1000000000000000000l;
BigInteger gasPrice = BigInteger.valueOf(0);
BigInteger gasLimit = BigInteger.valueOf(100000);
Transaction rskTx = CallTransaction.createCallTransaction(config, nonce, gasPrice.longValue(), gasLimit.longValue(), PrecompiledContracts.BRIDGE_ADDR, value, Bridge.RELEASE_BTC);
rskTx.sign(keyHoldingRSKs.getPrivKeyBytes());
return rskTx;
}
Aggregations