decodeAddr method
Overrides the method to decode an EOS address from its string representation.
addr
: The EOS address string to be decoded.
kwargs
: A map of optional keyword arguments.
This method removes the address prefix, decodes the address bytes, and validates the checksum. It returns the decoded public key bytes of the EOS address.
Returns a List
Implementation
@override
List<int> decodeAddr(String addr, [Map<String, dynamic> kwargs = const {}]) {
/// Remove the address prefix from the given address
final addrNoPrefix = AddrDecUtils.validateAndRemovePrefix(
addr, CoinsConf.eos.params.addrPrefix!);
/// Decode the remaining address bytes
final addrDecBytes = Base58Decoder.decode(addrNoPrefix);
/// Validate the length of the decoded address
AddrDecUtils.validateBytesLength(
addrDecBytes,
EcdsaKeysConst.pubKeyCompressedByteLen + EosAddrConst.checksumByteLen,
);
/// Split the address into its public key bytes and checksum
final parts = AddrDecUtils.splitPartsByChecksum(
addrDecBytes,
EosAddrConst.checksumByteLen,
);
final pubKeyBytes = parts.item1;
final checksumBytes = parts.item2;
/// Validate the checksum
AddrDecUtils.validateChecksum(
pubKeyBytes,
checksumBytes,
(pubKeyBytes) => _EosAddrUtils.computeChecksum(pubKeyBytes),
);
// Validate public key
// AddrDecUtils.validatePubKey(pubKeyBytes, Secp256k1PublicKey());
return pubKeyBytes;
}