Class AddressCodec


  • public class AddressCodec
    extends Object
    • Constructor Detail

      • AddressCodec

        public AddressCodec()
    • Method Detail

      • decodeSeed

        public Decoded decodeSeed​(String seed)
                           throws EncodingFormatException
        Decodes a Base58Check encoded XRPL secret key seed value. Works for ed25519 and secp256k1 seeds.
        Parameters:
        seed - A Base58Check encoded XRPL keypair seed.
        Returns:
        The decoded seed, seed type, and algorithm used to encode the seed.
        Throws:
        EncodingFormatException
        See Also:
        "https://xrpl.org/cryptographic-keys.html#seed"
      • encodeSeed

        public String encodeSeed​(UnsignedByteArray entropy,
                                 VersionType type)
        Encodes a byte array to a Base58Check String using the given VersionType.
        Parameters:
        entropy - An UnsignedByteArray containing the seed entropy to encode.
        type - The cryptographic algorithm type to be encoded in the resulting seed.
        Returns:
        A Base58Check encoded XRPL keypair seed.
      • encodeAccountId

        public Address encodeAccountId​(UnsignedByteArray accountId)
        Encode an XRPL AccountID to a Base58Check encoded String.
        Parameters:
        accountId - An UnsignedByteArray containing the AccountID to be encoded.
        Returns:
        The Base58 representation of accountId, as an Address.
      • decodeAccountId

        public UnsignedByteArray decodeAccountId​(Address accountId)
        Decode a Base58Check encoded XRPL AccountID.
        Parameters:
        accountId - The Base58 encoded AccountID to be decoded, as an Address.
        Returns:
        An UnsignedByteArray containing the decoded AccountID.
        See Also:
        "https://xrpl.org/base58-encodings.html"
      • encodeNodePublicKey

        public String encodeNodePublicKey​(UnsignedByteArray publicKey)
        Encode an XRPL Node Public Key to a Base58Check encoded String.
        Parameters:
        publicKey - An UnsignedByteArray containing the public key to be encoded.
        Returns:
        The Base58 representation of publicKey.
      • decodeNodePublicKey

        public UnsignedByteArray decodeNodePublicKey​(String publicKey)
        Decode a Base58Check encoded XRPL Node Public Key.
        Parameters:
        publicKey - The Base58 encoded public key to be decoded.
        Returns:
        An UnsignedByteArray containing the decoded public key.
        See Also:
        "https://xrpl.org/base58-encodings.html"
      • encodeAccountPublicKey

        public String encodeAccountPublicKey​(UnsignedByteArray publicKey)
        Encode an XRPL Account Public Key to a Base58Check encoded String.
        Parameters:
        publicKey - An UnsignedByteArray containing the public key to be encoded.
        Returns:
        The Base58 representation of publicKey.
      • decodeAccountPublicKey

        public UnsignedByteArray decodeAccountPublicKey​(String publicKey)
        Decode a Base58Check encoded XRPL Account Public Key.
        Parameters:
        publicKey - The Base58 encoded public key to be decoded.
        Returns:
        An UnsignedByteArray containing the decoded public key.
        See Also:
        "https://xrpl.org/base58-encodings.html"
      • classicAddressToXAddress

        public XAddress classicAddressToXAddress​(Address classicAddress,
                                                 com.google.common.primitives.UnsignedInteger tag,
                                                 boolean test)
        Converts an XRPL Classic Address and Destination Tag to an X-Address.
        Parameters:
        classicAddress - A String containing the classic address.
        tag - The destination tag of the address.
        test - true if the X-Address should be encoded for Testnet, false if it should be encoded for Mainnet.
        Returns:
        The X-Address representation of the classic address and destination tag.
      • classicAddressToXAddress

        public XAddress classicAddressToXAddress​(Address classicAddress,
                                                 boolean test)
        Converts an XRPL Classic Address with no Destination Tag to an X-Address.
        Parameters:
        classicAddress - An Address containing the classic address.
        test - true if the X-Address should be encoded for Testnet, false if it should be encoded for Mainnet.
        Returns:
        The X-Address representation of the classic address, as an XAddress.
      • classicAddressToXAddress

        public XAddress classicAddressToXAddress​(Address classicAddress,
                                                 Optional<com.google.common.primitives.UnsignedInteger> tag,
                                                 boolean test)
        Converts an XRPL Classic Address and and optional Destination Tag to an X-Address.
        Parameters:
        classicAddress - An Address containing the classic address.
        tag - The destination tag of the address.
        test - true if the X-Address should be encoded for Testnet, false if it should be encoded for Mainnet.
        Returns:
        The X-Address representation of the classic address and destination tag, as an XAddress.
      • xAddressToClassicAddress

        public ClassicAddress xAddressToClassicAddress​(XAddress xAddress)
        Decodes an X-Address to a Classic Address and Destination Tag.
        Parameters:
        xAddress - The XAddress to be decoded.
        Returns:
        The ClassicAddress decoded from xAddress.
      • isValidXAddress

        public boolean isValidXAddress​(XAddress xAddress)
        Tests if the given X-Address is a valid X-Address.
        Parameters:
        xAddress - A potentially valid XAddress.
        Returns:
        true if the given address is a valid X-Address, false if not.
      • isValidClassicAddress

        public boolean isValidClassicAddress​(Address address)
        Tests if the given Address is a valid Classic Address.
        Parameters:
        address - A potentially valid classic Address.
        Returns:
        true if the given address is a valid Classic Address, false if not.