drivePath static method
Implementation
static HdWallet drivePath(HdWallet base, String path) {
if (!isValidPath(path)) throw ArgumentError("Expected BIP32 Path");
List<String> splitPath = path.split("/");
if (splitPath[0] == "m") {
if (!base.isMaster) {
throw ArgumentError("wallet is not master");
}
splitPath = splitPath.sublist(1);
}
return splitPath.fold(base, (HdWallet prevHd, String indexStr) {
int index;
if (indexStr.substring(indexStr.length - 1) == "'") {
index = int.parse(indexStr.substring(0, indexStr.length - 1));
if (index > _maxUint31 || index < 0) {
throw ArgumentError("Expected UInt31");
}
final f = prevHd._addDrive(index + _highBit);
return f;
} else {
index = int.parse(indexStr);
final f = prevHd._addDrive(index);
return f;
}
});
}