driveEdPath static method

HdWallet driveEdPath(
  1. HdWallet base,
  2. String path
)

Implementation

static HdWallet driveEdPath(HdWallet base, String path) {
  if (!base.isMaster) {
    throw ArgumentError("wallet is not master");
  }
  if (!isValidPath(path)) throw ArgumentError("Expected BIP32 Path");
  List<String> splitPath = path.split("/");
  splitPath = splitPath.sublist(1);
  Uint8List prive = base._private;
  Uint8List chainCode = base._chainCode;
  for (String segment in splitPath) {
    bool isHardened = segment.contains("'");
    int index = int.parse(segment.replaceAll("'", ''));
    final indexResult = isHardened
        ? _getCKDPriv(prive, chainCode, index + _highBit)
        : _getCKDPriv(prive, chainCode, index);
    prive = indexResult.$1;
    chainCode = indexResult.$2;
  }
  // throw UnimplementedError();
  return HdWallet._child(prive, Uint8List(0), chainCode, 0, 0, Uint8List(4));
}