use of co.rsk.bitcoinj.core.NetworkParameters in project rskj by rsksmart.
the class LockWhitelistTest method createWhitelist.
@Before
public void createWhitelist() {
NetworkParameters params = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
int existingPrivate = 300;
addresses = Arrays.stream(new Integer[] { 100, 200, existingPrivate, 400 }).map(i -> {
Address address = BtcECKey.fromPrivate(BigInteger.valueOf(i)).toAddress(params);
if (i == existingPrivate) {
existingAddress = address;
}
return address;
}).collect(Collectors.toMap(Function.identity(), i -> Coin.CENT));
whitelist = new LockWhitelist(addresses, 0);
}
use of co.rsk.bitcoinj.core.NetworkParameters 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.NetworkParameters 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.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 LockWhitelistTest method createWhitelist.
@Before
public void createWhitelist() {
NetworkParameters params = NetworkParameters.fromID(NetworkParameters.ID_REGTEST);
int existingPrivate = 300;
addresses = Arrays.stream(new Integer[] { 100, 200, existingPrivate, 400 }).map(i -> {
Address address = BtcECKey.fromPrivate(BigInteger.valueOf(i)).toAddress(params);
if (i == existingPrivate) {
existingAddress = address;
}
return address;
}).collect(Collectors.toMap(Function.identity(), i -> new OneOffWhiteListEntry(i, Coin.CENT)));
whitelist = new LockWhitelist(addresses, 0);
}
Aggregations