decodeShellyAddress static method

List<int> decodeShellyAddress(
  1. String address, {
  2. ADANetwork? network,
  3. bool keepPrefix = true,
})

Decode an ADA Shelly address string to bytes.

address: The address to decode. network: The network type. keepPrefix: Whether to keep the address prefix.

Returns a byte list representing the decoded address.

Implementation

static List<int> decodeShellyAddress(
  String address, {
  ADANetwork? network,
  bool keepPrefix = true,
}) {
  final decode =
      AdaGenericAddrDecoder().decode(address, {"net_tag": network});
  if (decode.type == ADAAddressType.byron) {
    throw ADAPluginException("Invalid shelly address.",
        details: {"address": address, "type": decode.type});
  }
  if (keepPrefix) {
    return decode.addressBytes;
  }
  return decode.addressBytes.sublist(decode.prefixBytes!.length);
}