Package org.bitcoinj.base
Interface Address
- 
- All Superinterfaces:
 java.lang.Comparable<Address>
- All Known Implementing Classes:
 LegacyAddress,SegwitAddress
public interface Address extends java.lang.Comparable<Address>
Interface for addresses, e.g. native segwit addresses (SegwitAddress) or legacy addresses (LegacyAddress).Use
AddressParserto construct any kind of address from its textual form. 
- 
- 
Field Summary
Fields Modifier and Type Field Description static java.util.Comparator<Address>PARTIAL_ADDRESS_COMPARATORComparator for the first two comparison fields inAddresscomparisons, seecompareTo(Address). 
- 
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description intcompareTo(Address o)Comparison field order for addresses is:Network.id()Legacy vs.static intcompareTypes(Address a, Address b)static AddressfromKey(NetworkParameters params, ECKey key, ScriptType outputScriptType)Deprecated.static AddressfromString(NetworkParameters params, java.lang.String str)Deprecated.byte[]getHash()Get either the public key hash or script hash that is encoded in the address.ScriptTypegetOutputScriptType()Get the type of output script that will be used for sending to the address.default NetworkParametersgetParameters()Deprecated.Usenetwork()Networknetwork()Get the network this address is used on. 
 - 
 
- 
- 
Field Detail
- 
PARTIAL_ADDRESS_COMPARATOR
static final java.util.Comparator<Address> PARTIAL_ADDRESS_COMPARATOR
Comparator for the first two comparison fields inAddresscomparisons, seecompareTo(Address). Used byLegacyAddress.compareTo(Address)andSegwitAddress.compareTo(Address). For use by implementing classes only. 
 - 
 
- 
Method Detail
- 
fromString
@Deprecated static Address fromString(@Nullable NetworkParameters params, java.lang.String str) throws AddressFormatException
Deprecated.Construct an address from its textual form.- Parameters:
 params- the expected network this address is valid for, or null if the network should be derived from the textual formstr- the textual form of the address, such as "17kzeh4N8g49GFvdDzSf8PjaPfyoD1MndL" or "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"- Returns:
 - constructed address
 - Throws:
 AddressFormatException- if the given string doesn't parse or the checksum is invalidAddressFormatException.WrongNetwork- if the given string is valid but not for the expected network (eg testnet vs mainnet)
 
- 
fromKey
@Deprecated static Address fromKey(NetworkParameters params, ECKey key, ScriptType outputScriptType)
Deprecated.- Parameters:
 params- network this address is valid forkey- only the public part is usedoutputScriptType- script type the address should use- Returns:
 - constructed address
 
 
- 
getParameters
@Deprecated default NetworkParameters getParameters()
Deprecated.Usenetwork()- Returns:
 - network this data is valid for
 
 
- 
getHash
byte[] getHash()
Get either the public key hash or script hash that is encoded in the address.- Returns:
 - hash that is encoded in the address
 
 
- 
getOutputScriptType
ScriptType getOutputScriptType()
Get the type of output script that will be used for sending to the address.- Returns:
 - type of output script
 
 
- 
compareTo
int compareTo(Address o)
Comparison field order for addresses is:Network.id()- Legacy vs. Segwit
 - (Legacy only) Version byte
 - remaining 
bytes 
Implementations use
PARTIAL_ADDRESS_COMPARATORfor tests 1 and 2.- Specified by:
 compareToin interfacejava.lang.Comparable<Address>- Parameters:
 o- otherAddressobject- Returns:
 - comparison result
 
 
- 
network
Network network()
Get the network this address is used on. Returns the normalized network (see below.)Note: The network value returned is normalized. For example the address
"tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx"may be used on eitherBitcoinNetwork.TESTNETorBitcoinNetwork.SIGNET, but the value returned by this method will always beBitcoinNetwork.TESTNET. Similarly, the address"mnHUcqUVvrfi5kAaXJDQzBb9HsWs78b42R"may be used onBitcoinNetwork.TESTNET,BitcoinNetwork.REGTEST, orBitcoinNetwork.REGTEST, but the value returned by this method will always beBitcoinNetwork.TESTNET.- Returns:
 - the Network.
 
 
 - 
 
 -