Skip to content

Commit b3589d6

Browse files
committed
Merge branch 'python-slip39'; v2.3.0
2 parents ecade4b + b92f0a6 commit b3589d6

19 files changed

+386
-58
lines changed

.github/workflows/pythonpackage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
strategy:
1919
matrix:
2020
python-version: [
21-
"3.7", "3.8", "3.9", "3.10", "3.11"
21+
"3.8", "3.9", "3.10", "3.11", "3.12", "3.13"
2222
]
2323
steps:
2424
- uses: actions/checkout@master

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,5 @@ __pycache__/
2020

2121
# py.test stuff
2222
.pytest_cache/
23+
*~
24+
.#*

GNUmakefile

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,17 @@
11
SHELL = /bin/bash
22
PY3 ?= $(shell python3 --version >/dev/null 2>&1 && echo python3 || echo python )
3-
VERSION = $(shell $(PY3) -c 'from hdwallet import __version__; print( __version__.strip("v"))')
3+
PY3_V = $(shell $(PY3) -c "import sys; print('-'.join((next(iter(filter(None,sys.executable.split('/')))),sys.platform,sys.implementation.cache_tag)))" 2>/dev/null )
4+
VERSION = $(shell $(PY3) -c 'exec(open("hdwallet/version.py", "r").read()); print( __version__.strip("v"))')
45
WHEEL = dist/hdwallet-$(VERSION)-py3-none-any.whl
56

67
PY3TEST = $(PY3) -m pytest
78

9+
GHUB_NAME = python-hdwallet
10+
VENV_DIR = $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))/.. )
11+
VENV_NAME = $(GHUB_NAME)-$(VERSION)-$(PY3_V)
12+
VENV = $(VENV_DIR)/$(VENV_NAME)
13+
VENV_OPTS =
14+
815
.PHONY: all test build build-check wheel install-dev install clean FORCE
916

1017
all: build
@@ -19,28 +26,30 @@ test-%:
1926
unit-%:
2027
$(PY3TEST) -k $*
2128

22-
build: clean wheel
29+
nix-%:
30+
nix-shell --pure --run "make $*"
2331

24-
build-check:
25-
@$(PY3) -m build --version \
26-
|| ( \
27-
echo -e "\n\n!!! Missing Python modules; run:"; \
28-
echo -e "\n\n $(PY3) -m pip install --upgrade pip setuptools wheel build\n"; \
29-
false; \
30-
)
32+
build: clean wheel
3133

3234
wheel: $(WHEEL)
3335

34-
$(WHEEL): build-check FORCE
36+
$(WHEEL): FORCE
37+
$(PY3) -m pip install -r requirements-dev.txt
3538
$(PY3) -m build
3639
@ls -last dist
3740

38-
# Install from wheel, including all optional extra dependencies (except dev)
39-
install-dev: $(WHEEL) FORCE
40-
$(PY3) -m pip install --upgrade $<[tests]
41-
4241
install: $(WHEEL) FORCE
43-
$(PY3) -m pip install --force-reinstall $<[cli,docs]
42+
$(PY3) -m pip install --force-reinstall .[cli,docs]
4443

4544
clean:
4645
@rm -rf build dist *.egg-info $(shell find . -name '__pycache__' )
46+
47+
venv: $(VENV)
48+
@echo; echo "*** Activating $< VirtualEnv for Interactive $(SHELL)"
49+
@bash --init-file $</bin/activate -i
50+
51+
$(VENV):
52+
@echo; echo "*** Building $@ VirtualEnv..."
53+
@rm -rf $@ && $(PY3) -m venv $(VENV_OPTS) $@ \
54+
&& source $@/bin/activate \
55+
&& make install

MANIFEST.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
include LICENSE
22
include README.md
3-
include requirements.txt
3+
include requirements*.txt
44

5+
global-exclude *~
56
recursive-exclude * __pycache__
67
recursive-exclude * *.py[co]

