Package org.bitcoinj.params
Class BitcoinNetworkParams
java.lang.Object
org.bitcoinj.core.NetworkParameters
org.bitcoinj.params.BitcoinNetworkParams
- Direct Known Subclasses:
MainNetParams,RegTestParams,SigNetParams,TestNet3Params,UnitTestParams
Parameters for Bitcoin-like networks.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.protected Blocklazy-initialized by the first call toNetworkParameters.getGenesisBlock()static final intBlock reward halving interval (number of blocks)Fields inherited from class org.bitcoinj.core.NetworkParameters
addressHeader, addrSeeds, BIP16_ENFORCE_TIME, bip32HeaderP2PKHpriv, bip32HeaderP2PKHpub, bip32HeaderP2WPKHpriv, bip32HeaderP2WPKHpub, checkpoints, defaultSerializer, dnsSeeds, dumpedPrivateKeyHeader, id, interval, INTERVAL, majorityEnforceBlockUpgrade, majorityRejectBlockOutdated, majorityWindow, MAX_COINS, MAX_MONEY, maxTarget, network, p2shHeader, packetMagic, PAYMENT_PROTOCOL_ID_MAINNET, PAYMENT_PROTOCOL_ID_REGTEST, PAYMENT_PROTOCOL_ID_SIGNET, PAYMENT_PROTOCOL_ID_TESTNET, PAYMENT_PROTOCOL_ID_UNIT_TESTS, port, segwitAddressHrp, spendableCoinbaseDepth, subsidyDecreaseBlockCount, TARGET_SPACING, TARGET_TIMESPAN, targetTimespan -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcheckDifficultyTransitions(StoredBlock storedPrev, Block nextBlock, BlockStore blockStore) Throws an exception if the block's difficulty is not correct.static BitcoinNetworkParamsReturn network parameters for a network idgetBlockInflation(int height) A utility method that calculates how much new Bitcoin would be created by the block at the given height.Deprecated.Deprecated.Get one another way or construct your ownMonetaryFormatas needed.Deprecated.Construct and return a custom serializer.Deprecated.booleanDeprecated.final booleanisDifficultyTransitionPoint(int previousHeight) Checks if we are at a difficulty transition point.final booleanisRewardHalvingPoint(int previousHeight) Checks if we are at a reward halving point.static BitcoinNetworkParamsof(BitcoinNetwork network) Return network parameters for aBitcoinNetworkenumMethods inherited from class org.bitcoinj.core.NetworkParameters
allowEmptyPeerChain, equals, fromAddress, fromPmtProtocolID, getAddressHeader, getAddrSeeds, getBip32HeaderP2PKHpriv, getBip32HeaderP2PKHpub, getBip32HeaderP2WPKHpriv, getBip32HeaderP2WPKHpub, getBlockVerificationFlags, getDefaultSerializer, getDnsSeeds, getDumpedPrivateKeyHeader, getGenesisBlock, getId, getInterval, getMajorityEnforceBlockUpgrade, getMajorityRejectBlockOutdated, getMajorityWindow, getMaxTarget, getP2SHHeader, getPacketMagic, getPort, getProtocolVersionNum, getSegwitAddressHrp, getSpendableCoinbaseDepth, getSubsidyDecreaseBlockCount, getTargetTimespan, getTransactionVerificationFlags, hashCode, isCheckpoint, network, of, passesCheckpoint
-
Field Details
-
BITCOIN_SCHEME
Deprecated.Scheme part for Bitcoin URIs.- See Also:
-
REWARD_HALVING_INTERVAL
public static final int REWARD_HALVING_INTERVALBlock reward halving interval (number of blocks)- See Also:
-
genesisBlock
lazy-initialized by the first call toNetworkParameters.getGenesisBlock()
-
-
Constructor Details
-
BitcoinNetworkParams
No-args constructor
-
-
Method Details
-
fromID
Return network parameters for a network id- Parameters:
id- the network id- Returns:
- the network parameters for the given string ID or NULL if not recognized
-
of
Return network parameters for aBitcoinNetworkenum- Parameters:
network- the network- Returns:
- the network parameters for the given string ID
- Throws:
IllegalArgumentException- if unknown network
-
getPaymentProtocolId
Deprecated.- Specified by:
getPaymentProtocolIdin classNetworkParameters- Returns:
- the payment protocol network id string
-
isRewardHalvingPoint
public final boolean isRewardHalvingPoint(int previousHeight) Checks if we are at a reward halving point.- Parameters:
previousHeight- The height of the previous stored block- Returns:
- If this is a reward halving point
-
getBlockInflation
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.
The half-life is controlled by
NetworkParameters.getSubsidyDecreaseBlockCount().- Parameters:
height- the height of the block to calculate inflation for- Returns:
- block reward (inflation) for specified block
-
isDifficultyTransitionPoint
public final boolean isDifficultyTransitionPoint(int previousHeight) Checks if we are at a difficulty transition point.- Parameters:
previousHeight- The height of the previous stored block- Returns:
- If this is a difficulty transition point
-
checkDifficultyTransitions
public void checkDifficultyTransitions(StoredBlock storedPrev, Block nextBlock, BlockStore blockStore) throws VerificationException, BlockStoreException Description copied from class:NetworkParametersThrows an exception if the block's difficulty is not correct.- Specified by:
checkDifficultyTransitionsin classNetworkParameters- Parameters:
storedPrev- previous stored blocknextBlock- proposed blockblockStore- active BlockStore- Throws:
VerificationException- if the block's difficulty is not correct.BlockStoreException- if an error occurred accessing the BlockStore
-
getMaxMoney
Deprecated.Description copied from class:NetworkParametersReturns the number of coins that will be produced in total, on this network. Where not applicable, a very large number of coins is returned instead (e.g. the main coin issue for Dogecoin).- Specified by:
getMaxMoneyin classNetworkParameters- Returns:
- maximum number of coins for this network
-
getMonetaryFormat
Deprecated.Get one another way or construct your ownMonetaryFormatas needed.Description copied from class:NetworkParametersThe monetary object for this currency.- Specified by:
getMonetaryFormatin classNetworkParameters- Returns:
- formatting utility object
-
getSerializer
Description copied from class:NetworkParametersConstruct and return a custom serializer.- Specified by:
getSerializerin classNetworkParameters- Returns:
- the serializer
-
getUriScheme
Deprecated.Description copied from class:NetworkParametersScheme part for URIs, for example "bitcoin".- Specified by:
getUriSchemein classNetworkParameters- Returns:
- a string with the "scheme" part
-
hasMaxMoney
Deprecated.Description copied from class:NetworkParametersReturns whether this network has a maximum number of coins (finite supply) or not. Always returns true for Bitcoin, but exists to be overridden for other networks.- Specified by:
hasMaxMoneyin classNetworkParameters- Returns:
- true if network has a fixed maximum number of coins
-
BitcoinNetwork.BITCOIN_SCHEME