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.nano.params.addrPrefix,
      "addrPrefix",
    ),
  );

  // Prepend padding chars so the bit length aligns to a Base32 boundary.
  final addrDecBytes = Base32Decoder.decode(
    NanoAddrConst.payloadPadEnc + addrNoPrefix,
    NanoAddrConst.base32Alphabet,
  );

  AddrDecUtils.validateBytesLength(
    addrDecBytes,
    Ed25519KeysConst.pubKeyByteLen +
        QuickCrypto.blake2b40DigestSize +
        NanoAddrConst.payloadPadDec.length,
  );

  final decode = AddrDecUtils.splitPartsByChecksum(
    addrDecBytes.sublist(NanoAddrConst.payloadPadDec.length),
    QuickCrypto.blake2b40DigestSize,
  );

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

  AddrDecUtils.validateChecksum(
    pubKeyBytes,
    checksumBytes,
    _NanoAddrUtils.computeChecksum,
  );

  return BuBytes(pubKeyBytes);
}