Search in sources :

Example 1 with UTXO

use of co.rsk.bitcoinj.core.UTXO 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)

Aggregations

BtcTransaction (co.rsk.bitcoinj.core.BtcTransaction)1 Sha256Hash (co.rsk.bitcoinj.core.Sha256Hash)1 UTXO (co.rsk.bitcoinj.core.UTXO)1 Keccak256 (co.rsk.crypto.Keccak256)1 BigInteger (java.math.BigInteger)1 RLPList (org.ethereum.util.RLPList)1