validateAndRemovePrefixBytes static method

List<int> validateAndRemovePrefixBytes(
  1. List<int> addr,
  2. List<int> prefix
)

Validate and remove prefix from an address.

Implementation

static List<int> validateAndRemovePrefixBytes(
  List<int> addr,
  List<int> prefix,
) {
  final prefixGot = addr.sublist(0, prefix.length);

  if (!BytesUtils.bytesEqual(prefix, prefixGot)) {
    throw AddressConverterException.addressValidationFailed(
      reason: "Invalid address prefix.",
    );
  }

  return addr.sublist(prefix.length);
}