Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support m derivation path #301

Merged
merged 3 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions safe_cli/operators/hw_accounts/ledger_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ def add_account(self, derivation_path: str) -> ChecksumAddress:
:param derivation_path:
:return:
"""
# we should accept m/ or m'/ starting derivation paths
if derivation_path[0:2] == "m/":
derivation_path = derivation_path.replace("m/", "")

if not is_bip32_path(derivation_path):
raise InvalidDerivationPath()

Expand Down
5 changes: 5 additions & 0 deletions tests/test_ledger_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,11 @@ def test_add_account(self, mock_get_account_by_path: MagicMock):
ledger_account = list(ledger_manager.accounts)[0]
self.assertEqual(ledger_account.address, account_address)
self.assertEqual(ledger_account.path, derivation_path)
# Should accept derivation paths starting with master
master_derivation_path = "m/44'/60'/0'/0"
self.assertEqual(
ledger_manager.add_account(master_derivation_path), account_address
)

def test_delete_account(self):
ledger_manager = LedgerManager()
Expand Down