Search in sources :

Example 11 with MerkleBranch

use of co.rsk.peg.bitcoin.MerkleBranch in project rskj by rsksmart.

the class Bridge method getBtcTransactionConfirmations.

public int getBtcTransactionConfirmations(Object[] args) throws VMException {
    logger.trace("getBtcTransactionConfirmations");
    try {
        Sha256Hash btcTxHash = Sha256Hash.wrap((byte[]) args[0]);
        Sha256Hash btcBlockHash = Sha256Hash.wrap((byte[]) args[1]);
        int merkleBranchPath = ((BigInteger) args[2]).intValue();
        Object[] merkleBranchHashesArray = (Object[]) args[3];
        List<Sha256Hash> merkleBranchHashes = Arrays.stream(merkleBranchHashesArray).map(hash -> Sha256Hash.wrap((byte[]) hash)).collect(Collectors.toList());
        MerkleBranch merkleBranch = new MerkleBranch(merkleBranchHashes, merkleBranchPath);
        return bridgeSupport.getBtcTransactionConfirmations(btcTxHash, btcBlockHash, merkleBranch);
    } catch (Exception e) {
        logger.warn("Exception in getBtcTransactionConfirmations", e);
        throw new VMException("Exception in getBtcTransactionConfirmations", e);
    }
}
Also used : OneOffWhiteListEntry(co.rsk.peg.whitelist.OneOffWhiteListEntry) VMException(org.ethereum.vm.exception.VMException) Arrays(java.util.Arrays) LockWhitelistEntry(co.rsk.peg.whitelist.LockWhitelistEntry) LoggerFactory(org.slf4j.LoggerFactory) CallTransaction(org.ethereum.core.CallTransaction) RskAddress(co.rsk.core.RskAddress) ProgramSubtrace(co.rsk.rpc.modules.trace.ProgramSubtrace) Keccak256(co.rsk.crypto.Keccak256) Block(org.ethereum.core.Block) ArrayList(java.util.ArrayList) ActivationConfig(org.ethereum.config.blockchain.upgrades.ActivationConfig) BridgeConstants(co.rsk.config.BridgeConstants) co.rsk.bitcoinj.core(co.rsk.bitcoinj.core) PrecompiledContracts(org.ethereum.vm.PrecompiledContracts) BigInteger(java.math.BigInteger) MerkleBranch(co.rsk.peg.bitcoin.MerkleBranch) LogInfo(org.ethereum.vm.LogInfo) PanicProcessor(co.rsk.panic.PanicProcessor) Logger(org.slf4j.Logger) BtcTransactionFormatUtils(co.rsk.peg.utils.BtcTransactionFormatUtils) DataWord(org.ethereum.vm.DataWord) IOException(java.io.IOException) BlockStore(org.ethereum.db.BlockStore) Instant(java.time.Instant) Repository(org.ethereum.core.Repository) Collectors(java.util.stream.Collectors) ReceiptStore(org.ethereum.db.ReceiptStore) Program(org.ethereum.vm.program.Program) List(java.util.List) BlockStoreException(co.rsk.bitcoinj.store.BlockStoreException) ByteUtil(org.ethereum.util.ByteUtil) Optional(java.util.Optional) VisibleForTesting(com.google.common.annotations.VisibleForTesting) Transaction(org.ethereum.core.Transaction) ConsensusRule(org.ethereum.config.blockchain.upgrades.ConsensusRule) Constants(org.ethereum.config.Constants) VMException(org.ethereum.vm.exception.VMException) BigInteger(java.math.BigInteger) MerkleBranch(co.rsk.peg.bitcoin.MerkleBranch) VMException(org.ethereum.vm.exception.VMException) IOException(java.io.IOException) BlockStoreException(co.rsk.bitcoinj.store.BlockStoreException)

Aggregations

MerkleBranch (co.rsk.peg.bitcoin.MerkleBranch)11 BigInteger (java.math.BigInteger)11 ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)11 co.rsk.bitcoinj.core (co.rsk.bitcoinj.core)10 ActivationConfigsForTest (org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)10 MutableRepository (org.ethereum.db.MutableRepository)10 Test (org.junit.Test)10 Repository (org.ethereum.core.Repository)7 Block (org.ethereum.core.Block)6 BtcLockSenderProvider (co.rsk.peg.btcLockSender.BtcLockSenderProvider)5 PeginInstructionsProvider (co.rsk.peg.pegininstructions.PeginInstructionsProvider)5 Script (co.rsk.bitcoinj.script.Script)4 BlockStoreException (co.rsk.bitcoinj.store.BlockStoreException)4 BridgeConstants (co.rsk.config.BridgeConstants)4 RskAddress (co.rsk.core.RskAddress)4 Keccak256 (co.rsk.crypto.Keccak256)4 OneOffWhiteListEntry (co.rsk.peg.whitelist.OneOffWhiteListEntry)4 IOException (java.io.IOException)4 Instant (java.time.Instant)4 Constants (org.ethereum.config.Constants)4