Skip to content

Commit

Permalink
Merge branch 'main' into feature-thorest
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/core/jest.config.js
  • Loading branch information
lucanicoladebiasi committed Jan 21, 2025
2 parents 0665fae + 7d1cf92 commit 629c51b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 16 deletions.
13 changes: 13 additions & 0 deletions .github/ISSUE_TEMPLATE/task.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: "Task"
description: Create a new ticket for a new task.
title: "<title>"
labels: []
body:
- type: textarea
id: summary
attributes:
label: "Summary"
description: Provide a brief explanation of the feature.
placeholder: Describe in a few lines what should be done.
validations:
required: false
15 changes: 3 additions & 12 deletions packages/core/src/hdkey/HDKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -234,24 +234,15 @@ class HDKey extends s_bip32.HDKey {
}

/**
* Checks if derivation path is valid.
* Checks if BIP32 derivation path is valid.
*
* @param derivationPath - Derivation path to check.
*
* @returns `true` if derivation path is valid, otherwise `false`.
*/
public static isDerivationPathValid(derivationPath: string): boolean {
// Split derivation path into parts
const pathComponents = derivationPath.split('/');

// Check each component
for (let i = 0; i < pathComponents.length; i++) {
// If single component is not valid, return false
if (!this.isDerivationPathComponentValid(pathComponents[i], i))
return false;
}

return true;
const bip32Regex = /^m(\/\d+'?){3}(\/\d+){1,2}$/;
return bip32Regex.test(derivationPath);
}
}

Expand Down
11 changes: 7 additions & 4 deletions packages/core/tests/hdkey/HDKey.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,10 @@ const HDKeyFixture = {
correctValidationPaths: [
HDKey.VET_DERIVATION_PATH,
'm/0/1/2/3/4',
"m/0'/1'/2'/3'/4'",
"m/0'/1'/2'/3'/4",
"m/0'/1'/2/3'/4'"
"m/0'/1'/2'/3/4",
"m/44'/60'/0'/0/0",
"m/44'/60'/0'/0",
'm/0/1/2/3'
],

/**
Expand All @@ -64,7 +65,9 @@ const HDKeyFixture = {
'm/0/b',
'incorrect',
'inco/rre/01/ct',
'0/1/4/2/4/h'
'0/1/4/2/4/h',
'1/0/1',
"m/0'/1'/2/3'/4'"
]
};

Expand Down

0 comments on commit 629c51b

Please sign in to comment.