/** * <p>A utility method that calculates how much new Bitcoin would be created by the block at the given height. * The inflation of Bitcoin is predictable and drops roughly every 4 years (210,000 blocks). At the dawn of * the system it was 50 coins per block, in late 2012 it went to 25 coins per block, and so on. The size of * a coinbase transaction is inflation plus fees.</p> * * <p>The half-life is controlled by {@link org.bitcoinj.core.NetworkParameters#getSubsidyDecreaseBlockCount()}. * </p> */ public Coin getBlockInflation(int height) { return FIFTY_COINS.shiftRight(height / params.getSubsidyDecreaseBlockCount()); }
/** * <p>A utility method that calculates how much new Bitcoin would be created by the block at the given height. * The inflation of Bitcoin is predictable and drops roughly every 4 years (210,000 blocks). At the dawn of * the system it was 50 coins per block, in late 2012 it went to 25 coins per block, and so on. The size of * a coinbase transaction is inflation plus fees.</p> * * <p>The half-life is controlled by {@link org.bitcoinj.core.NetworkParameters#getSubsidyDecreaseBlockCount()}. * </p> */ public Coin getBlockInflation(int height) { return FIFTY_COINS.shiftRight(height / params.getSubsidyDecreaseBlockCount()); }
/** * <p>A utility method that calculates how much new Bitcoin would be created by the block at the given height. * The inflation of Bitcoin is predictable and drops roughly every 4 years (210,000 blocks). At the dawn of * the system it was 50 coins per block, in late 2012 it went to 25 coins per block, and so on. The size of * a coinbase transaction is inflation plus fees.</p> * * <p>The half-life is controlled by {@link org.bitcoinj.core.NetworkParameters#getSubsidyDecreaseBlockCount()}. * </p> */ public Coin getBlockInflation(int height) { return FIFTY_COINS.shiftRight(height / params.getSubsidyDecreaseBlockCount()); }
for (int i = params.getSubsidyDecreaseBlockCount(); i <= nPrevHeight; i += params.getSubsidyDecreaseBlockCount()) { nSubsidy = nSubsidy.subtract(nSubsidy.div(14));
private NewBlock createNextBlock(Block baseBlock, int nextBlockHeight, @Nullable TransactionOutPointWithValue prevOut, Coin additionalCoinbaseValue) throws ScriptException { Integer height = blockToHeightMap.get(baseBlock.getHash()); if (height != null) checkState(height == nextBlockHeight - 1); Coin coinbaseValue = FIFTY_COINS.shiftRight(nextBlockHeight / params.getSubsidyDecreaseBlockCount()) .add((prevOut != null ? prevOut.value.subtract(SATOSHI) : ZERO)) .add(additionalCoinbaseValue == null ? ZERO : additionalCoinbaseValue); Block block = baseBlock.createNextBlockWithCoinbase(Block.BLOCK_VERSION_GENESIS, coinbaseOutKeyPubKey, coinbaseValue, nextBlockHeight); Transaction t = new Transaction(params); if (prevOut != null) { // Entirely invalid scriptPubKey to ensure we aren't pre-verifying too much t.addOutput(new TransactionOutput(params, t, ZERO, new byte[] {(byte)(new Random().nextInt() & 0xff), uniquenessCounter++})); // Spendable output t.addOutput(new TransactionOutput(params, t, SATOSHI, new byte[] {OP_1})); addOnlyInputToTransaction(t, prevOut); block.addTransaction(t); block.solve(); } return new NewBlock(block, prevOut == null ? null : new TransactionOutPointWithValue(t, 1)); } private NewBlock createNextBlock(NewBlock baseBlock, int nextBlockHeight, @Nullable TransactionOutPointWithValue prevOut,