Package org.bitcoinj.base
Enum Class BitcoinNetwork
- All Implemented Interfaces:
 Serializable,Comparable<BitcoinNetwork>,Constable,Network
A convenient 
enum representation of a Bitcoin network.
 
 Note that the name of each enum constant is defined in uppercase as is the convention in Java.
 However, the canonical
 representation in bitcoinj for user-facing display and input
 of Bitcoin network names is lowercase (e.g. as a command-line parameter.)
 Implementations should use the toString() method for output and the fromString(String)
 method for input of network values.
- 
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>> - 
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionThe main Bitcoin network, known as"mainnet", withidstring"org.bitcoin.production"A local Bitcoin regression test network, known as"regtest", withidstring"org.bitcoin.regtest"The Bitcoin signature-based test network, known as"signet", withidstring"org.bitcoin.signet"The Bitcoin test network, known as"testnet", withidstring"org.bitcoin.test" - 
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringScheme part for Bitcoin URIs.static final StringThe ID string for the main, production network where people trade things.static final StringThe ID string for regtest mode.static final StringThe ID string for the signet.static final StringThe ID string for the testnet.static final CoinThe maximum money to be generated - 
Method Summary
Modifier and TypeMethodDescriptioncheckAddress(Address address) Check if an address is valid on this network.booleanexceedsMaxMoney(Monetary amount) Check if an amount exceeds the maximum allowed for a network (if the network has one)static Optional<BitcoinNetwork>fromIdString(String idString) Find theBitcoinNetworkfrom an ID Stringstatic Optional<BitcoinNetwork>fromString(String nameString) Find theBitcoinNetworkfrom a name string, e.g.booleanDoes this network have a fixed maximum number of coinsid()booleanisValidAddress(Address address) Is address valid for this network.intHeader byte of base58 encoded legacy P2PKH addresses for this network.intHeader byte of base58 encoded legacy P2SH addresses for this network.maxMoney()Maximum number of coins for this network as aMonetaryvalue.Return the standard Bech32SegwitAddress.SegwitHrp(as aString) for this network.strings()toString()Return the canonical, lowercase, user-facingStringfor anenum.The URI scheme for Bitcoin.static BitcoinNetworkReturns the enum constant of this class with the specified name.static BitcoinNetwork[]values()Returns an array containing the constants of this enum class, in the order they are declared. 
- 
Enum Constant Details
- 
MAINNET
The main Bitcoin network, known as"mainnet", withidstring"org.bitcoin.production" - 
TESTNET
The Bitcoin test network, known as"testnet", withidstring"org.bitcoin.test" - 
SIGNET
The Bitcoin signature-based test network, known as"signet", withidstring"org.bitcoin.signet" - 
REGTEST
A local Bitcoin regression test network, known as"regtest", withidstring"org.bitcoin.regtest" 
 - 
 - 
Field Details
- 
BITCOIN_SCHEME
Scheme part for Bitcoin URIs.- See Also:
 
 - 
MAX_MONEY
The maximum money to be generated - 
ID_MAINNET
The ID string for the main, production network where people trade things. - 
ID_TESTNET
The ID string for the testnet. - 
ID_SIGNET
The ID string for the signet. - 
ID_REGTEST
The ID string for regtest mode. 
 - 
 - 
Method Details
- 
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
 - an array containing the constants of this enum class, in the order they are declared
 
 - 
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
 name- the name of the enum constant to be returned.- Returns:
 - the enum constant with the specified name
 - Throws:
 IllegalArgumentException- if this enum class has no constant with the specified nameNullPointerException- if the argument is null
 - 
toString
Return the canonical, lowercase, user-facingStringfor anenum. It is the lowercase value ofEnum.name()and can be displayed to the user, used as a command-line parameter, etc.- Overrides:
 toStringin classEnum<BitcoinNetwork>- Returns:
 - canonical lowercase name for this Bitcoin network
 
 - 
id
Return the network ID string as defined by (these were previously defined inNetworkParameters) - 
legacyAddressHeader
public int legacyAddressHeader()Header byte of base58 encoded legacy P2PKH addresses for this network.- Specified by:
 legacyAddressHeaderin interfaceNetwork- Returns:
 - header byte as an 
int. - See Also:
 
 - 
legacyP2SHHeader
public int legacyP2SHHeader()Header byte of base58 encoded legacy P2SH addresses for this network.- Specified by:
 legacyP2SHHeaderin interfaceNetwork- Returns:
 - header byte as an 
int. - See Also:
 
 - 
segwitAddressHrp
Return the standard Bech32SegwitAddress.SegwitHrp(as aString) for this network.- Specified by:
 segwitAddressHrpin interfaceNetwork- Returns:
 - The HRP as a (lowercase) string.
 
 - 
uriScheme
The URI scheme for Bitcoin. - 
hasMaxMoney
public boolean hasMaxMoney()Description copied from interface:NetworkDoes this network have a fixed maximum number of coins- Specified by:
 hasMaxMoneyin interfaceNetwork- Returns:
 trueif this network has a fixed maximum number of coins
 - 
maxMoney
Description copied from interface:NetworkMaximum number of coins for this network as aMonetaryvalue. Where not applicable, a very large number of coins is returned instead (e.g. the main coin issue for Dogecoin). - 
exceedsMaxMoney
Description copied from interface:NetworkCheck if an amount exceeds the maximum allowed for a network (if the network has one)- Specified by:
 exceedsMaxMoneyin interfaceNetwork- Parameters:
 amount- A monetary amount- Returns:
 - true if too big, false if an allowed amount
 
 - 
checkAddress
Check if an address is valid on this network. This is meant to be used as a precondition for a method or function that expects a valid address. If you are validating addresses provided externally, you probably want to useisValidAddress(Address)to handle errors more gracefully. This method usesisValidAddress(Address)internally which properly accounts for address normalization.- Parameters:
 address- Address to validate- Returns:
 - The unmodified address if valid on this network
 - Throws:
 IllegalArgumentException- if address not valid on this network
 - 
isValidAddress
Is address valid for this network. Because we normalize thenetwork()value in theAddresstype (see the JavaDoc forAddress.network()) this method should be used in preference to simply verifying thataddress.network()returns the desired network type.- Parameters:
 address- Address to validate- Returns:
 trueif valid on this network,falseotherwise
 - 
fromString
Find theBitcoinNetworkfrom a name string, e.g. "mainnet", "testnet" or "signet". A number of common alternate names are allowed too, e.g. "main" or "prod".- Parameters:
 nameString- A name string- Returns:
 - An 
Optionalcontaining the matching enum or empty 
 - 
fromIdString
Find theBitcoinNetworkfrom an ID String- Parameters:
 idString- specifies the network- Returns:
 - An 
Optionalcontaining the matching enum or empty 
 - 
strings
- Returns:
 - list of the names of all instances of this enum
 
 
 -