Skip to content

Commit

Permalink
Merge pull request #71 from twostack/bip32_update
Browse files Browse the repository at this point in the history
Hardened path verification / validation
  • Loading branch information
stephanfeb authored Sep 20, 2023
2 parents 2021973 + f34ce07 commit ce929b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/dartsv.dart
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,6 @@ export 'src/encoding/utils.dart';
export 'src/encoding/base58check.dart';
export 'src/crypto/ecies.dart';
export 'src/crypto/hdutils.dart';
export 'src/crypto/childnumber.dart';


6 changes: 5 additions & 1 deletion lib/src/crypto/hdutils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ class HDUtils {
static List<ChildNumber> parsePath(String path) {

if (!(path.startsWith("m") || path.startsWith("M")))
throw new InvalidPathException("Valid paths start with an 'm' or an 'M'");
throw InvalidPathException("Valid paths start with an 'm' or an 'M'");

final regex = RegExp(r"^([mM]\/)?(\d+'?\/)*\d+'?$");
if (!regex.hasMatch(path)) throw InvalidPathException("Invalid path expression");


path = path.toUpperCase();
path = path.replaceAll("'", "H");
Expand Down

0 comments on commit ce929b1

Please sign in to comment.