Search in sources :

Example 1 with PeginInstructionsProvider

use of co.rsk.peg.pegininstructions.PeginInstructionsProvider in project rskj by rsksmart.

the class BridgeSupportTest method assertLockingCap.

private void assertLockingCap(boolean shouldLock, boolean isLockingCapEnabled, Coin lockingCap, Coin amountSentToNewFed, Coin amountSentToOldFed, Coin amountInNewFed, Coin amountInOldFed) throws BlockStoreException, IOException, BridgeIllegalArgumentException {
    // Configure if locking cap should be evaluated
    ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class);
    when(activations.isActive(ConsensusRule.RSKIP134)).thenReturn(isLockingCapEnabled);
    BridgeConstants bridgeConstants = mock(BridgeConstants.class);
    when(bridgeConstants.getLegacyMinimumPeginTxValueInSatoshis()).thenReturn(Coin.SATOSHI);
    when(bridgeConstants.getBtcParams()).thenReturn(BridgeRegTestConstants.getInstance().getBtcParams());
    when(bridgeConstants.getBtc2RskMinimumAcceptableConfirmations()).thenReturn(1);
    when(bridgeConstants.getGenesisFeePerKb()).thenReturn(BridgeRegTestConstants.getInstance().getGenesisFeePerKb());
    when(bridgeConstants.getMaxRbtc()).thenReturn(BridgeRegTestConstants.getInstance().getMaxRbtc());
    // Configure locking cap
    when(bridgeConstants.getInitialLockingCap()).thenReturn(lockingCap);
    Repository repository = createRepository();
    Federation oldFederation = this.getFederation(bridgeConstants);
    BridgeStorageProvider provider = new BridgeStorageProvider(repository, PrecompiledContracts.BRIDGE_ADDR, bridgeConstants, activations);
    // We need a random new fed
    provider.setNewFederation(this.getFederation(bridgeConstants, Arrays.asList(BtcECKey.fromPrivate(Hex.decode("fb01")), BtcECKey.fromPrivate(Hex.decode("fb02")), BtcECKey.fromPrivate(Hex.decode("fb03")))));
    // Use genesis fed as old
    provider.setOldFederation(oldFederation);
    Coin currentFunds = Coin.ZERO;
    // Configure existing utxos in both federations
    if (amountInOldFed != null) {
        UTXO utxo = new UTXO(Sha256Hash.wrap(HashUtil.randomHash()), 0, amountInOldFed, 1, false, new Script(new byte[] {}));
        provider.getOldFederationBtcUTXOs().add(utxo);
        currentFunds = currentFunds.add(amountInOldFed);
    }
    if (amountInNewFed != null) {
        UTXO utxo = new UTXO(Sha256Hash.wrap(HashUtil.randomHash()), 0, amountInNewFed, 1, false, new Script(new byte[] {}));
        provider.getNewFederationBtcUTXOs().add(utxo);
        currentFunds = currentFunds.add(amountInNewFed);
    }
    // Fund bridge in RBTC, substracting the funds that we are indicating were locked in the federations (which means a user locked)
    co.rsk.core.Coin bridgeBalance = LIMIT_MONETARY_BASE.subtract(co.rsk.core.Coin.fromBitcoin(currentFunds));
    repository.addBalance(PrecompiledContracts.BRIDGE_ADDR, bridgeBalance);
    // The locking cap shouldn't be surpassed by the initial configuration
    Assert.assertFalse(isLockingCapEnabled && currentFunds.isGreaterThan(lockingCap));
    Coin lockValue = Coin.ZERO;
    int newUtxos = 0;
    // Create transaction setting the outputs to the configured values
    BtcTransaction tx = new BtcTransaction(bridgeConstants.getBtcParams());
    if (amountSentToOldFed != null) {
        tx.addOutput(amountSentToOldFed, provider.getOldFederation().getAddress());
        lockValue = lockValue.add(amountSentToOldFed);
        newUtxos++;
    }
    if (amountSentToNewFed != null) {
        tx.addOutput(amountSentToNewFed, provider.getNewFederation().getAddress());
        lockValue = lockValue.add(amountSentToNewFed);
        newUtxos++;
    }
    BtcECKey srcKey = new BtcECKey();
    tx.addInput(PegTestUtils.createHash(1), 0, ScriptBuilder.createInputScript(null, srcKey));
    // Create header and PMT
    byte[] bits = new byte[1];
    bits[0] = 0x3f;
    List<Sha256Hash> hashes = new ArrayList<>();
    hashes.add(tx.getHash());
    PartialMerkleTree pmt = new PartialMerkleTree(bridgeConstants.getBtcParams(), bits, hashes, 1);
    Sha256Hash merkleRoot = pmt.getTxnHashAndMerkleRoot(new ArrayList<>());
    co.rsk.bitcoinj.core.BtcBlock registerHeader = new co.rsk.bitcoinj.core.BtcBlock(bridgeConstants.getBtcParams(), 1, PegTestUtils.createHash(1), merkleRoot, 1, 1, 1, new ArrayList<BtcTransaction>());
    BtcBlockStoreWithCache btcBlockStore = mock(BtcBlockStoreWithCache.class);
    BtcBlockStoreWithCache.Factory mockFactory = mock(BtcBlockStoreWithCache.Factory.class);
    when(mockFactory.newInstance(repository, bridgeConstants, provider, activations)).thenReturn(btcBlockStore);
    Block executionBlock = Mockito.mock(Block.class);
    when(executionBlock.getNumber()).thenReturn(10L);
    // Get the tx sender public key
    byte[] data = tx.getInput(0).getScriptSig().getChunks().get(1).data;
    BtcECKey senderBtcKey = BtcECKey.fromPublicOnly(data);
    // Whitelist the addresses
    LockWhitelist whitelist = provider.getLockWhitelist();
    Address address = senderBtcKey.toAddress(bridgeConstants.getBtcParams());
    whitelist.put(address, new OneOffWhiteListEntry(address, lockValue));
    // The address is whitelisted
    Assert.assertThat(whitelist.isWhitelisted(address), is(true));
    BridgeSupport bridgeSupport = getBridgeSupport(bridgeConstants, provider, repository, new BtcLockSenderProvider(), new PeginInstructionsProvider(), executionBlock, mockFactory, activations);
    // Simulate blockchain
    int height = 1;
    mockChainOfStoredBlocks(btcBlockStore, registerHeader, height + bridgeConstants.getBtc2RskMinimumAcceptableConfirmations(), height);
    Transaction rskTx = mock(Transaction.class);
    Keccak256 hash = new Keccak256(HashUtil.keccak256(new byte[] {}));
    when(rskTx.getHash()).thenReturn(hash);
    // Try to register tx
    bridgeSupport.registerBtcTransaction(rskTx, tx.bitcoinSerialize(), height, pmt.bitcoinSerialize());
    bridgeSupport.save();
    // If the address is no longer whitelisted, it means it was consumed, whether the lock was rejected by lockingCap or not
    Assert.assertThat(whitelist.isWhitelisted(address), is(false));
    // The Btc transaction should have been processed
    assertTrue(bridgeSupport.isBtcTxHashAlreadyProcessed(tx.getHash()));
    co.rsk.core.Coin totalAmountExpectedToHaveBeenLocked = co.rsk.core.Coin.fromBitcoin(shouldLock ? lockValue : Coin.ZERO);
    RskAddress srcKeyRskAddress = new RskAddress(org.ethereum.crypto.ECKey.fromPrivate(srcKey.getPrivKey()).getAddress());
    // Verify amount was locked
    Assert.assertEquals(totalAmountExpectedToHaveBeenLocked, repository.getBalance(srcKeyRskAddress));
    Assert.assertEquals(bridgeBalance.subtract(totalAmountExpectedToHaveBeenLocked), repository.getBalance(PrecompiledContracts.BRIDGE_ADDR));
    if (!shouldLock) {
        // Release tx should have been created directly to the signatures stack
        BtcTransaction releaseTx = provider.getReleaseTransactionSet().getEntries().iterator().next().getTransaction();
        Assert.assertNotNull(releaseTx);
        // returns the funds to the sender
        Assert.assertEquals(1, releaseTx.getOutputs().size());
        Assert.assertEquals(address, releaseTx.getOutputs().get(0).getAddressFromP2PKHScript(bridgeConstants.getBtcParams()));
        Assert.assertEquals(lockValue, releaseTx.getOutputs().get(0).getValue().add(releaseTx.getFee()));
        // Uses the same UTXO(s)
        Assert.assertEquals(newUtxos, releaseTx.getInputs().size());
        for (int i = 0; i < newUtxos; i++) {
            TransactionInput input = releaseTx.getInput(i);
            Assert.assertEquals(tx.getHash(), input.getOutpoint().getHash());
            Assert.assertEquals(i, input.getOutpoint().getIndex());
        }
    }
}
Also used : RskAddress(co.rsk.core.RskAddress) BtcLockSenderProvider(co.rsk.peg.btcLockSender.BtcLockSenderProvider) LockWhitelist(co.rsk.peg.whitelist.LockWhitelist) PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation(co.rsk.peg.PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation) PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation(co.rsk.peg.PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation) RskAddress(co.rsk.core.RskAddress) BridgeConstants(co.rsk.config.BridgeConstants) Script(co.rsk.bitcoinj.script.Script) PeginInstructionsProvider(co.rsk.peg.pegininstructions.PeginInstructionsProvider) Keccak256(co.rsk.crypto.Keccak256) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) co.rsk.bitcoinj.core(co.rsk.bitcoinj.core) Repository(org.ethereum.core.Repository) MutableRepository(org.ethereum.db.MutableRepository) SimpleRskTransaction(co.rsk.peg.simples.SimpleRskTransaction) InternalTransaction(org.ethereum.vm.program.InternalTransaction) Transaction(org.ethereum.core.Transaction) Block(org.ethereum.core.Block) OneOffWhiteListEntry(co.rsk.peg.whitelist.OneOffWhiteListEntry)

