decodeAddr method

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

Decodes a given blockchain address string.

Throws AddressConverterException on invalid input.

Implementation

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

  AddrDecUtils.validateBytesLength(
    addrDecBytes,
    QuickCrypto.hash160DigestSize + verBytes.length,
  );

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

  return addrDecBytes.sublist(1);
}