decodeAddr method

  1. @override
List<int> decodeAddr(
  1. String addr
)
override

Overrides the base class method to decode a Nano (NANO) address.

Implementation

@override
List<int> decodeAddr(String addr) {
  /// Validate and remove the Nano address prefix.
  final addrNoPrefix = AddrDecUtils.validateAndRemovePrefix(
    addr,
    AddrKeyValidator.getConfigArg(
      CoinsConf.nano.params.addrPrefix,
      "addrPrefix",
    ),
  );

  /// Decode the Base32-encoded payload using the custom Nano Base32 alphabet and padding.
  final addrDecBytes = Base32Decoder.decode(
    NanoAddrConst.payloadPadEnc + addrNoPrefix,
    NanoAddrConst.base32Alphabet,
  );

  /// Validate the length of the decoded address.
  AddrDecUtils.validateBytesLength(
    addrDecBytes,
    Ed25519KeysConst.pubKeyByteLen +
        QuickCrypto.blake2b40DigestSize +
        NanoAddrConst.payloadPadDec.length,
  );

  /// Split the decoded address into its public key and checksum parts.
  final decode = AddrDecUtils.splitPartsByChecksum(
    addrDecBytes.sublist(NanoAddrConst.payloadPadDec.length),
    QuickCrypto.blake2b40DigestSize,
  );

  /// Retrieve the public key bytes and checksum bytes.
  final pubKeyBytes = decode.$1;
  final checksumBytes = decode.$2;

  /// Validate the address checksum using the computed checksum function.
  AddrDecUtils.validateChecksum(
    pubKeyBytes,
    checksumBytes,
    _NanoAddrUtils.computeChecksum,
  );

  return pubKeyBytes;
}