Example 2 with PeginInstructionsProvider

use of co.rsk.peg.pegininstructions.PeginInstructionsProvider in project rskj by rsksmart.

the class BridgeSupportTest method validationsForRegisterBtcTransaction_invalid_block_merkle_root.

@Test
public void validationsForRegisterBtcTransaction_invalid_block_merkle_root() throws IOException, BlockStoreException, BridgeIllegalArgumentException {
    BridgeStorageProvider mockBridgeStorageProvider = mock(BridgeStorageProvider.class);
    when(mockBridgeStorageProvider.getHeightIfBtcTxhashIsAlreadyProcessed(any(Sha256Hash.class))).thenReturn(Optional.empty());
    BtcBlockStoreWithCache.Factory btcBlockStoreFactory = mock(BtcBlockStoreWithCache.Factory.class);
    BtcBlockStoreWithCache btcBlockStore = mock(BtcBlockStoreWithCache.class);
    when(btcBlockStoreFactory.newInstance(any(Repository.class), any(), any(), any())).thenReturn(btcBlockStore);
    // Create transaction
    BtcTransaction tx = new BtcTransaction(bridgeConstants.getBtcParams());
    BtcECKey srcKey = new BtcECKey();
    tx.addInput(PegTestUtils.createHash(1), 0, ScriptBuilder.createInputScript(null, srcKey));
    // Create tx and PMT. Also create a btc block, that has not relation with tx and PMT.
    // The tx will be rejected because merkle block doesn't match.
    byte[] bits = new byte[1];
    bits[0] = 0x3f;
    List<Sha256Hash> hashes = new ArrayList<>();
    hashes.add(tx.getHash());
    PartialMerkleTree pmt = new PartialMerkleTree(bridgeConstants.getBtcParams(), bits, hashes, 1);
    co.rsk.bitcoinj.core.BtcBlock btcBlock = new co.rsk.bitcoinj.core.BtcBlock(bridgeConstants.getBtcParams(), 1, PegTestUtils.createHash(), Sha256Hash.ZERO_HASH, 1, 1, 1, new ArrayList<>());
    int height = 1;
    mockChainOfStoredBlocks(btcBlockStore, btcBlock, height + bridgeConstants.getBtc2RskMinimumAcceptableConfirmations(), height);
    BridgeSupport bridgeSupport = new BridgeSupport(bridgeConstants, mockBridgeStorageProvider, mock(BridgeEventLogger.class), new BtcLockSenderProvider(), new PeginInstructionsProvider(), mock(Repository.class), mock(Block.class), mock(Context.class), mock(FederationSupport.class), btcBlockStoreFactory, mock(ActivationConfig.ForBlock.class));
    Assert.assertFalse(bridgeSupport.validationsForRegisterBtcTransaction(tx.getHash(), height, pmt.bitcoinSerialize(), tx.bitcoinSerialize()));
}
Also used : BtcLockSenderProvider(co.rsk.peg.btcLockSender.BtcLockSenderProvider) PeginInstructionsProvider(co.rsk.peg.pegininstructions.PeginInstructionsProvider) co.rsk.bitcoinj.core(co.rsk.bitcoinj.core) Repository(org.ethereum.core.Repository) MutableRepository(org.ethereum.db.MutableRepository) Block(org.ethereum.core.Block) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest) Test(org.junit.Test)

