public abstract class NetworkParameters extends Object
NetworkParameters contains the data needed for working with an instantiation of a Bitcoin chain.
This is an abstract class, concrete instantiations can be found in the params package. There are four:
one for the main network (MainNetParams
), one for the public test network, and two others that are
intended for unit testing and local app development purposes. Although this class contains some aliases for
them, you are encouraged to call the static get() methods on each specific params class directly.
Modifier and Type | Class and Description |
---|---|
static class |
NetworkParameters.ProtocolVersion |
Modifier and Type | Field and Description |
---|---|
protected int[] |
acceptableAddressCodes |
protected int |
addressHeader |
protected int[] |
addrSeeds |
protected byte[] |
alertSigningKey |
static int |
BIP16_ENFORCE_TIME
Blocks with a timestamp after this should enforce BIP 16, aka "Pay to script hash".
|
protected int |
bip32HeaderPriv |
protected int |
bip32HeaderPub |
protected Map<Integer,Sha256Hash> |
checkpoints |
protected MessageSerializer |
defaultSerializer |
protected String[] |
dnsSeeds |
protected int |
dumpedPrivateKeyHeader |
protected Block |
genesisBlock |
protected HttpDiscovery.Details[] |
httpSeeds |
protected String |
id
See getId().
|
static String |
ID_MAINNET
The string returned by getId() for the main, production network where people trade things.
|
static String |
ID_REGTEST
The string returned by getId() for regtest mode.
|
static String |
ID_TESTNET
The string returned by getId() for the testnet.
|
static String |
ID_UNITTESTNET
Unit test network.
|
protected int |
interval |
static int |
INTERVAL |
protected int |
majorityEnforceBlockUpgrade
Used to check majorities for block version upgrade
|
protected int |
majorityRejectBlockOutdated |
protected int |
majorityWindow |
static long |
MAX_COINS
The maximum number of coins to be generated
|
static Coin |
MAX_MONEY
The maximum money to be generated
|
protected BigInteger |
maxTarget |
protected int |
p2shHeader |
protected long |
packetMagic |
static String |
PAYMENT_PROTOCOL_ID_MAINNET
The string used by the payment protocol to represent the main net.
|
static String |
PAYMENT_PROTOCOL_ID_REGTEST |
static String |
PAYMENT_PROTOCOL_ID_TESTNET
The string used by the payment protocol to represent the test net.
|
static String |
PAYMENT_PROTOCOL_ID_UNIT_TESTS
The string used by the payment protocol to represent unit testing (note that this is non-standard).
|
protected int |
port |
static byte[] |
SATOSHI_KEY
The alert signing key originally owned by Satoshi, and now passed on to Gavin along with a few others.
|
protected int |
spendableCoinbaseDepth
The depth of blocks required for a coinbase transaction to be spendable.
|
protected int |
subsidyDecreaseBlockCount |
static int |
TARGET_SPACING |
static int |
TARGET_TIMESPAN |
protected int |
targetTimespan |
Modifier | Constructor and Description |
---|---|
protected |
NetworkParameters() |
Modifier and Type | Method and Description |
---|---|
boolean |
allowEmptyPeerChain()
If we are running in testnet-in-a-box mode, we allow connections to nodes with 0 non-genesis blocks.
|
abstract void |
checkDifficultyTransitions(StoredBlock storedPrev,
Block next,
BlockStore blockStore)
Throws an exception if the block's difficulty is not correct.
|
boolean |
equals(Object o) |
static NetworkParameters |
fromID(String id)
Returns the network parameters for the given string ID or NULL if not recognized.
|
static NetworkParameters |
fromPmtProtocolID(String pmtProtocolId)
Returns the network parameters for the given string paymentProtocolID or NULL if not recognized.
|
int[] |
getAcceptableAddressCodes()
The version codes that prefix addresses which are acceptable on this network.
|
int |
getAddressHeader()
First byte of a base58 encoded address.
|
int[] |
getAddrSeeds()
Returns IP address of active peers.
|
byte[] |
getAlertSigningKey()
The key used to sign
AlertMessage s. |
int |
getBip32HeaderPriv()
Returns the 4 byte header for BIP32 (HD) wallet - private key part.
|
int |
getBip32HeaderPub()
Returns the 4 byte header for BIP32 (HD) wallet - public key part.
|
EnumSet<Block.VerifyFlag> |
getBlockVerificationFlags(Block block,
VersionTally tally,
Integer height)
The flags indicating which block validation tests should be applied to
the given block.
|
MessageSerializer |
getDefaultSerializer()
Return the default serializer for this network.
|
String[] |
getDnsSeeds()
Returns DNS names that when resolved, give IP addresses of active peers.
|
int |
getDumpedPrivateKeyHeader()
First byte of a base58 encoded dumped private key.
|
Block |
getGenesisBlock()
Genesis block for this chain.
|
HttpDiscovery.Details[] |
getHttpSeeds()
Returns discovery objects for seeds implementing the Cartographer protocol.
|
String |
getId()
A Java package style string acting as unique ID for these parameters
|
int |
getInterval()
How many blocks pass between difficulty adjustment periods.
|
int |
getMajorityEnforceBlockUpgrade()
The number of blocks in the last
getMajorityWindow() blocks
at which to trigger a notice to the user to upgrade their client, where
the client does not understand those blocks. |
int |
getMajorityRejectBlockOutdated()
The number of blocks in the last
getMajorityWindow() blocks
at which to enforce the requirement that all new blocks are of the
newer type (i.e. |
int |
getMajorityWindow()
The sampling window from which the version numbers of blocks are taken
in order to determine if a new block version is now the majority.
|
abstract Coin |
getMaxMoney()
Returns the number of coins that will be produced in total, on this
network.
|
BigInteger |
getMaxTarget()
Maximum target represents the easiest allowable proof of work.
|
abstract Coin |
getMinNonDustOutput()
Any standard (ie pay-to-address) output smaller than this value will
most likely be rejected by the network.
|
abstract MonetaryFormat |
getMonetaryFormat()
The monetary object for this currency.
|
int |
getP2SHHeader()
First byte of a base58 encoded P2SH address.
|
long |
getPacketMagic()
The header bytes that identify the start of a packet on this network.
|
abstract String |
getPaymentProtocolId() |
int |
getPort()
Default TCP port on which to connect to nodes.
|
abstract int |
getProtocolVersionNum(NetworkParameters.ProtocolVersion version) |
abstract BitcoinSerializer |
getSerializer(boolean parseRetain)
Construct and return a custom serializer.
|
int |
getSpendableCoinbaseDepth() |
int |
getSubsidyDecreaseBlockCount() |
int |
getTargetTimespan()
How much time in seconds is supposed to pass between "interval" blocks.
|
EnumSet<Script.VerifyFlag> |
getTransactionVerificationFlags(Block block,
Transaction transaction,
VersionTally tally,
Integer height)
The flags indicating which script validation tests should be applied to
the given transaction.
|
abstract String |
getUriScheme()
Scheme part for URIs, for example "bitcoin".
|
int |
hashCode() |
abstract boolean |
hasMaxMoney()
Returns whether this network has a maximum number of coins (finite supply) or
not.
|
boolean |
isCheckpoint(int height)
Returns true if the given height has a recorded checkpoint.
|
boolean |
passesCheckpoint(int height,
Sha256Hash hash)
Returns true if the block height is either not a checkpoint, or is a checkpoint and the hash matches.
|
static NetworkParameters |
prodNet()
Deprecated.
|
static NetworkParameters |
regTests()
Deprecated.
|
static NetworkParameters |
testNet()
Deprecated.
|
static NetworkParameters |
testNet2()
Deprecated.
|
static NetworkParameters |
testNet3()
Deprecated.
|
static NetworkParameters |
unitTests()
Deprecated.
|
public static final byte[] SATOSHI_KEY
public static final String ID_MAINNET
public static final String ID_TESTNET
public static final String ID_REGTEST
public static final String ID_UNITTESTNET
public static final String PAYMENT_PROTOCOL_ID_MAINNET
public static final String PAYMENT_PROTOCOL_ID_TESTNET
public static final String PAYMENT_PROTOCOL_ID_UNIT_TESTS
public static final String PAYMENT_PROTOCOL_ID_REGTEST
protected Block genesisBlock
protected BigInteger maxTarget
protected int port
protected long packetMagic
protected int addressHeader
protected int p2shHeader
protected int dumpedPrivateKeyHeader
protected int interval
protected int targetTimespan
protected byte[] alertSigningKey
protected int bip32HeaderPub
protected int bip32HeaderPriv
protected int majorityEnforceBlockUpgrade
protected int majorityRejectBlockOutdated
protected int majorityWindow
protected String id
protected int spendableCoinbaseDepth
protected int subsidyDecreaseBlockCount
protected int[] acceptableAddressCodes
protected String[] dnsSeeds
protected int[] addrSeeds
protected HttpDiscovery.Details[] httpSeeds
protected Map<Integer,Sha256Hash> checkpoints
protected transient MessageSerializer defaultSerializer
public static final int TARGET_TIMESPAN
public static final int TARGET_SPACING
public static final int INTERVAL
public static final int BIP16_ENFORCE_TIME
public static final long MAX_COINS
public static final Coin MAX_MONEY
@Deprecated public static NetworkParameters testNet()
@Deprecated public static NetworkParameters testNet2()
@Deprecated public static NetworkParameters testNet3()
@Deprecated public static NetworkParameters prodNet()
@Deprecated public static NetworkParameters unitTests()
@Deprecated public static NetworkParameters regTests()
public String getId()
public abstract String getPaymentProtocolId()
@Nullable public static NetworkParameters fromID(String id)
@Nullable public static NetworkParameters fromPmtProtocolID(String pmtProtocolId)
public int getSpendableCoinbaseDepth()
public abstract void checkDifficultyTransitions(StoredBlock storedPrev, Block next, BlockStore blockStore) throws VerificationException, BlockStoreException
VerificationException
- if the block's difficulty is not correct.BlockStoreException
public boolean passesCheckpoint(int height, Sha256Hash hash)
public boolean isCheckpoint(int height)
public int getSubsidyDecreaseBlockCount()
public String[] getDnsSeeds()
public int[] getAddrSeeds()
public HttpDiscovery.Details[] getHttpSeeds()
HttpDiscovery
for more info.public Block getGenesisBlock()
Genesis block for this chain.
The first block in every chain is a well known constant shared between all Bitcoin implemenetations. For a block to be valid, it must be eventually possible to work backwards to the genesis block by following the prevBlockHash pointers in the block headers.
The genesis blocks for both test and main networks contain the timestamp of when they were created, and a message in the coinbase transaction. It says, "The Times 03/Jan/2009 Chancellor on brink of second bailout for banks".
public int getPort()
public long getPacketMagic()
public int getAddressHeader()
Address
. This is the same as acceptableAddressCodes[0] and
is the one used for "normal" addresses. Other types of address may be encountered with version codes found in
the acceptableAddressCodes array.public int getP2SHHeader()
public int getDumpedPrivateKeyHeader()
DumpedPrivateKey
.public int getTargetTimespan()
public int[] getAcceptableAddressCodes()
public boolean allowEmptyPeerChain()
public int getInterval()
public BigInteger getMaxTarget()
public byte[] getAlertSigningKey()
AlertMessage
s. You can use ECKey.verify(byte[], byte[], byte[])
to verify
signatures using it.public int getBip32HeaderPub()
public int getBip32HeaderPriv()
public abstract Coin getMaxMoney()
public abstract Coin getMinNonDustOutput()
public abstract MonetaryFormat getMonetaryFormat()
public abstract String getUriScheme()
public abstract boolean hasMaxMoney()
public final MessageSerializer getDefaultSerializer()
public abstract BitcoinSerializer getSerializer(boolean parseRetain)
public int getMajorityEnforceBlockUpgrade()
getMajorityWindow()
blocks
at which to trigger a notice to the user to upgrade their client, where
the client does not understand those blocks.public int getMajorityRejectBlockOutdated()
getMajorityWindow()
blocks
at which to enforce the requirement that all new blocks are of the
newer type (i.e. outdated blocks are rejected).public int getMajorityWindow()
public EnumSet<Block.VerifyFlag> getBlockVerificationFlags(Block block, VersionTally tally, Integer height)
block
- block to determine flags for.height
- height of the block, if known, null otherwise. Returned
tests should be a safe subset if block height is unknown.public EnumSet<Script.VerifyFlag> getTransactionVerificationFlags(Block block, Transaction transaction, VersionTally tally, Integer height)
block
- block the transaction belongs to.transaction
- to determine flags for.height
- height of the block, if known, null otherwise. Returned
tests should be a safe subset if block height is unknown.public abstract int getProtocolVersionNum(NetworkParameters.ProtocolVersion version)
Copyright © 2016. All rights reserved.