Skip to content

Commit

Permalink
fixed bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fametrano committed Feb 5, 2023
1 parent 8e76ad4 commit 581ac15
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion btclib/bip32/bip32.py
Expand Up @@ -444,7 +444,7 @@ def _derive_from_account(
if address_index >= 0x80000000:
raise BTClibValueError("invalid private derivation at address index level")
if address_index > max_index:
raise BTClibValueError(f"too high address index: {branch}")
raise BTClibValueError(f"too high address index: {address_index}")

return _derive(mxkey, f"m/{branch}/{address_index}")

Expand Down
4 changes: 2 additions & 2 deletions tests/bip32/test_bip32.py
Expand Up @@ -300,15 +300,15 @@ def test_derive_from_account() -> None:
with pytest.raises(BTClibValueError, match=err_msg):
derive_from_account(mxpub, 0xFFFF + 1, 0)

err_msg = "invalid branch: "
err_msg = "invalid branch: 2"
with pytest.raises(BTClibValueError, match=err_msg):
derive_from_account(mxpub, 2, 0)

err_msg = "invalid private derivation at address index level"
with pytest.raises(BTClibValueError, match=err_msg):
derive_from_account(mxpub, 0, 0x80000000)

err_msg = "too high address index: "
err_msg = "too high address index: 65536"
with pytest.raises(BTClibValueError, match=err_msg):
derive_from_account(mxpub, 0, 0xFFFF + 1)

Expand Down

0 comments on commit 581ac15

Please sign in to comment.