Example 3 with PeginInstructionsProvider

use of co.rsk.peg.pegininstructions.PeginInstructionsProvider in project rskj by rsksmart.

the class BridgeSupportTest method getFastBridgeWallet_ok.

@Test
public void getFastBridgeWallet_ok() {
    ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class);
    when(activations.isActive(ConsensusRule.RSKIP176)).thenReturn(true);
    Context btcContext = mock(Context.class);
    when(btcContext.getParams()).thenReturn(bridgeConstants.getBtcParams());
    BridgeSupport bridgeSupport = new BridgeSupport(bridgeConstants, mock(BridgeStorageProvider.class), mock(BridgeEventLogger.class), new BtcLockSenderProvider(), new PeginInstructionsProvider(), mock(Repository.class), mock(Block.class), btcContext, mock(FederationSupport.class), mock(BtcBlockStoreWithCache.Factory.class), activations);
    Federation fed = bridgeConstants.getGenesisFederation();
    Keccak256 derivationHash = PegTestUtils.createHash3(1);
    Script fastBridgeRedeemScript = FastBridgeRedeemScriptParser.createMultiSigFastBridgeRedeemScript(fed.getRedeemScript(), Sha256Hash.wrap(derivationHash.getBytes()));
    Script fastBridgeP2SH = ScriptBuilder.createP2SHOutputScript(fastBridgeRedeemScript);
    FastBridgeFederationInformation fastBridgeFederationInformation = new FastBridgeFederationInformation(derivationHash, fed.getP2SHScript().getPubKeyHash(), fastBridgeP2SH.getPubKeyHash());
    BtcTransaction tx = new BtcTransaction(bridgeConstants.getBtcParams());
    tx.addOutput(Coin.COIN, fastBridgeFederationInformation.getFastBridgeFederationAddress(bridgeConstants.getBtcParams()));
    List<UTXO> utxoList = new ArrayList<>();
    UTXO utxo = new UTXO(tx.getHash(), 0, Coin.COIN, 0, false, fastBridgeP2SH);
    utxoList.add(utxo);
    Wallet obtainedWallet = bridgeSupport.getFastBridgeWallet(btcContext, utxoList, fastBridgeFederationInformation);
    Assert.assertEquals(Coin.COIN, obtainedWallet.getBalance());
}
Also used : Script(co.rsk.bitcoinj.script.Script) PeginInstructionsProvider(co.rsk.peg.pegininstructions.PeginInstructionsProvider) Wallet(co.rsk.bitcoinj.wallet.Wallet) Keccak256(co.rsk.crypto.Keccak256) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) BtcLockSenderProvider(co.rsk.peg.btcLockSender.BtcLockSenderProvider) Repository(org.ethereum.core.Repository) MutableRepository(org.ethereum.db.MutableRepository) PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation(co.rsk.peg.PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation) PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation(co.rsk.peg.PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation) Block(org.ethereum.core.Block) FastBridgeFederationInformation(co.rsk.peg.fastbridge.FastBridgeFederationInformation) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest) Test(org.junit.Test)

