decodeAddr method

  1. @override
List<int> decodeAddr(
  1. String addr, {
  2. List<int>? versionBytes,
})
override

Overrides the base class method to decode a Neo (NEO) address.

Implementation

@override
List<int> decodeAddr(String addr, {List<int>? versionBytes}) {
  final List<int> verBytes = AddrKeyValidator.getAddrArg(
    versionBytes,
    "versionBytes",
  );
  final List<int> addrDecBytes = Base58Decoder.checkDecode(addr);

  /// Validate the length of the decoded address.
  AddrDecUtils.validateBytesLength(
    addrDecBytes,
    QuickCrypto.hash160DigestSize + verBytes.length,
  );

  if (!BytesUtils.bytesEqual([addrDecBytes[0]], verBytes)) {
    throw AddressConverterException.addressValidationFailed(
      reason: "Invalid address checksum.",
    );
  }

  return addrDecBytes.sublist(1);
}