hashToXAddress static method

String hashToXAddress(
  1. List<int> addrHash,
  2. List<int> xAddrPrefix,
  3. int? tag
)

Generates an XRP (Ripple) X-address from the provided address hash, X-Address prefix, and optional tag.

Implementation

static String hashToXAddress(
  List<int> addrHash,
  List<int> xAddrPrefix,
  int? tag,
) {
  if (tag != null && tag > BinaryOps.mask32) {
    throw AddressConverterException.addressBytesValidationFailed(
      reason: "Invalid address tag.",
    );
  }
  List<int> addrBytes = [...xAddrPrefix, ...addrHash];
  final List<int> tagBytes = BinaryOps.writeUint64LE(tag ?? 0);
  addrBytes = [...addrBytes, tag == null ? 0 : 1, ...tagBytes];
  return Base58Encoder.checkEncode(addrBytes, Base58Alphabets.ripple);
}