use of co.rsk.bitcoinj.core.NetworkParameters 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.NetworkParameters in project rskj by rsksmart.
the class MnrModuleImpl method submitBitcoinBlockPartialMerkle.
@Override
public SubmittedBlockInfo submitBitcoinBlockPartialMerkle(String blockHashHex, String blockHeaderHex, String coinbaseHex, String merkleHashesHex, String blockTxnCountHex) {
logger.debug("submitBitcoinBlockPartialMerkle(): {}, {}, {}, {}, {}", blockHashHex, blockHeaderHex, coinbaseHex, merkleHashesHex, blockTxnCountHex);
if (merkleHashesHex.isEmpty()) {
throw new JsonRpcSubmitBlockException("The list of merkle hashes can't be empty");
}
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.NetworkParameters in project rskj by rsksmart.
the class MnrModuleImpl method submitBitcoinBlock.
@Override
public SubmittedBlockInfo submitBitcoinBlock(String bitcoinBlockHex) {
logger.debug("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.NetworkParameters in project rskj by rsksmart.
the class ForkDataDetectionCalculatorTest method setUp.
@BeforeClass
public static void setUp() {
NetworkParameters params = RegTestParams.get();
new Context(params);
serializer = params.getDefaultSerializer();
}
use of co.rsk.bitcoinj.core.NetworkParameters in project rskj by rsksmart.
the class BridgeTest method receiveHeader_before_RSKIP200.
@Test
public void receiveHeader_before_RSKIP200() throws VMException {
ActivationConfig activations = spy(ActivationConfigsForTest.genesis());
doReturn(false).when(activations).isActive(eq(RSKIP200), anyLong());
BridgeSupport bridgeSupportMock = mock(BridgeSupport.class);
Bridge bridge = spy(getBridgeInstance(bridgeSupportMock, activations));
NetworkParameters networkParameters = constants.bridgeConstants.getBtcParams();
co.rsk.bitcoinj.core.BtcBlock block = new co.rsk.bitcoinj.core.BtcBlock(networkParameters, 1, PegTestUtils.createHash(1), PegTestUtils.createHash(1), 1, Utils.encodeCompactBits(networkParameters.getMaxTarget()), 1, new ArrayList<>()).cloneAsHeader();
Object[] parameters = new Object[] { block.bitcoinSerialize() };
byte[] data = Bridge.RECEIVE_HEADER.encode(parameters);
bridge.execute(data);
assertNull(bridge.execute(data));
verify(bridge, never()).receiveHeader(any(Object[].class));
}
Aggregations