decodeAddress static method

List<int> decodeAddress(
  1. String address, {
  2. List<int>? xAddrPrefix,
})

Decodes the given address, whether it is an X-Address or a classic address, and returns the address bytes.

This method attempts to decode the provided address as a classic XRP address using XrpAddrDecoder. If decoding as a classic address fails, it attempts to decode the address as an X-Address using decodeXAddress. Returns the decoded address bytes in both cases.

address The address to be decoded, which can be either an X-Address or a classic address. xAddrPrefix The optional prefix for the X-Address, specific to mainnet or testnet. returns The decoded address bytes. throws ArgumentException if the provided address is neither a valid X-Address nor a classic address.

Implementation

static List<int> decodeAddress(String address, {List<int>? xAddrPrefix}) {
  try {
    try {
      final decode = XrpAddrDecoder().decodeAddr(address);
      return decode;
    } catch (e) {
      final xAddr = decodeXAddress(address, xAddrPrefix);
      return xAddr.bytes;
    }
  } catch (e) {
    throw const AddressConverterException(
        "invalid ripple X or classic address");
  }
}