use of co.rsk.bitcoinj.core.BtcBlock 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.BtcBlock 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.BtcBlock in project rskj by rsksmart.
the class MnrModuleImpl method submitBitcoinBlockTransactions.
@Override
public SubmittedBlockInfo submitBitcoinBlockTransactions(String blockHashHex, String blockHeaderHex, String coinbaseHex, String txnHashesHex) {
logger.debug("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.BtcBlock in project rskj by rsksmart.
the class GetBtcBlockchainBlockHeaderByHeightTest method getBtcBlockchainBlockHeaderByHeightTest_success.
private void getBtcBlockchainBlockHeaderByHeightTest_success(int times, ExecutionStats stats) throws VMException {
BridgeStorageProviderInitializer storageInitializer = generateInitializerForTest(1000, 2000);
executeAndAverage("getBtcBlockchainBlockHeaderByHeightTest_success", times, getABIEncoder(), storageInitializer, Helper.getZeroValueRandomSenderTxBuilder(), Helper.getRandomHeightProvider(10), stats, (environment, executionResult) -> {
BtcBlock btcBlock = byteArrayToBlockHeader(getByteFromResult(executionResult));
Assert.assertEquals(btcBlock.getHash(), expectedBlock.getHash());
});
}
use of co.rsk.bitcoinj.core.BtcBlock in project rskj by rsksmart.
the class GetBtcBlockchainParentBlockHeaderByHashTest method getBtcBlockchainParentBlockHeaderByHashTest_success.
private void getBtcBlockchainParentBlockHeaderByHashTest_success(int times, ExecutionStats stats) throws VMException {
BridgeStorageProviderInitializer storageInitializer = generateInitializerForTest(1000, 2000);
executeAndAverage("getBtcBlockchainParentBlockHeaderByHashTest_success", times, getABIEncoder(), storageInitializer, Helper.getZeroValueRandomSenderTxBuilder(), Helper.getRandomHeightProvider(10), stats, (environment, executionResult) -> {
BtcBlock btcBlock = byteArrayToBlockHeader(getByteFromResult(executionResult));
Assert.assertEquals(expectedBlock.getHash(), btcBlock.getHash());
});
}
Aggregations