hashToXAddress static method
Generates an XRP (Ripple) X-address from the provided address hash, X-Address prefix, and optional tag.
This method constructs an X-Address by combining the address hash, X-Address prefix, and an optional tag, and then encodes it using the Base58Check encoding with the Ripple alphabet.
addrHash
The address hash used to generate the X-Address.
xAddrPrefix
The prefix for the X-Address, specific to mainnet or testnet.
tag
An optional tag associated with the X-Address. Must be lower than 2^32 for Ripple X-Addresses.
returns The generated X-Address as a Base58Check encoded string.
throws ArgumentException if the tag is invalid.
Implementation
static String hashToXAddress(
List<int> addrHash, List<int> xAddrPrefix, int? tag) {
if (tag != null && tag > mask32) {
throw const AddressConverterException(
"Invalid tag. Tag should be lower than 2^32 for Ripple X address");
}
List<int> addrBytes = [...xAddrPrefix, ...addrHash];
List<int> tagBytes = writeUint64LE(tag ?? 0);
addrBytes = [...addrBytes, tag == null ? 0 : 1, ...tagBytes];
return Base58Encoder.checkEncode(addrBytes, Base58Alphabets.ripple);
}