default.nix

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
{ pkgs ? import ./nixpkgs.nix {} }:
2+
3+
with pkgs;
4+
5+
let
6+
in
7+
{
8+
py313 = stdenv.mkDerivation rec {
9+
name = "python313-with-pytest";
10+
11+
buildInputs = [
12+
git
13+
openssh
14+
python313
15+
python313Packages.pytest
16+
];
17+
};
18+
19+
py312 = stdenv.mkDerivation rec {
20+
name = "python312-with-pytest";
21+
22+
buildInputs = [
23+
git
24+
openssh
25+
python312
26+
python312Packages.pytest
27+
];
28+
};
29+
30+
py311 = stdenv.mkDerivation rec {
31+
name = "python311-with-pytest";
32+
33+
buildInputs = [
34+
git
35+
openssh
36+
python311
37+
python311Packages.pytest
38+
];
39+
};
40+
41+
py310 = stdenv.mkDerivation rec {
42+
name = "python310-with-pytest";
43+
44+
buildInputs = [
45+
git
46+
openssh
47+
python310
48+
python310Packages.pytest
49+
];
50+
};
51+
52+
py39 = stdenv.mkDerivation rec {
53+
name = "python39-with-pytest";
54+
55+
buildInputs = [
56+
git
57+
openssh
58+
python39
59+
python39Packages.pytest
60+
];
61+
};
62+
}

hdwallet/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
)
1111

1212
# HDWallet Information's
13-
__version__: str = "v2.2.1"
13+
from .version import (
14+
__version__,
15+
__version_info__
16+
)
1417
__license__: str = "MIT"
1518
__author__: str = "Meheret Tesfaye Batu"
1619
__email__: str = "[email protected]"
@@ -19,6 +22,7 @@
1922

