Package org.bitcoinj.base
Enum BitcoinNetwork
- java.lang.Object
- 
- java.lang.Enum<BitcoinNetwork>
- 
- org.bitcoinj.base.BitcoinNetwork
 
 
- 
- All Implemented Interfaces:
- java.io.Serializable,- java.lang.Comparable<BitcoinNetwork>,- Network
 
 public enum BitcoinNetwork extends java.lang.Enum<BitcoinNetwork> implements Network A convenientenumrepresentation of a Bitcoin network.Note that the name of each enumconstant is defined in uppercase as is the convention in Java. However, thecanonical 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 thetoString()method for output and thefromString(String)method for input of network values.
- 
- 
Enum Constant SummaryEnum Constants Enum Constant Description MAINNETThe main Bitcoin network, known as"mainnet", withidstring"org.bitcoin.production"REGTESTA local Bitcoin regression test network, known as"regtest", withidstring"org.bitcoin.regtest"SIGNETThe Bitcoin signature-based test network, known as"signet", withidstring"org.bitcoin.signet"TESTNETThe Bitcoin test network, known as"testnet", withidstring"org.bitcoin.test"
 - 
Field SummaryFields Modifier and Type Field Description static java.lang.StringBITCOIN_SCHEMEScheme part for Bitcoin URIs.static java.lang.StringID_MAINNETThe ID string for the main, production network where people trade things.static java.lang.StringID_REGTESTThe ID string for regtest mode.static java.lang.StringID_SIGNETThe ID string for the signet.static java.lang.StringID_TESTNETThe ID string for the testnet.static CoinMAX_MONEYThe maximum money to be generated
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanexceedsMaxMoney(Monetary amount)Check if an amount exceeds the maximum allowed for a network (if the network has one)static java.util.Optional<BitcoinNetwork>fromIdString(java.lang.String idString)Find theBitcoinNetworkfrom an ID Stringstatic java.util.Optional<BitcoinNetwork>fromString(java.lang.String nameString)Find theBitcoinNetworkfrom a name string, e.g.booleanhasMaxMoney()Does this network have a fixed maximum number of coinsjava.lang.Stringid()intlegacyAddressHeader()Header byte of base58 encoded legacy P2PKH addresses for this network.intlegacyP2SHHeader()Header byte of base58 encoded legacy P2SH addresses for this network.CoinmaxMoney()Maximum number of coins for this network as aMonetaryvalue.java.lang.StringsegwitAddressHrp()Return the standard Bech32SegwitAddress.SegwitHrp(as aString) for this network.java.lang.StringtoString()Return the canonical, lowercase, user-facingStringfor anenum.java.lang.StringuriScheme()The URI scheme for Bitcoin.static BitcoinNetworkvalueOf(java.lang.String name)Returns the enum constant of this type with the specified name.static BitcoinNetwork[]values()Returns an array containing the constants of this enum type, in the order they are declared.
 
- 
- 
- 
Enum Constant Detail- 
MAINNETpublic static final BitcoinNetwork MAINNET The main Bitcoin network, known as"mainnet", withidstring"org.bitcoin.production"
 - 
TESTNETpublic static final BitcoinNetwork TESTNET The Bitcoin test network, known as"testnet", withidstring"org.bitcoin.test"
 - 
SIGNETpublic static final BitcoinNetwork SIGNET The Bitcoin signature-based test network, known as"signet", withidstring"org.bitcoin.signet"
 - 
REGTESTpublic static final BitcoinNetwork REGTEST A local Bitcoin regression test network, known as"regtest", withidstring"org.bitcoin.regtest"
 
- 
 - 
Field Detail- 
BITCOIN_SCHEMEpublic static final java.lang.String BITCOIN_SCHEME Scheme part for Bitcoin URIs.- See Also:
- Constant Field Values
 
 - 
MAX_MONEYpublic static final Coin MAX_MONEY The maximum money to be generated
 - 
ID_MAINNETpublic static final java.lang.String ID_MAINNET The ID string for the main, production network where people trade things.
 - 
ID_TESTNETpublic static final java.lang.String ID_TESTNET The ID string for the testnet.
 - 
ID_SIGNETpublic static final java.lang.String ID_SIGNET The ID string for the signet.
 - 
ID_REGTESTpublic static final java.lang.String ID_REGTEST The ID string for regtest mode.
 
- 
 - 
Method Detail- 
valuespublic static BitcoinNetwork[] values() Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (BitcoinNetwork c : BitcoinNetwork.values()) System.out.println(c); - Returns:
- an array containing the constants of this enum type, in the order they are declared
 
 - 
valueOfpublic static BitcoinNetwork valueOf(java.lang.String name) Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (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:
- java.lang.IllegalArgumentException- if this enum type has no constant with the specified name
- java.lang.NullPointerException- if the argument is null
 
 - 
toStringpublic java.lang.String 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 class- java.lang.Enum<BitcoinNetwork>
- Returns:
- canonical lowercase name for this Bitcoin network
 
 - 
idpublic java.lang.String id() Return the network ID string as defined by (these were previously defined inNetworkParameters)
 - 
legacyAddressHeaderpublic int legacyAddressHeader() Header byte of base58 encoded legacy P2PKH addresses for this network.- Specified by:
- legacyAddressHeaderin interface- Network
- Returns:
- header byte as an int.
- See Also:
- LegacyAddress.AddressHeader
 
 - 
legacyP2SHHeaderpublic int legacyP2SHHeader() Header byte of base58 encoded legacy P2SH addresses for this network.- Specified by:
- legacyP2SHHeaderin interface- Network
- Returns:
- header byte as an int.
- See Also:
- LegacyAddress.P2SHHeader
 
 - 
segwitAddressHrppublic java.lang.String segwitAddressHrp() Return the standard Bech32SegwitAddress.SegwitHrp(as aString) for this network.- Specified by:
- segwitAddressHrpin interface- Network
- Returns:
- The HRP as a (lowercase) string.
 
 - 
uriSchemepublic java.lang.String uriScheme() The URI scheme for Bitcoin.
 - 
hasMaxMoneypublic boolean hasMaxMoney() Description copied from interface:NetworkDoes this network have a fixed maximum number of coins- Specified by:
- hasMaxMoneyin interface- Network
- Returns:
- trueif this network has a fixed maximum number of coins
 
 - 
maxMoneypublic Coin 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).
 - 
exceedsMaxMoneypublic boolean exceedsMaxMoney(Monetary amount) Description copied from interface:NetworkCheck if an amount exceeds the maximum allowed for a network (if the network has one)- Specified by:
- exceedsMaxMoneyin interface- Network
- Parameters:
- amount- A monetary amount
- Returns:
- true if too big, false if an allowed amount
 
 - 
fromStringpublic static java.util.Optional<BitcoinNetwork> fromString(java.lang.String nameString) 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
 
 - 
fromIdStringpublic static java.util.Optional<BitcoinNetwork> fromIdString(java.lang.String idString) Find theBitcoinNetworkfrom an ID String- Parameters:
- idString- specifies the network
- Returns:
- An Optionalcontaining the matching enum or empty
 
 
- 
 
-