mm-btc 0.0.3__py3-none-any.whl → 0.0.5__py3-none-any.whl
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/cli/cli.py +16 -4
- mm_btc/cli/cmd/address_cmd.py +10 -0
- mm_btc/cli/cmd/mnemonic_cmd.py +12 -3
- mm_btc/wallet.py +6 -1
- {mm_btc-0.0.3.dist-info → mm_btc-0.0.5.dist-info}/METADATA +1 -1
- mm_btc-0.0.5.dist-info/RECORD +15 -0
- mm_btc-0.0.3.dist-info/RECORD +0 -14
- {mm_btc-0.0.3.dist-info → mm_btc-0.0.5.dist-info}/WHEEL +0 -0
- {mm_btc-0.0.3.dist-info → mm_btc-0.0.5.dist-info}/entry_points.txt +0 -0
- {mm_btc-0.0.3.dist-info → mm_btc-0.0.5.dist-info}/top_level.txt +0 -0
mm_btc/cli/cli.py
CHANGED
|
@@ -1,23 +1,27 @@
|
|
|
1
1
|
from typing import Annotated
|
|
2
2
|
|
|
3
3
|
import typer
|
|
4
|
+
import typer.core
|
|
4
5
|
from mm_std import print_plain
|
|
5
6
|
|
|
6
7
|
from mm_btc.cli import cli_utils
|
|
7
|
-
from mm_btc.cli.cmd import mnemonic_cmd
|
|
8
|
+
from mm_btc.cli.cmd import address_cmd, mnemonic_cmd
|
|
8
9
|
|
|
9
10
|
app = typer.Typer(no_args_is_help=True, pretty_exceptions_enable=False, add_completion=False)
|
|
10
11
|
|
|
11
12
|
|
|
12
|
-
@app.command(
|
|
13
|
+
@app.command("mnemonic")
|
|
14
|
+
@app.command(name="m", hidden=True)
|
|
13
15
|
def mnemonic_command( # nosec B107:hardcoded_password_default
|
|
14
16
|
mnemonic: Annotated[str, typer.Option("--mnemonic", "-m", help="")] = "",
|
|
15
|
-
passphrase: Annotated[str, typer.Option("--passphrase", "-
|
|
17
|
+
passphrase: Annotated[str, typer.Option("--passphrase", "-p")] = "",
|
|
16
18
|
path: Annotated[str, typer.Option("--path", help="Derivation path. Examples: bip44, bip88, m/44'/0'/0'/0")] = "bip44",
|
|
19
|
+
hex_: Annotated[bool, typer.Option("--hex", help="Print private key in hex format instead of WIF")] = False,
|
|
17
20
|
words: int = typer.Option(12, "--words", "-w", help="Number of mnemonic words"),
|
|
18
21
|
limit: int = typer.Option(10, "--limit", "-l"),
|
|
19
22
|
testnet: bool = typer.Option(False, "--testnet", "-t", help="Testnet network"),
|
|
20
23
|
) -> None:
|
|
24
|
+
"""Generate keys based on a mnemonic"""
|
|
21
25
|
mnemonic_cmd.run(
|
|
22
26
|
mnemonic_cmd.Args(
|
|
23
27
|
mnemonic=mnemonic,
|
|
@@ -25,14 +29,22 @@ def mnemonic_command( # nosec B107:hardcoded_password_default
|
|
|
25
29
|
words=words,
|
|
26
30
|
limit=limit,
|
|
27
31
|
path=path,
|
|
32
|
+
hex=hex_,
|
|
28
33
|
testnet=testnet,
|
|
29
34
|
)
|
|
30
35
|
)
|
|
31
36
|
|
|
32
37
|
|
|
38
|
+
@app.command(name="address")
|
|
39
|
+
@app.command(name="a", hidden=True)
|
|
40
|
+
def address_command(address: str) -> None:
|
|
41
|
+
"""Get address info from Blockstream API"""
|
|
42
|
+
address_cmd.run(address)
|
|
43
|
+
|
|
44
|
+
|
|
33
45
|
def version_callback(value: bool) -> None:
|
|
34
46
|
if value:
|
|
35
|
-
print_plain(f"mm-
|
|
47
|
+
print_plain(f"mm-btc: v{cli_utils.get_version()}")
|
|
36
48
|
raise typer.Exit()
|
|
37
49
|
|
|
38
50
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
from mm_std import print_json
|
|
2
|
+
|
|
3
|
+
from mm_btc import blockstream
|
|
4
|
+
from mm_btc.wallet import is_testnet_address
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def run(address: str) -> None:
|
|
8
|
+
testnet = is_testnet_address(address)
|
|
9
|
+
res = blockstream.get_address(address, testnet=testnet)
|
|
10
|
+
print_json(res)
|
mm_btc/cli/cmd/mnemonic_cmd.py
CHANGED
|
@@ -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:
|
mm_btc/wallet.py
CHANGED
|
@@ -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
|
|
@@ -59,3 +60,7 @@ def mnemonic_words_to_strenght(words: int) -> int:
|
|
|
59
60
|
return 256
|
|
60
61
|
|
|
61
62
|
raise ValueError("Invalid words")
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def is_testnet_address(address: str) -> bool:
|
|
66
|
+
return address.startswith(("m", "n", "tb1"))
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
mm_btc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
mm_btc/blockstream.py,sha256=HllRQBO1Ezl0ArVH8b-CPRi0f5zdRNXJT_K3oCpAtgg,2159
|
|
3
|
+
mm_btc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
mm_btc/wallet.py,sha256=0ejOIl5gbm1oMO4WY3AsQRiF3PCrB4WC2LknaYPmMfY,1838
|
|
5
|
+
mm_btc/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
+
mm_btc/cli/cli.py,sha256=5UWUzlJvaV8qq2hZ_XptkaLPf81EbwlYFNcT-_xmQ_U,1825
|
|
7
|
+
mm_btc/cli/cli_utils.py,sha256=g2o5ySLu-Tw8dZm84ZAsx8862yHij4sDfz4z6uLS2hw,102
|
|
8
|
+
mm_btc/cli/cmd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
+
mm_btc/cli/cmd/address_cmd.py,sha256=vOjPgK9D91w2YWyCvbRO1_dWfuRDxpjNzOUpJYvYEVE,262
|
|
10
|
+
mm_btc/cli/cmd/mnemonic_cmd.py,sha256=zAAHr9j0SLJX5BXoiMTZj8pIzTPX26aJEOUi7IN40Ug,1192
|
|
11
|
+
mm_btc-0.0.5.dist-info/METADATA,sha256=28ask6JTpLCaDXE_gNWlatFVY88mgZbovq3CvdMvg84,858
|
|
12
|
+
mm_btc-0.0.5.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
|
13
|
+
mm_btc-0.0.5.dist-info/entry_points.txt,sha256=KphzLNE9eb9H1DO-L0gvBQaQT5ImedyVCN4a6svfiRg,46
|
|
14
|
+
mm_btc-0.0.5.dist-info/top_level.txt,sha256=0X0Ppv_QY0ulzgCB5HNezpaHfQ4wvih_B72hn5hHTUE,7
|
|
15
|
+
mm_btc-0.0.5.dist-info/RECORD,,
|
mm_btc-0.0.3.dist-info/RECORD
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
mm_btc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
mm_btc/blockstream.py,sha256=HllRQBO1Ezl0ArVH8b-CPRi0f5zdRNXJT_K3oCpAtgg,2159
|
|
3
|
-
mm_btc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
mm_btc/wallet.py,sha256=l1oHkAsJRxSHbIrV4waaqFUs3ojS_t3WB-P_pERXpNs,1707
|
|
5
|
-
mm_btc/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
6
|
-
mm_btc/cli/cli.py,sha256=i6idhoBGOKRIOl6H7XP-FmLa11zg_CkHd-NbVDwOsQw,1449
|
|
7
|
-
mm_btc/cli/cli_utils.py,sha256=g2o5ySLu-Tw8dZm84ZAsx8862yHij4sDfz4z6uLS2hw,102
|
|
8
|
-
mm_btc/cli/cmd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
9
|
-
mm_btc/cli/cmd/mnemonic_cmd.py,sha256=PbHVCaw9CzB16k5yrMsijDOvA5CAUb-KbDfVoL9oUBY,990
|
|
10
|
-
mm_btc-0.0.3.dist-info/METADATA,sha256=tUE-Jqu9MWfUu-fl7KuXLlG7YPNuv5GXzNs7NOyH3Os,858
|
|
11
|
-
mm_btc-0.0.3.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
|
12
|
-
mm_btc-0.0.3.dist-info/entry_points.txt,sha256=KphzLNE9eb9H1DO-L0gvBQaQT5ImedyVCN4a6svfiRg,46
|
|
13
|
-
mm_btc-0.0.3.dist-info/top_level.txt,sha256=0X0Ppv_QY0ulzgCB5HNezpaHfQ4wvih_B72hn5hHTUE,7
|
|
14
|
-
mm_btc-0.0.3.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|