Search in sources :

Example 1 with SubmitBlockResult

use of co.rsk.mine.SubmitBlockResult 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);
}
Also used : Context(co.rsk.bitcoinj.core.Context) SubmitBlockResult(co.rsk.mine.SubmitBlockResult) NetworkParameters(co.rsk.bitcoinj.core.NetworkParameters) BtcTransaction(co.rsk.bitcoinj.core.BtcTransaction) BtcBlock(co.rsk.bitcoinj.core.BtcBlock)

Example 2 with SubmitBlockResult

use of co.rsk.mine.SubmitBlockResult 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);
}
Also used : Context(co.rsk.bitcoinj.core.Context) SubmitBlockResult(co.rsk.mine.SubmitBlockResult) NetworkParameters(co.rsk.bitcoinj.core.NetworkParameters) BtcTransaction(co.rsk.bitcoinj.core.BtcTransaction) BtcBlock(co.rsk.bitcoinj.core.BtcBlock) JsonRpcSubmitBlockException(co.rsk.rpc.exception.JsonRpcSubmitBlockException)

Example 3 with SubmitBlockResult

use of co.rsk.mine.SubmitBlockResult 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);
}
Also used : Context(co.rsk.bitcoinj.core.Context) SubmitBlockResult(co.rsk.mine.SubmitBlockResult) NetworkParameters(co.rsk.bitcoinj.core.NetworkParameters) BtcTransaction(co.rsk.bitcoinj.core.BtcTransaction) BtcBlock(co.rsk.bitcoinj.core.BtcBlock)

Aggregations

BtcBlock (co.rsk.bitcoinj.core.BtcBlock)3 BtcTransaction (co.rsk.bitcoinj.core.BtcTransaction)3 Context (co.rsk.bitcoinj.core.Context)3 NetworkParameters (co.rsk.bitcoinj.core.NetworkParameters)3 SubmitBlockResult (co.rsk.mine.SubmitBlockResult)3 JsonRpcSubmitBlockException (co.rsk.rpc.exception.JsonRpcSubmitBlockException)1