mm-btc 0.0.3__tar.gz → 0.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mm_btc-0.0.3 → mm_btc-0.0.4}/PKG-INFO +1 -1
- mm_btc-0.0.4/README.txt +1 -0
- {mm_btc-0.0.3 → mm_btc-0.0.4}/pyproject.toml +1 -1
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc/cli/cli.py +3 -1
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc/cli/cmd/mnemonic_cmd.py +12 -3
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc/wallet.py +2 -1
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc.egg-info/PKG-INFO +1 -1
- {mm_btc-0.0.3 → mm_btc-0.0.4}/tests/test_blockstream.py +7 -7
- mm_btc-0.0.4/tests/test_wallet.py +45 -0
- mm_btc-0.0.3/README.txt +0 -2
- mm_btc-0.0.3/tests/test_wallet.py +0 -44
- {mm_btc-0.0.3 → mm_btc-0.0.4}/setup.cfg +0 -0
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc/__init__.py +0 -0
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc/blockstream.py +0 -0
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc/cli/__init__.py +0 -0
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc/cli/cli_utils.py +0 -0
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc/cli/cmd/__init__.py +0 -0
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc/py.typed +0 -0
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc.egg-info/SOURCES.txt +0 -0
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc.egg-info/dependency_links.txt +0 -0
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc.egg-info/entry_points.txt +0 -0
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc.egg-info/requires.txt +0 -0
- {mm_btc-0.0.3 → mm_btc-0.0.4}/src/mm_btc.egg-info/top_level.txt +0 -0
mm_btc-0.0.4/README.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
mm-btc
|
|
@@ -12,8 +12,9 @@ app = typer.Typer(no_args_is_help=True, pretty_exceptions_enable=False, add_comp
|
|
|
12
12
|
@app.command(name="mnemonic", help="Generate keys based on a mnemonic")
|
|
13
13
|
def mnemonic_command( # nosec B107:hardcoded_password_default
|
|
14
14
|
mnemonic: Annotated[str, typer.Option("--mnemonic", "-m", help="")] = "",
|
|
15
|
-
passphrase: Annotated[str, typer.Option("--passphrase", "-
|
|
15
|
+
passphrase: Annotated[str, typer.Option("--passphrase", "-p")] = "",
|
|
16
16
|
path: Annotated[str, typer.Option("--path", help="Derivation path. Examples: bip44, bip88, m/44'/0'/0'/0")] = "bip44",
|
|
17
|
+
hex_: Annotated[bool, typer.Option("--hex", help="Print private key in hex format instead of WIF")] = False,
|
|
17
18
|
words: int = typer.Option(12, "--words", "-w", help="Number of mnemonic words"),
|
|
18
19
|
limit: int = typer.Option(10, "--limit", "-l"),
|
|
19
20
|
testnet: bool = typer.Option(False, "--testnet", "-t", help="Testnet network"),
|
|
@@ -25,6 +26,7 @@ def mnemonic_command( # nosec B107:hardcoded_password_default
|
|
|
25
26
|
words=words,
|
|
26
27
|
limit=limit,
|
|
27
28
|
path=path,
|
|
29
|
+
hex=hex_,
|
|
28
30
|
testnet=testnet,
|
|
29
31
|
)
|
|
30
32
|
)
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
|
+
from enum import Enum
|
|
2
3
|
|
|
3
4
|
from mm_std import print_plain
|
|
4
5
|
|
|
5
6
|
from mm_btc.wallet import derive_accounts, generate_mnemonic
|
|
6
7
|
|
|
7
8
|
|
|
9
|
+
class PrivateType(str, Enum):
|
|
10
|
+
hex = "hex"
|
|
11
|
+
wif = "wif"
|
|
12
|
+
|
|
13
|
+
|
|
8
14
|
@dataclass
|
|
9
15
|
class Args:
|
|
10
16
|
mnemonic: str
|
|
11
17
|
passphrase: str
|
|
12
18
|
words: int
|
|
13
19
|
limit: int
|
|
20
|
+
hex: bool # Print private key in hex format instead of WIF
|
|
14
21
|
path: str
|
|
15
22
|
testnet: bool
|
|
16
23
|
|
|
@@ -21,10 +28,12 @@ def run(args: Args) -> None:
|
|
|
21
28
|
path = get_derivation_path_prefix(args.path, args.testnet)
|
|
22
29
|
accounts = derive_accounts(mnemonic, passphrase, path, args.limit)
|
|
23
30
|
|
|
24
|
-
print_plain(f"
|
|
25
|
-
|
|
31
|
+
print_plain(f"{mnemonic}")
|
|
32
|
+
if passphrase:
|
|
33
|
+
print_plain(f"{passphrase}")
|
|
26
34
|
for acc in accounts:
|
|
27
|
-
|
|
35
|
+
private = acc.private if args.hex else acc.wif
|
|
36
|
+
print_plain(f"{acc.path} {acc.address} {private}")
|
|
28
37
|
|
|
29
38
|
|
|
30
39
|
def get_derivation_path_prefix(path: str, testnet: bool) -> str:
|
|
@@ -14,6 +14,7 @@ BIP84_TESTNET_PATH = "m/84'/1'/0'/0"
|
|
|
14
14
|
class Account:
|
|
15
15
|
address: str
|
|
16
16
|
private: str
|
|
17
|
+
wif: str
|
|
17
18
|
path: str
|
|
18
19
|
|
|
19
20
|
|
|
@@ -40,7 +41,7 @@ def derive_accounts(mnemonic: str, passphrase: str, path: str, limit: int) -> li
|
|
|
40
41
|
accounts = []
|
|
41
42
|
for index_path in range(limit):
|
|
42
43
|
w.from_path(path=f"{path}/{index_path}")
|
|
43
|
-
accounts.append(Account(address=w.address(), private=w.wif(), path=f"{path}/{index_path}"))
|
|
44
|
+
accounts.append(Account(address=w.address(), private=w.private_key(), wif=w.wif(), path=f"{path}/{index_path}"))
|
|
44
45
|
w.clean_derivation()
|
|
45
46
|
|
|
46
47
|
return accounts
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
from mm_btc import blockstream
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
def test_get_address(binance_address):
|
|
4
|
+
def test_get_address(binance_address, proxies):
|
|
5
5
|
# non-empty address
|
|
6
|
-
res = blockstream.get_address(binance_address)
|
|
6
|
+
res = blockstream.get_address(binance_address, proxies=proxies)
|
|
7
7
|
assert res.unwrap().chain_stats.tx_count > 800
|
|
8
8
|
|
|
9
9
|
# empty address
|
|
10
|
-
res = blockstream.get_address("bc1pa48c294qk7yd7sc8y0wxydc3a2frv5j83e65rvm48v3ej098s5zs8kvh6d")
|
|
10
|
+
res = blockstream.get_address("bc1pa48c294qk7yd7sc8y0wxydc3a2frv5j83e65rvm48v3ej098s5zs8kvh6d", proxies=proxies)
|
|
11
11
|
assert res.unwrap().chain_stats.tx_count == 0
|
|
12
12
|
|
|
13
13
|
# invalid address
|
|
14
|
-
res = blockstream.get_address("bc1pa48c294qk7yd7sc8y0wxydc3a2frv5j83e65rvm48v3ej098s5zs8kvh5d")
|
|
14
|
+
res = blockstream.get_address("bc1pa48c294qk7yd7sc8y0wxydc3a2frv5j83e65rvm48v3ej098s5zs8kvh5d", proxies=proxies)
|
|
15
15
|
assert res.unwrap_err() == blockstream.ERROR_INVALID_ADDRESS
|
|
16
16
|
|
|
17
17
|
# invalid network
|
|
18
|
-
res = blockstream.get_address(binance_address, testnet=True)
|
|
18
|
+
res = blockstream.get_address(binance_address, testnet=True, proxies=proxies)
|
|
19
19
|
assert res.unwrap_err() == blockstream.ERROR_INVALID_NETWORK
|
|
20
20
|
|
|
21
21
|
|
|
22
|
-
def test_get_confirmed_balance(binance_address):
|
|
23
|
-
res = blockstream.get_confirmed_balance(binance_address)
|
|
22
|
+
def test_get_confirmed_balance(binance_address, proxies):
|
|
23
|
+
res = blockstream.get_confirmed_balance(binance_address, proxies=proxies)
|
|
24
24
|
assert res.unwrap() > 0
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
from mm_btc.wallet import (
|
|
2
|
+
BIP44_MAINNET_PATH,
|
|
3
|
+
BIP44_TESTNET_PATH,
|
|
4
|
+
BIP84_MAINNET_PATH,
|
|
5
|
+
BIP84_TESTNET_PATH,
|
|
6
|
+
derive_accounts,
|
|
7
|
+
generate_mnemonic,
|
|
8
|
+
)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
def test_generate_mnemonic():
|
|
12
|
+
mnemonic = generate_mnemonic(words=24)
|
|
13
|
+
assert len(mnemonic.split()) == 24
|
|
14
|
+
|
|
15
|
+
assert generate_mnemonic() != generate_mnemonic()
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def test_derive_accounts(mnemonic, passphrase):
|
|
19
|
+
# mainnet bip44
|
|
20
|
+
accs = derive_accounts(mnemonic, passphrase, BIP44_MAINNET_PATH, 2)
|
|
21
|
+
assert accs[1].path == "m/44'/0'/0'/0/1"
|
|
22
|
+
assert accs[1].address == "13MJrGQq8RwLcGfdnY58666kCsZqevsadE"
|
|
23
|
+
assert accs[1].private == "0d5feb50af849f2ebcc0c83a4446ddbceefd7b0ceba437a57161fa37702d096e"
|
|
24
|
+
assert accs[1].wif == "Kwfi75WxsuaKnmxRUQDoEZDzKXkMC8E9Pzk3vVjEdPsJu1DXCFPv"
|
|
25
|
+
|
|
26
|
+
# mainnet bip84
|
|
27
|
+
accs = derive_accounts(mnemonic, passphrase, BIP84_MAINNET_PATH, 2)
|
|
28
|
+
assert accs[1].path == "m/84'/0'/0'/0/1"
|
|
29
|
+
assert accs[1].address == "bc1qszqeg6gfcmt8zurkeayes2895urnea2m54rt3w"
|
|
30
|
+
assert accs[1].private == "1cc57553f9e3e1b863693be92ac753f682f61f1a2dede2ceff97262027635334"
|
|
31
|
+
assert accs[1].wif == "KxBdzQTQduYKoec1FWgwMDF9R1a4UdQp3ezyhjniw4W2k54Cb6gE"
|
|
32
|
+
|
|
33
|
+
# testnet bip44
|
|
34
|
+
accs = derive_accounts(mnemonic, passphrase, BIP44_TESTNET_PATH, 2)
|
|
35
|
+
assert accs[1].path == "m/44'/1'/0'/0/1"
|
|
36
|
+
assert accs[1].address == "miRfXh2aH6pjhdo5EoBt4RRdAipR88dcV3"
|
|
37
|
+
assert accs[1].private == "3a2e8fc45c75ab8a7cdafacf7c77c941f8eebc813ee2f0e17ee86e7ac8584b3a"
|
|
38
|
+
assert accs[1].wif == "cPXoLA4cRKxeht4iH6ZsCDQxPspFi8SEieZNTKDzGgog94Zg5Y64"
|
|
39
|
+
|
|
40
|
+
# testnet bip84
|
|
41
|
+
accs = derive_accounts(mnemonic, passphrase, BIP84_TESTNET_PATH, 2)
|
|
42
|
+
assert accs[1].path == "m/84'/1'/0'/0/1"
|
|
43
|
+
assert accs[1].address == "tb1qp36pk9w408pgfpwn5myxwurr3fhzryn0lpyah2"
|
|
44
|
+
assert accs[1].private == "150fd20e4cb377ae57b43fed59ca2765a9f5d91a20640a4cfdf43ceb5403d48c"
|
|
45
|
+
assert accs[1].wif == "cNHeFPcfq2XFfDAgq9icSK8NX29C1exPHekqYQdWgruQ6gPMBmXD"
|
mm_btc-0.0.3/README.txt
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
from mm_btc.wallet import (
|
|
2
|
-
BIP44_MAINNET_PATH,
|
|
3
|
-
BIP44_TESTNET_PATH,
|
|
4
|
-
BIP84_MAINNET_PATH,
|
|
5
|
-
BIP84_TESTNET_PATH,
|
|
6
|
-
derive_accounts,
|
|
7
|
-
generate_mnemonic,
|
|
8
|
-
)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
def test_generate_mnemonic():
|
|
12
|
-
mnemonic = generate_mnemonic(words=24)
|
|
13
|
-
assert len(mnemonic.split()) == 24
|
|
14
|
-
|
|
15
|
-
assert generate_mnemonic() != generate_mnemonic()
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def test_derive_accounts():
|
|
19
|
-
mnemonic = "arrange mutual earth tackle smart kangaroo rigid census exotic acoustic stock dream eager area laptop"
|
|
20
|
-
passphrase = "my-secret"
|
|
21
|
-
|
|
22
|
-
# mainnet bip44
|
|
23
|
-
accs = derive_accounts(mnemonic, passphrase, BIP44_MAINNET_PATH, 2)
|
|
24
|
-
assert accs[1].path == "m/44'/0'/0'/0/1"
|
|
25
|
-
assert accs[1].address == "1L4Ghh4kuJuRCXrFrczwCV2TaggfCgf6B3"
|
|
26
|
-
assert accs[1].private == "Kz4zoYPJ5astywoTbxHQr5SgFvMCekMqnWDFnXjY9CfvFtyNnGiE"
|
|
27
|
-
|
|
28
|
-
# mainnet bip84
|
|
29
|
-
accs = derive_accounts(mnemonic, passphrase, BIP84_MAINNET_PATH, 2)
|
|
30
|
-
assert accs[1].path == "m/84'/0'/0'/0/1"
|
|
31
|
-
assert accs[1].address == "bc1qrq2mwuqz3utyqz97xjq5npl0dyq5gmddpxdf8k"
|
|
32
|
-
assert accs[1].private == "L447sW2JenqmEMMi7GoiUZDxTpY3Ni5ZfRrRxAbufiYwZV1AHytj"
|
|
33
|
-
|
|
34
|
-
# testnet bip44
|
|
35
|
-
accs = derive_accounts(mnemonic, passphrase, BIP44_TESTNET_PATH, 2)
|
|
36
|
-
assert accs[1].path == "m/44'/1'/0'/0/1"
|
|
37
|
-
assert accs[1].address == "n3DsvbopmKJaxHNgdZ6VVK4mB9fcuhXy5w"
|
|
38
|
-
assert accs[1].private == "cVsAhYpSm2x8V2fQJdjmfBGm1aW7xKH1U8eZTpG9giz8usxNv4da"
|
|
39
|
-
|
|
40
|
-
# testnet bip84
|
|
41
|
-
accs = derive_accounts(mnemonic, passphrase, BIP84_TESTNET_PATH, 2)
|
|
42
|
-
assert accs[1].path == "m/84'/1'/0'/0/1"
|
|
43
|
-
assert accs[1].address == "tb1q4cu7pgs0w5s4ctjz4m6gx6m4rv8eqjwtnt0a4j"
|
|
44
|
-
assert accs[1].private == "cPASMrozgCxXD6GQsJhge7hPY81j3huF8RJBY1PYwKmUVSYgeSRw"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|