decodeAddr method
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,
);
/// Retrieve the version byte from the decoded address and compare it with the expected version.
final List<int> verGot = IntUtils.toBytes(
addrDecBytes[0],
byteOrder: Endian.little,
);
if (!BytesUtils.bytesEqual(verGot, verBytes)) {
throw AddressConverterException.addressValidationFailed(
reason: "Invalid address checksum.",
);
}
return addrDecBytes.sublist(1);
}