Client and backend. This class is shared: the same code is compiled into your app and into your server, so everything on this page works in both.
public final class BitcoinNetwork
- Object
- BitcoinNetwork
The parameters that make an address or key belong to one Bitcoin network.
Fields
public static final BitcoinNetwork MAINNET | Bitcoin mainnet: 1..., 3..., bc1.... |
public static final BitcoinNetwork TESTNET | testnet3 and testnet4: m.../n..., 2..., tb1.... |
public static final BitcoinNetwork SIGNET | Signet, which shares testnet’s encodings. |
public static final BitcoinNetwork REGTEST | Regtest: testnet’s encodings except for the bcrt HRP. |
Methods
public String getName() | The network’s name. |
public int getP2pkhVersion() | The Base58Check version byte of a P2PKH address. |
public int getP2shVersion() | The Base58Check version byte of a P2SH address. |
public String getBech32Hrp() | The Bech32 human-readable part of a SegWit address. |
public int getWifPrefix() | The first byte of a WIF private key. |
public int getXpubVersion() | The BIP-32 public version bytes (xpub/tpub). |
public int getXprvVersion() | The BIP-32 private version bytes (xprv/tprv). |
public int getCoinType() | The BIP-44 coin type: 0 on mainnet, 1 on every test network. |
public String toString() | Returns a string representation of the object. |
Inherited methods
Field details
MAINNET
public static final BitcoinNetwork MAINNETBitcoin mainnet:
1..., 3..., bc1....TESTNET
public static final BitcoinNetwork TESTNETtestnet3 and testnet4:
m.../n..., 2..., tb1....SIGNET
public static final BitcoinNetwork SIGNETSignet, which shares testnet’s encodings.
REGTEST
public static final BitcoinNetwork REGTESTRegtest: testnet’s encodings except for the
bcrt HRP.Method details
getName
public String getName()The network’s name.
getP2pkhVersion
public int getP2pkhVersion()The Base58Check version byte of a P2PKH address.
getP2shVersion
public int getP2shVersion()The Base58Check version byte of a P2SH address.
getBech32Hrp
public String getBech32Hrp()The Bech32 human-readable part of a SegWit address.
getWifPrefix
public int getWifPrefix()The first byte of a WIF private key.
getXpubVersion
public int getXpubVersion()The BIP-32 public version bytes (
xpub/tpub).getXprvVersion
public int getXprvVersion()The BIP-32 private version bytes (
xprv/tprv).getCoinType
public int getCoinType()The BIP-44 coin type: 0 on mainnet, 1 on every test network.
toString
public String toString()Returns a string representation of the object. In general, the toString method returns a string that “textually represents” this object. The result should be a concise but informative representation that is easy for a person to read. It is recommended that all subclasses override this method.
The toString method for class Object returns a string consisting of the name of the class of which the object is an instance, the at-sign character `@’, and the unsigned hexadecimal representation of the hash code of the object. In other words, this method returns a string equal to the value of:
getClass().getName() + ‘@’ + Integer.toHexString(hashCode())