decodeAddr method
Overrides the base class method to decode a Neo (NEO) address.
This method decodes a Neo address from the provided input string using Base58 encoding. It expects an optional map of keyword arguments with 'ver' specifying the version bytes. The method validates the arguments, decodes the Base58 address, checks its version, length, and checksum, and returns the decoded Neo address as a List
Parameters:
- addr: The Base58-encoded Neo address to be decoded.
- kwargs: Optional keyword arguments with 'ver' for the version bytes.
Returns: A List
Implementation
@override
List<int> decodeAddr(String addr, [Map<String, dynamic> kwargs = const {}]) {
/// Validate the version argument.
AddrKeyValidator.validateAddressArgs<List<int>>(kwargs, "ver");
List<int> verBytes = kwargs["ver"];
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.
List<int> verGot = IntUtils.toBytes(addrDecBytes[0],
length: IntUtils.bitlengthInBytes(addrDecBytes[0]),
byteOrder: Endian.little);
if (!BytesUtils.bytesEqual(verGot, verBytes)) {
throw AddressConverterException(
"Invalid version (expected ${BytesUtils.toHexString(verBytes)}, "
"got ${BytesUtils.toHexString(verGot)})");
}
return addrDecBytes.sublist(1);
}