Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
kigawas committed May 28, 2020
1 parent 45609fa commit 58d99dd
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
17 changes: 16 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# python-bip44

Simple python bip44 implementation = mnemonic + bip32.
Simple python bip44 implementation. Mnemonic + bip32.

## Quickstart
```python
>>> from coincurve import PrivateKey
>>> from bip44.wallet import Wallet
>>> from bip44.utils import get_eth_addr
>>> mnemonic = "purity tunnel grid error scout long fruit false embody caught skin gate"
>>> w = Wallet(mnemonic)
>>> sk, pk = w.derive_account("eth", account=0)
>>> sk = PrivateKey(sk)
>>> sk.public_key.format() == pk
True
>>> get_eth_addr(pk)
'0x7ad23d6ed9a1d98e240988bed0d78e8c81ec296c'
```
4 changes: 3 additions & 1 deletion bip44/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from typing import List

from bip32 import HARDENED_INDEX
from coincurve import PublicKey
from sha3 import keccak_256 as _keccak_256


Expand Down Expand Up @@ -28,4 +28,6 @@ def parse_path(s: str) -> List[int]:


def get_eth_addr(pk: bytes) -> str:
if len(pk) != 64:
pk = PublicKey(pk).format(False)[1:]
return f"0x{keccak_256(pk)[-20:].hex()}"
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
[tool.poetry]
name = "bip44"
version = "0.0.1"
description = "Mnemonic + python-bip32"
description = "Simple python bip44 implementation. Mnemonic + bip32."
repository = "https://github.com/kigawas/python-bip44"
authors = ["Weiliang Li <to.be.impressive@gmail.com>"]
maintainers = ["Weiliang Li <to.be.impressive@gmail.com>"]
readme = "README.md"
license = "MIT"

[tool.poetry.dependencies]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_bip44.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ def test_btc_wallet():

assert sk == expected_sk
assert pk == expected_pk
assert pk == PublicKey.from_secret(expected_pk).format()
assert pk == PublicKey.from_secret(expected_sk).format()

0 comments on commit 58d99dd

Please sign in to comment.