Package org.xrpl.xrpl4j.codec.addresses
Class AddressCodec
- java.lang.Object
-
- org.xrpl.xrpl4j.codec.addresses.AddressCodec
-
public class AddressCodec extends Object
-
-
Constructor Summary
Constructors Constructor Description AddressCodec()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description XAddress
classicAddressToXAddress(Address classicAddress, boolean test)
Converts an XRPL Classic Address with no Destination Tag to an X-Address.XAddress
classicAddressToXAddress(Address classicAddress, com.google.common.primitives.UnsignedInteger tag, boolean test)
Converts an XRPL Classic Address and Destination Tag to an X-Address.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.UnsignedByteArray
decodeAccountId(Address accountId)
Decode a Base58Check encoded XRPL AccountID.UnsignedByteArray
decodeAccountPublicKey(String publicKey)
Decode a Base58Check encoded XRPL Account Public Key.UnsignedByteArray
decodeNodePublicKey(String publicKey)
Decode a Base58Check encoded XRPL Node Public Key.Decoded
decodeSeed(String seed)
Decodes a Base58Check encoded XRPL secret key seed value.Address
encodeAccountId(UnsignedByteArray accountId)
Encode an XRPL AccountID to a Base58Check encodedString
.String
encodeAccountPublicKey(UnsignedByteArray publicKey)
Encode an XRPL Account Public Key to a Base58Check encodedString
.String
encodeNodePublicKey(UnsignedByteArray publicKey)
Encode an XRPL Node Public Key to a Base58Check encodedString
.String
encodeSeed(UnsignedByteArray entropy, VersionType type)
Encodes a byte array to a Base58CheckString
using the givenVersionType
.static AddressCodec
getInstance()
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.ClassicAddress
xAddressToClassicAddress(XAddress xAddress)
Decodes an X-Address to a Classic Address and Destination Tag.
-
-
-
Method Detail
-
getInstance
public static AddressCodec getInstance()
-
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 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
public Address encodeAccountId(UnsignedByteArray accountId)
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
public UnsignedByteArray decodeAccountId(Address accountId)
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
public String encodeNodePublicKey(UnsignedByteArray publicKey)
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
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 encodedString
.- Parameters:
publicKey
- AnUnsignedByteArray
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
- 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
public XAddress classicAddressToXAddress(Address classicAddress, boolean test)
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
public ClassicAddress xAddressToClassicAddress(XAddress xAddress)
Decodes an X-Address to a Classic Address and Destination Tag.- Parameters:
xAddress
- TheXAddress
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 validXAddress
.- Returns:
true
if the given address is a valid X-Address,false
if not.
-
-