use of co.rsk.bitcoinj.core.BtcTransaction in project rskj by rsksmart.
the class Web3RskImpl method mnr_submitBitcoinBlockTransactions.
public SubmittedBlockInfo mnr_submitBitcoinBlockTransactions(String blockHashHex, String blockHeaderHex, String coinbaseHex, String txnHashesHex) {
logger.debug("mnr_submitBitcoinBlockTransactions(): {}, {}, {}, {}", blockHashHex, blockHeaderHex, coinbaseHex, txnHashesHex);
NetworkParameters params = RegTestParams.get();
new Context(params);
BtcBlock bitcoinBlockWithHeaderOnly = getBtcBlock(blockHeaderHex, params);
BtcTransaction coinbase = new BtcTransaction(params, Hex.decode(coinbaseHex));
String blockHashForMergedMining = extractBlockHashForMergedMining(coinbase);
List<String> txnHashes = parseHashes(txnHashesHex);
SubmitBlockResult result = minerServer.submitBitcoinBlockTransactions(blockHashForMergedMining, bitcoinBlockWithHeaderOnly, coinbase, txnHashes);
return parseResultAndReturn(result);
}
use of co.rsk.bitcoinj.core.BtcTransaction in project rskj by rsksmart.
the class Web3RskImpl method mnr_submitBitcoinBlockPartialMerkle.
public SubmittedBlockInfo mnr_submitBitcoinBlockPartialMerkle(String blockHashHex, String blockHeaderHex, String coinbaseHex, String merkleHashesHex, String blockTxnCountHex) {
logger.debug("mnr_submitBitcoinBlockPartialMerkle(): {}, {}, {}, {}, {}", blockHashHex, blockHeaderHex, coinbaseHex, merkleHashesHex, blockTxnCountHex);
NetworkParameters params = RegTestParams.get();
new Context(params);
BtcBlock bitcoinBlockWithHeaderOnly = getBtcBlock(blockHeaderHex, params);
BtcTransaction coinbase = new BtcTransaction(params, Hex.decode(coinbaseHex));
String blockHashForMergedMining = extractBlockHashForMergedMining(coinbase);
List<String> merkleHashes = parseHashes(merkleHashesHex);
int txnCount = Integer.parseInt(blockTxnCountHex, 16);
SubmitBlockResult result = minerServer.submitBitcoinBlockPartialMerkle(blockHashForMergedMining, bitcoinBlockWithHeaderOnly, coinbase, merkleHashes, txnCount);
return parseResultAndReturn(result);
}
use of co.rsk.bitcoinj.core.BtcTransaction in project rskj by rsksmart.
the class Web3RskImpl method mnr_submitBitcoinBlock.
public SubmittedBlockInfo mnr_submitBitcoinBlock(String bitcoinBlockHex) {
logger.debug("mnr_submitBitcoinBlock(): {}", bitcoinBlockHex.length());
NetworkParameters params = RegTestParams.get();
new Context(params);
BtcBlock bitcoinBlock = getBtcBlock(bitcoinBlockHex, params);
BtcTransaction coinbase = bitcoinBlock.getTransactions().get(0);
String blockHashForMergedMining = extractBlockHashForMergedMining(coinbase);
SubmitBlockResult result = minerServer.submitBitcoinBlock(blockHashForMergedMining, bitcoinBlock);
return parseResultAndReturn(result);
}
use of co.rsk.bitcoinj.core.BtcTransaction in project rskj by rsksmart.
the class StateForFederatorTest method serialize.
@Test
public void serialize() {
Keccak256 hash1 = new Keccak256(SHA3_1);
Keccak256 hash2 = new Keccak256(SHA3_2);
Keccak256 hash3 = new Keccak256(SHA3_3);
Keccak256 hash4 = new Keccak256(SHA3_4);
BtcTransaction tx1 = new BtcTransaction(NETWORK_PARAMETERS);
BtcTransaction tx2 = new BtcTransaction(NETWORK_PARAMETERS);
BtcTransaction tx3 = new BtcTransaction(NETWORK_PARAMETERS);
BtcTransaction tx4 = new BtcTransaction(NETWORK_PARAMETERS);
SortedMap<Keccak256, BtcTransaction> rskTxsWaitingForSignatures = new TreeMap<>();
rskTxsWaitingForSignatures.put(hash1, tx1);
rskTxsWaitingForSignatures.put(hash2, tx2);
SortedMap<Keccak256, Pair<BtcTransaction, Long>> rskTxsWaitingForBroadcasting = new TreeMap<>();
rskTxsWaitingForBroadcasting.put(hash3, Pair.of(tx3, 3L));
rskTxsWaitingForBroadcasting.put(hash4, Pair.of(tx4, 4L));
StateForFederator stateForFederator = new StateForFederator(rskTxsWaitingForSignatures);
byte[] encoded = stateForFederator.getEncoded();
Assert.assertTrue(encoded.length > 0);
StateForFederator reverseResult = new StateForFederator(encoded, NETWORK_PARAMETERS);
Assert.assertNotNull(reverseResult);
Assert.assertEquals(2, reverseResult.getRskTxsWaitingForSignatures().size());
Assert.assertEquals(tx1, reverseResult.getRskTxsWaitingForSignatures().get(hash1));
Assert.assertEquals(tx2, reverseResult.getRskTxsWaitingForSignatures().get(hash2));
Assert.assertTrue(checkKeys(reverseResult.getRskTxsWaitingForSignatures().keySet(), hash1, hash2));
}
use of co.rsk.bitcoinj.core.BtcTransaction 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);
}
Aggregations