decodeAddr method

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

Decodes a Tezos (XTZ) blockchain address from its string representation to its byte data.

Implementation

@override
List<int> decodeAddr(String addr, {XtzAddrPrefixes? addressPrefix}) {
  /// Validate and retrieve the address prefix from the keyword arguments.
  addressPrefix = AddrKeyValidator.getAddrArg<XtzAddrPrefixes>(
    addressPrefix,
    "addressPrefix",
  );

  /// Decode the base58 address into bytes.
  final addrDecBytes = Base58Decoder.checkDecode(addr);

  /// Validate the length of the decoded address and remove the prefix bytes.
  AddrDecUtils.validateBytesLength(
    addrDecBytes,
    addressPrefix.value.length + 20,
  );
  final blakeBytes = AddrDecUtils.validateAndRemovePrefixBytes(
    addrDecBytes,
    addressPrefix.value,
  );

  return blakeBytes;
}