Package org.xrpl.xrpl4j.codec.addresses
Class AddressCodec
java.lang.Object
org.xrpl.xrpl4j.codec.addresses.AddressCodec
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclassicAddressToXAddress
(Address classicAddress, boolean test) Converts an XRPL Classic Address with no Destination Tag to an X-Address.classicAddressToXAddress
(Address classicAddress, com.google.common.primitives.UnsignedInteger tag, boolean test) Converts an XRPL Classic Address and Destination Tag to an X-Address.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.decodeAccountId
(Address accountId) Decode a Base58Check encoded XRPL AccountID.decodeAccountPublicKey
(String publicKey) Decode a Base58Check encoded XRPL Account Public Key.decodeNodePublicKey
(String publicKey) Decode a Base58Check encoded XRPL Node Public Key.decodeSeed
(String seed) Decodes a Base58Check encoded XRPL secret key seed value.encodeAccountId
(UnsignedByteArray accountId) Encode an XRPL AccountID to a Base58Check encodedString
.encodeAccountPublicKey
(UnsignedByteArray publicKey) Encode an XRPL Account Public Key to a Base58Check encodedString
.encodeNodePublicKey
(UnsignedByteArray publicKey) Encode an XRPL Node Public Key to a Base58Check encodedString
.encodeSeed
(UnsignedByteArray entropy, VersionType type) Encodes a byte array to a Base58CheckString
using the givenVersionType
.static AddressCodec
boolean
isValidClassicAddress
(Address address) Tests if the given Address is a valid Classic Address.boolean
isValidXAddress
(XAddress xAddress) Tests if the given X-Address is a valid X-Address.xAddressToClassicAddress
(XAddress xAddress) Decodes an X-Address to a Classic Address and Destination Tag.
-
Constructor Details
-
AddressCodec
public AddressCodec()
-
-
Method Details
-
getInstance
-
decodeSeed
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
Encodes a byte array to a Base58CheckString
using the givenVersionType
.- Parameters:
entropy
- AnUnsignedByteArray
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
Encode an XRPL AccountID to a Base58Check encodedString
.- Parameters:
accountId
- AnUnsignedByteArray
containing the AccountID to be encoded.- Returns:
- The Base58 representation of accountId, as an
Address
.
-
decodeAccountId
Decode a Base58Check encoded XRPL AccountID.- Parameters:
accountId
- The Base58 encoded AccountID to be decoded, as anAddress
.- Returns:
- An
UnsignedByteArray
containing the decoded AccountID. - See Also:
-
- "https://xrpl.org/base58-encodings.html"
-
encodeNodePublicKey
Encode an XRPL Node Public Key to a Base58Check encodedString
.- Parameters:
publicKey
- AnUnsignedByteArray
containing the public key to be encoded.- Returns:
- The Base58 representation of publicKey.
-
decodeNodePublicKey
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
Encode an XRPL Account Public Key to a Base58Check encodedString
.- Parameters:
publicKey
- AnUnsignedByteArray
containing the public key to be encoded.- Returns:
- The Base58 representation of publicKey.
-
decodeAccountPublicKey
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
- AString
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
Converts an XRPL Classic Address with no Destination Tag to an X-Address. -
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
- AnAddress
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
Decodes an X-Address to a Classic Address and Destination Tag.- Parameters:
xAddress
- TheXAddress
to be decoded.- Returns:
- The
ClassicAddress
decoded from xAddress.
-
isValidXAddress
Tests if the given X-Address is a valid X-Address.- Parameters:
xAddress
- A potentially validXAddress
.- Returns:
true
if the given address is a valid X-Address,false
if not.
-
isValidClassicAddress
Tests if the given Address is a valid Classic Address.- Parameters:
address
- A potentially valid classicAddress
.- Returns:
true
if the given address is a valid Classic Address,false
if not.
-