Search in sources :

Example 1 with NetworkParameters

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);
}
Also used : BigInteger(java.math.BigInteger) Address(co.rsk.bitcoinj.core.Address) NetworkParameters(co.rsk.bitcoinj.core.NetworkParameters) Before(org.junit.Before)

Example 2 with NetworkParameters

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

Example 3 with NetworkParameters

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

Example 4 with NetworkParameters

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);
}
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 5 with NetworkParameters

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);
}
Also used : BigInteger(java.math.BigInteger) Address(co.rsk.bitcoinj.core.Address) NetworkParameters(co.rsk.bitcoinj.core.NetworkParameters) Before(org.junit.Before)

Aggregations

NetworkParameters (co.rsk.bitcoinj.core.NetworkParameters)28 BtcBlock (co.rsk.bitcoinj.core.BtcBlock)11 Test (org.junit.Test)9 BtcTransaction (co.rsk.bitcoinj.core.BtcTransaction)8 Context (co.rsk.bitcoinj.core.Context)7 BigInteger (java.math.BigInteger)6 Address (co.rsk.bitcoinj.core.Address)5 ActivationConfigsForTest (org.ethereum.config.blockchain.upgrades.ActivationConfigsForTest)5 ECKey (org.ethereum.crypto.ECKey)5 DeterministicKey (co.rsk.bitcoinj.crypto.DeterministicKey)4 co.rsk.bitcoinj.core (co.rsk.bitcoinj.core)3 BtcECKey (co.rsk.bitcoinj.core.BtcECKey)3 BlockGenerator (co.rsk.blockchain.utils.BlockGenerator)3 RskAddress (co.rsk.core.RskAddress)3 Keccak256 (co.rsk.crypto.Keccak256)3 SubmitBlockResult (co.rsk.mine.SubmitBlockResult)3 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 ActivationConfig (org.ethereum.config.blockchain.upgrades.ActivationConfig)3 CallTransaction (org.ethereum.core.CallTransaction)3