Example 4 with PeginInstructionsProvider

use of co.rsk.peg.pegininstructions.PeginInstructionsProvider in project rskj by rsksmart.

the class BridgeSupportTest method addSignature_fedPubKey_no_belong_to_retiring_or_active_federation.

@Test
public void addSignature_fedPubKey_no_belong_to_retiring_or_active_federation() throws Exception {
    // Setup
    FederationSupport mockFederationSupport = mock(FederationSupport.class);
    BridgeStorageProvider provider = mock(BridgeStorageProvider.class);
    BridgeSupport bridgeSupport = new BridgeSupport(bridgeConstants, provider, mock(BridgeEventLogger.class), new BtcLockSenderProvider(), new PeginInstructionsProvider(), mock(Repository.class), mock(Block.class), new Context(bridgeConstants.getBtcParams()), mockFederationSupport, null, null);
    // Creates retiring federation
    List<BtcECKey> federation1Keys = Arrays.asList(BtcECKey.fromPrivate(Hex.decode("fa01")), BtcECKey.fromPrivate(Hex.decode("fa02")));
    federation1Keys.sort(BtcECKey.PUBKEY_COMPARATOR);
    Federation retiringFederation = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(federation1Keys), Instant.ofEpochMilli(1000L), 0L, btcParams);
    // Creates active federation
    List<BtcECKey> activeFederationKeys = Arrays.asList(BtcECKey.fromPrivate(Hex.decode("fa03")), BtcECKey.fromPrivate(Hex.decode("fa04")));
    activeFederationKeys.sort(BtcECKey.PUBKEY_COMPARATOR);
    Federation activeFederation = new Federation(FederationTestUtils.getFederationMembersWithBtcKeys(activeFederationKeys), Instant.ofEpochMilli(1000L), 0L, btcParams);
    when(mockFederationSupport.getActiveFederation()).thenReturn(activeFederation);
    when(mockFederationSupport.getRetiringFederation()).thenReturn(retiringFederation);
    bridgeSupport.addSignature(BtcECKey.fromPrivate(Hex.decode("fa05")), null, PegTestUtils.createHash3(1).getBytes());
    verify(provider, times(0)).getRskTxsWaitingForSignatures();
}
Also used : BtcLockSenderProvider(co.rsk.peg.btcLockSender.BtcLockSenderProvider) Repository(org.ethereum.core.Repository) MutableRepository(org.ethereum.db.MutableRepository) PeginInstructionsProvider(co.rsk.peg.pegininstructions.PeginInstructionsProvider) PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation(co.rsk.peg.PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation) PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation(co.rsk.peg.PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation) Block(org.ethereum.core.Block) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest) Test(org.junit.Test)

