getHDPath function

List<int> getHDPath(
  1. String path
)

Implementation

List<int> getHDPath(String path) {
  List<String> parts = path.replaceAll('-', '/').toLowerCase().split('/');
  return parts.where((p) => p != 'm' && p != '').map((p) {
    if (p.endsWith("'")) {
      p = p.substring(0, p.length - 1);
    }
    int? n = int.tryParse(p);
    if (n == null) {
      throw 'PATH_NOT_VALID';
    } else if (n < 0) {
      throw 'PATH_NEGATIVE_VALUES';
    }
    return n;
  }).toList();
}