Search in sources :

Example 1 with JsonRpcSubmitBlockException

use of co.rsk.rpc.exception.JsonRpcSubmitBlockException 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)

Aggregations

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