2023
__all__: list = [
2124
"__version__",
25+
"__version_info__",
2226
"__license__",
2327
"__author__",
2428
"__email__",

hdwallet/cryptocurrencies.py

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,6 +2153,206 @@ class EthereumMainnet(Cryptocurrency):
21532153
WIF_SECRET_KEY = 0x80
21542154

21552155

2156+
class BinanceSmartChainMainnet(Cryptocurrency):
2157+
2158+
NAME = "Binance Smart Chain"
2159+
SYMBOL = "BSC"
2160+
NETWORK = "mainnet"
2161+
SOURCE_CODE = "https://github.com/bnb-chain/bsc"
2162+
COIN_TYPE = CoinType({
2163+
"INDEX": 9006,
2164+
"HARDENED": True
2165+
})
2166+
2167+
SCRIPT_ADDRESS = 0x05
2168+
PUBLIC_KEY_ADDRESS = 0x00
2169+
SEGWIT_ADDRESS = SegwitAddress({
2170+
"HRP": "bc",
2171+
"VERSION": 0x00
2172+
})
2173+
2174+
EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
2175+
"P2PKH": 0x0488ade4,
2176+
"P2SH": 0x0488ade4,
2177+
"P2WPKH": 0x04b2430c,
2178+
"P2WPKH_IN_P2SH": 0x049d7878,
2179+
"P2WSH": 0x02aa7a99,
2180+
"P2WSH_IN_P2SH": 0x0295b005
2181+
})
2182+
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
2183+
"P2PKH": 0x0488b21e,
2184+
"P2SH": 0x0488b21e,
2185+
"P2WPKH": 0x04b24746,
2186+
"P2WPKH_IN_P2SH": 0x049d7cb2,
2187+
"P2WSH": 0x02aa7ed3,
2188+
"P2WSH_IN_P2SH": 0x0295b43f
2189+
})
2190+
2191+
MESSAGE_PREFIX = None
2192+
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
2193+
WIF_SECRET_KEY = 0x80
2194+
2195+
2196+
class PolygonMainnet(Cryptocurrency):
2197+
2198+
NAME = "Polygon"
2199+
SYMBOL = "MATIC"
2200+
NETWORK = "mainnet"
2201+
SOURCE_CODE = "https://github.com/bnb-chain/bsc"
2202+
COIN_TYPE = CoinType({
2203+
"INDEX": 966,
2204+
"HARDENED": True
2205+
})
2206+
2207+
SCRIPT_ADDRESS = 0x05
2208+
PUBLIC_KEY_ADDRESS = 0x00
2209+
SEGWIT_ADDRESS = SegwitAddress({
2210+
"HRP": "bc",
2211+
"VERSION": 0x00
2212+
})
2213+
2214+
EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
2215+
"P2PKH": 0x0488ade4,
2216+
"P2SH": 0x0488ade4,
2217+
"P2WPKH": 0x04b2430c,
2218+
"P2WPKH_IN_P2SH": 0x049d7878,
2219+
"P2WSH": 0x02aa7a99,
2220+
"P2WSH_IN_P2SH": 0x0295b005
2221+
})
2222+
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
2223+
"P2PKH": 0x0488b21e,
2224+
"P2SH": 0x0488b21e,
2225+
"P2WPKH": 0x04b24746,
2226+
"P2WPKH_IN_P2SH": 0x049d7cb2,
2227+
"P2WSH": 0x02aa7ed3,
2228+
"P2WSH_IN_P2SH": 0x0295b43f
2229+
})
2230+
2231+
MESSAGE_PREFIX = None
2232+
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
2233+
WIF_SECRET_KEY = 0x80
2234+
2235+
2236+
class ArbitrumMainnet(Cryptocurrency):
2237+
2238+
NAME = "Arbitrum"
2239+
SYMBOL = "ARB1"
2240+
NETWORK = "mainnet"
2241+
SOURCE_CODE = "https://github.com/bnb-chain/bsc"
2242+
COIN_TYPE = CoinType({
2243+
"INDEX": 9001,
2244+
"HARDENED": True
2245+
})
2246+
2247+
SCRIPT_ADDRESS = 0x05
2248+
PUBLIC_KEY_ADDRESS = 0x00
2249+
SEGWIT_ADDRESS = SegwitAddress({
2250+
"HRP": "bc",
2251+
"VERSION": 0x00
2252+
})
2253+
2254+
EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
2255+
"P2PKH": 0x0488ade4,
2256+
"P2SH": 0x0488ade4,
2257+
"P2WPKH": 0x04b2430c,
2258+
"P2WPKH_IN_P2SH": 0x049d7878,
2259+
"P2WSH": 0x02aa7a99,
2260+
"P2WSH_IN_P2SH": 0x0295b005
2261+
})
2262+
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
2263+
"P2PKH": 0x0488b21e,
2264+
"P2SH": 0x0488b21e,
2265+
"P2WPKH": 0x04b24746,
2266+
"P2WPKH_IN_P2SH": 0x049d7cb2,
2267+
"P2WSH": 0x02aa7ed3,
2268+
"P2WSH_IN_P2SH": 0x0295b43f
2269+
})
2270+
2271+
MESSAGE_PREFIX = None
2272+
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
2273+
WIF_SECRET_KEY = 0x80
2274+
2275+
2276+
class zkSyncMainnet(Cryptocurrency):
2277+
2278+
NAME = "zkSync"
2279+
SYMBOL = "ZKS"
2280+
NETWORK = "mainnet"
2281+
SOURCE_CODE = "https://github.com/bnb-chain/bsc"
2282+
COIN_TYPE = CoinType({
2283+
"INDEX": 804,
2284+
"HARDENED": True
2285+
})
2286+
2287+
SCRIPT_ADDRESS = 0x05
2288+
PUBLIC_KEY_ADDRESS = 0x00
2289+
SEGWIT_ADDRESS = SegwitAddress({
2290+
"HRP": "bc",
2291+
"VERSION": 0x00
2292+
})
2293+
2294+
EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
2295+
"P2PKH": 0x0488ade4,
2296+
"P2SH": 0x0488ade4,
2297+
"P2WPKH": 0x04b2430c,
2298+
"P2WPKH_IN_P2SH": 0x049d7878,
2299+
"P2WSH": 0x02aa7a99,
2300+
"P2WSH_IN_P2SH": 0x0295b005
2301+
})
2302+
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
2303+
"P2PKH": 0x0488b21e,
2304+
"P2SH": 0x0488b21e,
2305+
"P2WPKH": 0x04b24746,
2306+
"P2WPKH_IN_P2SH": 0x049d7cb2,
2307+
"P2WSH": 0x02aa7ed3,
2308+
"P2WSH_IN_P2SH": 0x0295b43f
2309+
})
2310+
2311+
MESSAGE_PREFIX = None
2312+
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
2313+
WIF_SECRET_KEY = 0x80
2314+
2315+
2316+
class LineaMainnet(Cryptocurrency):
2317+
2318+
NAME = "Linea"
2319+
SYMBOL = "LINEA"
2320+
NETWORK = "mainnet"
2321+
SOURCE_CODE = "https://github.com/bnb-chain/bsc"
2322+
COIN_TYPE = CoinType({
2323+
"INDEX": 59144,
2324+
"HARDENED": True
2325+
})
2326+
2327+
SCRIPT_ADDRESS = 0x05
2328+
PUBLIC_KEY_ADDRESS = 0x00
2329+
SEGWIT_ADDRESS = SegwitAddress({
2330+
"HRP": "bc",
2331+
"VERSION": 0x00
2332+
})
2333+
2334+
EXTENDED_PRIVATE_KEY = ExtendedPrivateKey({
2335+
"P2PKH": 0x0488ade4,
2336+
"P2SH": 0x0488ade4,
2337+
"P2WPKH": 0x04b2430c,
2338+
"P2WPKH_IN_P2SH": 0x049d7878,
2339+
"P2WSH": 0x02aa7a99,
2340+
"P2WSH_IN_P2SH": 0x0295b005
2341+
})
2342+
EXTENDED_PUBLIC_KEY = ExtendedPublicKey({
2343+
"P2PKH": 0x0488b21e,
2344+
"P2SH": 0x0488b21e,
2345+
"P2WPKH": 0x04b24746,
2346+
"P2WPKH_IN_P2SH": 0x049d7cb2,
2347+
"P2WSH": 0x02aa7ed3,
2348+
"P2WSH_IN_P2SH": 0x0295b43f
2349+
})
2350+
2351+
MESSAGE_PREFIX = None
2352+
DEFAULT_PATH = f"m/44'/{str(COIN_TYPE)}/0'/0/0"
2353+
WIF_SECRET_KEY = 0x80
2354+
2355+
21562356
class EuropeCoinMainnet(Cryptocurrency):
21572357

21582358
NAME = "Europe Coin"

hdwallet/derivations.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def from_path(cls, path: str) -> "Derivation":
6767
6868
>>> from hdwallet.derivations import Derivation
6969
>>> derivation = Derivation()
70-
>>> derivation.from_path(path="m/44'/0'/'0/0/0")
70+
>>> derivation.from_path(path="m/44'/0'/0'/0/0")
7171
<hdwallet.derivation.Derivation object at 0x000001E8BFB98D60>
7272
"""
7373

@@ -123,9 +123,9 @@ def clean_derivation(self) -> "Derivation":
123123
124124
>>> from hdwallet.derivations import Derivation
125125
>>> derivation = Derivation()
126-
>>> derivation.from_path(path="m/44'/0'/'0/0/0")
126+
>>> derivation.from_path(path="m/44'/0'/0'/0/0")
127127
>>> str(derivation)
128-
"m/44'/0'/'0/0/0"
128+
"m/44'/0'/0'/0/0"
129129
>>> derivation.clean_derivation()
130130
<hdwallet.wallet.HDWallet object at 0x000001E8BFB98D60>
131131
>>> str(derivation)

0 commit comments

Comments
 (0)