Search in sources :

Example 6 with LockWhitelistEntry

use of co.rsk.peg.whitelist.LockWhitelistEntry in project rskj by rsksmart.

the class BridgeStorageProvider method getLockWhitelist.

public LockWhitelist getLockWhitelist() {
    if (lockWhitelist != null) {
        return lockWhitelist;
    }
    Pair<HashMap<Address, OneOffWhiteListEntry>, Integer> oneOffWhitelistAndDisableBlockHeightData = safeGetFromRepository(LOCK_ONE_OFF_WHITELIST_KEY, data -> BridgeSerializationUtils.deserializeOneOffLockWhitelistAndDisableBlockHeight(data, networkParameters));
    if (oneOffWhitelistAndDisableBlockHeightData == null) {
        lockWhitelist = new LockWhitelist(new HashMap<>());
        return lockWhitelist;
    }
    Map<Address, LockWhitelistEntry> whitelistedAddresses = new HashMap<>();
    whitelistedAddresses.putAll(oneOffWhitelistAndDisableBlockHeightData.getLeft());
    if (activations.isActive(RSKIP87)) {
        whitelistedAddresses.putAll(safeGetFromRepository(LOCK_UNLIMITED_WHITELIST_KEY, data -> BridgeSerializationUtils.deserializeUnlimitedLockWhitelistEntries(data, networkParameters)));
    }
    lockWhitelist = new LockWhitelist(whitelistedAddresses, oneOffWhitelistAndDisableBlockHeightData.getRight());
    return lockWhitelist;
}
Also used : OneOffWhiteListEntry(co.rsk.peg.whitelist.OneOffWhiteListEntry) FastBridgeFederationInformation(co.rsk.peg.fastbridge.FastBridgeFederationInformation) java.util(java.util) LockWhitelistEntry(co.rsk.peg.whitelist.LockWhitelistEntry) CoinbaseInformation(co.rsk.peg.bitcoin.CoinbaseInformation) Hex(org.spongycastle.util.encoders.Hex) DataWord(org.ethereum.vm.DataWord) RskAddress(co.rsk.core.RskAddress) IOException(java.io.IOException) LockWhitelist(co.rsk.peg.whitelist.LockWhitelist) Keccak256(co.rsk.crypto.Keccak256) Repository(org.ethereum.core.Repository) UnlimitedWhiteListEntry(co.rsk.peg.whitelist.UnlimitedWhiteListEntry) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) Script(co.rsk.bitcoinj.script.Script) Pair(org.apache.commons.lang3.tuple.Pair) BridgeConstants(co.rsk.config.BridgeConstants) co.rsk.bitcoinj.core(co.rsk.bitcoinj.core) ConsensusRule(org.ethereum.config.blockchain.upgrades.ConsensusRule) LockWhitelist(co.rsk.peg.whitelist.LockWhitelist) RskAddress(co.rsk.core.RskAddress) LockWhitelistEntry(co.rsk.peg.whitelist.LockWhitelistEntry)

Example 7 with LockWhitelistEntry

use of co.rsk.peg.whitelist.LockWhitelistEntry in project rskj by rsksmart.

the class Bridge method getLockWhitelistEntryByAddress.

public long getLockWhitelistEntryByAddress(Object[] args) {
    logger.trace("getLockWhitelistEntryByAddress");
    String addressBase58;
    try {
        addressBase58 = (String) args[0];
    } catch (Exception e) {
        logger.warn("Exception in getLockWhitelistEntryByAddress", e);
        return LOCK_WHITELIST_INVALID_ADDRESS_FORMAT_ERROR_CODE;
    }
    LockWhitelistEntry entry = bridgeSupport.getLockWhitelistEntryByAddress(addressBase58);
    if (entry == null) {
        // Empty string is returned when address is not found
        return LOCK_WHITELIST_ENTRY_NOT_FOUND_CODE;
    }
    return entry.getClass() == OneOffWhiteListEntry.class ? ((OneOffWhiteListEntry) entry).maxTransferValue().getValue() : LOCK_WHITELIST_UNLIMITED_MODE_CODE;
}
Also used : LockWhitelistEntry(co.rsk.peg.whitelist.LockWhitelistEntry) OneOffWhiteListEntry(co.rsk.peg.whitelist.OneOffWhiteListEntry) VMException(org.ethereum.vm.exception.VMException) IOException(java.io.IOException) BlockStoreException(co.rsk.bitcoinj.store.BlockStoreException)

Aggregations

LockWhitelistEntry (co.rsk.peg.whitelist.LockWhitelistEntry)7 OneOffWhiteListEntry (co.rsk.peg.whitelist.OneOffWhiteListEntry)6 RskAddress (co.rsk.core.RskAddress)5 LockWhitelist (co.rsk.peg.whitelist.LockWhitelist)4 BigInteger (java.math.BigInteger)4 Test (org.junit.Test)4 UnlimitedWhiteListEntry (co.rsk.peg.whitelist.UnlimitedWhiteListEntry)3 ActivationConfigsForTest (org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)3 Repository (org.ethereum.core.Repository)3 MutableRepository (org.ethereum.db.MutableRepository)3 DataWord (org.ethereum.vm.DataWord)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)3 co.rsk.bitcoinj.core (co.rsk.bitcoinj.core)2 Script (co.rsk.bitcoinj.script.Script)2 BlockStoreException (co.rsk.bitcoinj.store.BlockStoreException)2 BridgeConstants (co.rsk.config.BridgeConstants)2 Keccak256 (co.rsk.crypto.Keccak256)2 IOException (java.io.IOException)2 java.util (java.util)2