decodeAddr method

  1. @override
BuBytes decodeAddr(
  1. String addr
)
override

Decodes a given blockchain address string.

Throws AddressConverterException on invalid input.

Implementation

@override
BuBytes decodeAddr(String addr) {
  final addrNoPrefix = AddrDecUtils.validateAndRemovePrefix(
    addr,
    AddrKeyValidator.getConfigArg(
      CoinsConf.eos.params.addrPrefix,
      "addrPrefix",
    ),
  );

  final addrDecBytes = Base58Decoder.decode(addrNoPrefix);

  AddrDecUtils.validateBytesLength(
    addrDecBytes,
    EcdsaKeysConst.pubKeyCompressedByteLen + EosAddrConst.checksumByteLen,
  );

  final parts = AddrDecUtils.splitPartsByChecksum(
    addrDecBytes,
    EosAddrConst.checksumByteLen,
  );

  final pubKeyBytes = parts.$1;
  final checksumBytes = parts.$2;

  AddrDecUtils.validateChecksum(
    pubKeyBytes,
    checksumBytes,
    (pubKeyBytes) => _EosAddrUtils.computeChecksum(pubKeyBytes),
  );

  return BuBytes(pubKeyBytes);
}