Example 5 with PeginInstructionsProvider

use of co.rsk.peg.pegininstructions.PeginInstructionsProvider in project rskj by rsksmart.

the class BridgeSupportTest method registerBtcTransaction_accepts_lock_tx_version1_after_rskip_170_activation.

@Test
public void registerBtcTransaction_accepts_lock_tx_version1_after_rskip_170_activation() throws BlockStoreException, IOException, PeginInstructionsException, BridgeIllegalArgumentException {
    // Arrange
    ActivationConfig.ForBlock activations = mock(ActivationConfig.ForBlock.class);
    when(activations.isActive(ConsensusRule.RSKIP170)).thenReturn(true);
    Federation federation1 = getFederation(bridgeConstants);
    Repository repository = createRepository();
    repository.addBalance(PrecompiledContracts.BRIDGE_ADDR, LIMIT_MONETARY_BASE);
    BtcECKey srcKey1 = new BtcECKey();
    ECKey key = ECKey.fromPublicOnly(srcKey1.getPubKey());
    Address btcAddressFromBtcLockSender = srcKey1.toAddress(btcParams);
    RskAddress rskDerivedAddress = new RskAddress(key.getAddress());
    RskAddress rskDestinationAddress = new RskAddress(new byte[20]);
    Coin amountToLock = Coin.COIN.multiply(10);
    BtcTransaction tx1 = new BtcTransaction(btcParams);
    tx1.addOutput(amountToLock, federation1.getAddress());
    tx1.addInput(PegTestUtils.createHash(1), 0, new Script(new byte[] {}));
    byte[] bits = new byte[1];
    bits[0] = 0x3f;
    List<Sha256Hash> hashes = new ArrayList<>();
    hashes.add(tx1.getHash());
    PartialMerkleTree pmtWithoutWitness = new PartialMerkleTree(btcParams, bits, hashes, 1);
    List<Sha256Hash> hashlist = new ArrayList<>();
    Sha256Hash blockMerkleRoot = pmtWithoutWitness.getTxnHashAndMerkleRoot(hashlist);
    co.rsk.bitcoinj.core.BtcBlock registerHeader = new co.rsk.bitcoinj.core.BtcBlock(btcParams, 1, PegTestUtils.createHash(1), blockMerkleRoot, 1, 1, 1, new ArrayList<>());
    int height = 50;
    StoredBlock block = new StoredBlock(registerHeader, new BigInteger("0"), height);
    BtcBlockStoreWithCache btcBlockStore = mock(BtcBlockStoreWithCache.class);
    co.rsk.bitcoinj.core.BtcBlock headBlock = new co.rsk.bitcoinj.core.BtcBlock(btcParams, 1, PegTestUtils.createHash(2), Sha256Hash.of(new byte[] { 1 }), 1, 1, 1, new ArrayList<>());
    StoredBlock chainHead = new StoredBlock(headBlock, new BigInteger("0"), 132);
    when(btcBlockStore.getChainHead()).thenReturn(chainHead);
    when(btcBlockStore.getStoredBlockAtMainChainHeight(block.getHeight())).thenReturn(block);
    BtcBlockStoreWithCache.Factory mockFactory = mock(BtcBlockStoreWithCache.Factory.class);
    when(mockFactory.newInstance(any(), any(), any(), any())).thenReturn(btcBlockStore);
    BridgeStorageProvider provider = new BridgeStorageProvider(repository, contractAddress, bridgeConstants, activations);
    provider.setNewFederation(federation1);
    BtcLockSenderProvider btcLockSenderProvider = getBtcLockSenderProvider(TxSenderAddressType.P2PKH, btcAddressFromBtcLockSender, rskDerivedAddress);
    PeginInstructionsProvider peginInstructionsProvider = getPeginInstructionsProviderForVersion1(rskDestinationAddress, Optional.empty());
    BridgeSupport bridgeSupport = getBridgeSupport(bridgeConstants, provider, repository, btcLockSenderProvider, peginInstructionsProvider, mock(Block.class), mockFactory, activations);
    // Act
    bridgeSupport.registerBtcTransaction(mock(Transaction.class), tx1.bitcoinSerialize(), height, pmtWithoutWitness.bitcoinSerialize());
    // Assert
    co.rsk.core.Coin totalAmountExpectedToHaveBeenLocked = co.rsk.core.Coin.fromBitcoin(amountToLock);
    Assert.assertEquals(co.rsk.core.Coin.ZERO, repository.getBalance(rskDerivedAddress));
    Assert.assertEquals(totalAmountExpectedToHaveBeenLocked, repository.getBalance(rskDestinationAddress));
    Assert.assertEquals(1, provider.getNewFederationBtcUTXOs().size());
    Assert.assertEquals(amountToLock, provider.getNewFederationBtcUTXOs().get(0).getValue());
    Assert.assertEquals(0, provider.getReleaseRequestQueue().getEntries().size());
    Assert.assertEquals(0, provider.getReleaseTransactionSet().getEntries().size());
    Assert.assertTrue(provider.getRskTxsWaitingForSignatures().isEmpty());
    Assert.assertTrue(provider.getHeightIfBtcTxhashIsAlreadyProcessed(tx1.getHash(true)).isPresent());
}
Also used : RskAddress(co.rsk.core.RskAddress) ECKey(org.ethereum.crypto.ECKey) BtcLockSenderProvider(co.rsk.peg.btcLockSender.BtcLockSenderProvider) PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation(co.rsk.peg.PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation) PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation(co.rsk.peg.PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation) RskAddress(co.rsk.core.RskAddress) Script(co.rsk.bitcoinj.script.Script) PeginInstructionsProvider(co.rsk.peg.pegininstructions.PeginInstructionsProvider) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) co.rsk.bitcoinj.core(co.rsk.bitcoinj.core) Repository(org.ethereum.core.Repository) MutableRepository(org.ethereum.db.MutableRepository) SimpleRskTransaction(co.rsk.peg.simples.SimpleRskTransaction) InternalTransaction(org.ethereum.vm.program.InternalTransaction) Transaction(org.ethereum.core.Transaction) BigInteger(java.math.BigInteger) Block(org.ethereum.core.Block) ActivationConfigsForTest(org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest) Test(org.junit.Test)

