Class Address

    • Constructor Detail

      • Address

        protected Address​(NetworkParameters params,
                          byte[] bytes)
        Construct an address from its binary form.
        Parameters:
        params - the network this address is valid for
        bytes - the binary address data
    • Method Detail

      • fromString

        public static Address fromString​(@Nullable
                                         NetworkParameters params,
                                         java.lang.String str)
                                  throws AddressFormatException
        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 form
        str - 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 invalid
        AddressFormatException.WrongNetwork - if the given string is valid but not for the expected network (eg testnet vs mainnet)
      • fromKey

        public static Address fromKey​(NetworkParameters params,
                                      ECKey key,
                                      Script.ScriptType outputScriptType)
        Construct an Address that represents the public part of the given ECKey.
        Parameters:
        params - network this address is valid for
        key - only the public part is used
        outputScriptType - script type the address should use
        Returns:
        constructed address
      • getHash

        public abstract 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

        public abstract Script.ScriptType getOutputScriptType()
        Get the type of output script that will be used for sending to the address.
        Returns:
        type of output script
      • compareTo

        public abstract int compareTo​(Address o)
        Comparison field order for addresses is:
        1. NetworkParameters.getId()
        2. Legacy vs. Segwit
        3. (Legacy only) Version byte
        4. remaining bytes

        Implementations may use compareAddressPartial for tests 1 and 2.

        Specified by:
        compareTo in interface java.lang.Comparable<Address>
        Parameters:
        o - other Address object
        Returns:
        comparison result