derivePath method

HDNode derivePath (String path)

Derives a new HDNode from this instance based on the path

Implementation

HDNode derivePath(String path) {
  List<String> splitPath = path.split('/');

  if (splitPath[0] == 'm') {
    splitPath = splitPath.sublist(1);
  }

  return splitPath.fold(this, (HDNode prevHd, String indexStr) {
    int index;
    if (indexStr.endsWith("'")) {
      index = int.parse(indexStr.substring(0, indexStr.length - 1));
      return prevHd._deriveHardened(index);
    } else {
      index = int.parse(indexStr);
      return prevHd.derive(index);
    }
  });
}