Search in sources :

Example 1 with Address

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);
}
Also used : BigInteger(java.math.BigInteger) Address(co.rsk.bitcoinj.core.Address) NetworkParameters(co.rsk.bitcoinj.core.NetworkParameters) Before(org.junit.Before)

Example 2 with Address

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));
}
Also used : Address(co.rsk.bitcoinj.core.Address) Test(org.junit.Test)

Example 3 with Address

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()));
}
Also used : Address(co.rsk.bitcoinj.core.Address) Test(org.junit.Test)

Example 4 with Address

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;
}
Also used : Address(co.rsk.bitcoinj.core.Address) RskAddress(co.rsk.core.RskAddress) BigInteger(java.math.BigInteger)

Aggregations

Address (co.rsk.bitcoinj.core.Address)4 BigInteger (java.math.BigInteger)2 Test (org.junit.Test)2 NetworkParameters (co.rsk.bitcoinj.core.NetworkParameters)1 RskAddress (co.rsk.core.RskAddress)1 Before (org.junit.Before)1