Search in sources :

Example 6 with Sha256Hash

use of co.rsk.bitcoinj.core.Sha256Hash in project rskj by rsksmart.

the class BridgeState method create.

public static BridgeState create(BridgeConstants bridgeConstants, byte[] data) throws IOException {
    RLPList rlpList = (RLPList) RLP.decode2(data).get(0);
    byte[] btcBlockchainBestChainHeightBytes = rlpList.get(0).getRLPData();
    int btcBlockchainBestChainHeight = btcBlockchainBestChainHeightBytes == null ? 0 : (new BigInteger(1, btcBlockchainBestChainHeightBytes)).intValue();
    byte[] btcTxHashesAlreadyProcessedBytes = rlpList.get(1).getRLPData();
    Map<Sha256Hash, Long> btcTxHashesAlreadyProcessed = BridgeSerializationUtils.deserializeMapOfHashesToLong(btcTxHashesAlreadyProcessedBytes);
    byte[] btcUTXOsBytes = rlpList.get(2).getRLPData();
    List<UTXO> btcUTXOs = BridgeSerializationUtils.deserializeUTXOList(btcUTXOsBytes);
    byte[] rskTxsWaitingForSignaturesBytes = rlpList.get(3).getRLPData();
    SortedMap<Keccak256, BtcTransaction> rskTxsWaitingForSignatures = BridgeSerializationUtils.deserializeMap(rskTxsWaitingForSignaturesBytes, bridgeConstants.getBtcParams(), false);
    byte[] releaseRequestQueueBytes = rlpList.get(4).getRLPData();
    ReleaseRequestQueue releaseRequestQueue = BridgeSerializationUtils.deserializeReleaseRequestQueue(releaseRequestQueueBytes, bridgeConstants.getBtcParams());
    byte[] releaseTransactionSetBytes = rlpList.get(5).getRLPData();
    ReleaseTransactionSet releaseTransactionSet = BridgeSerializationUtils.deserializeReleaseTransactionSet(releaseTransactionSetBytes, bridgeConstants.getBtcParams());
    return new BridgeState(btcBlockchainBestChainHeight, btcTxHashesAlreadyProcessed, btcUTXOs, rskTxsWaitingForSignatures, releaseRequestQueue, releaseTransactionSet);
}
Also used : Sha256Hash(co.rsk.bitcoinj.core.Sha256Hash) BtcTransaction(co.rsk.bitcoinj.core.BtcTransaction) Keccak256(co.rsk.crypto.Keccak256) RLPList(org.ethereum.util.RLPList) UTXO(co.rsk.bitcoinj.core.UTXO) BigInteger(java.math.BigInteger)

Example 7 with Sha256Hash

use of co.rsk.bitcoinj.core.Sha256Hash in project rskj by rsksmart.

the class LockTest method isBtcTxHashAlreadyProcessed_no.

private void isBtcTxHashAlreadyProcessed_no(int times, ExecutionStats stats) {
    Sha256Hash hash = Sha256Hash.of(BigInteger.valueOf(new Random().nextLong()).toByteArray());
    ABIEncoder abiEncoder = (int executionIndex) -> Bridge.IS_BTC_TX_HASH_ALREADY_PROCESSED.encode(new Object[] { Hex.toHexString(hash.getBytes()) });
    executeAndAverage("isBtcTxHashAlreadyProcessed-no", times, abiEncoder, buildInitializer(), Helper.getZeroValueRandomSenderTxBuilder(), Helper.getRandomHeightProvider(10), stats);
}
Also used : Random(java.util.Random) Sha256Hash(co.rsk.bitcoinj.core.Sha256Hash)

Aggregations

Sha256Hash (co.rsk.bitcoinj.core.Sha256Hash)7 BigInteger (java.math.BigInteger)3 Random (java.util.Random)3 BtcBlock (co.rsk.bitcoinj.core.BtcBlock)2 Repository (org.ethereum.core.Repository)2 BtcTransaction (co.rsk.bitcoinj.core.BtcTransaction)1 PartialMerkleTree (co.rsk.bitcoinj.core.PartialMerkleTree)1 StoredBlock (co.rsk.bitcoinj.core.StoredBlock)1 UTXO (co.rsk.bitcoinj.core.UTXO)1 RskSystemProperties (co.rsk.config.RskSystemProperties)1 Keccak256 (co.rsk.crypto.Keccak256)1 RepositoryImplForTesting (co.rsk.db.RepositoryImplForTesting)1 BridgeStorageProvider (co.rsk.peg.BridgeStorageProvider)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 ObjectInputStream (java.io.ObjectInputStream)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 Triple (org.apache.commons.lang3.tuple.Triple)1 RLPList (org.ethereum.util.RLPList)1