Aggregations

PeginInstructionsProvider (co.rsk.peg.pegininstructions.PeginInstructionsProvider)57 Test (org.junit.Test)51 BtcLockSenderProvider (co.rsk.peg.btcLockSender.BtcLockSenderProvider)50 ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)49 RskAddress (co.rsk.core.RskAddress)44 Repository (org.ethereum.core.Repository)43 ActivationConfigsForTest (org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)42 MutableRepository (org.ethereum.db.MutableRepository)42 Block (org.ethereum.core.Block)40 InternalTransaction (org.ethereum.vm.program.InternalTransaction)37 co.rsk.bitcoinj.core (co.rsk.bitcoinj.core)31 SimpleRskTransaction (co.rsk.peg.simples.SimpleRskTransaction)31 Transaction (org.ethereum.core.Transaction)31 ECKey (org.ethereum.crypto.ECKey)27 PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation (co.rsk.peg.PegTestUtils.createBaseInputScriptThatSpendsFromTheFederation)25 PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation (co.rsk.peg.PegTestUtils.createBaseRedeemScriptThatSpendsFromTheFederation)25 Script (co.rsk.bitcoinj.script.Script)16 LockWhitelist (co.rsk.peg.whitelist.LockWhitelist)16 BigInteger (java.math.BigInteger)14 OneOffWhiteListEntry (co.rsk.peg.whitelist.OneOffWhiteListEntry)10