mm-btc 0.0.2__py3-none-any.whl → 0.0.3__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/__init__.py ADDED
File without changes
mm_btc/cli/cli.py ADDED
@@ -0,0 +1,45 @@
1
+ from typing import Annotated
2
+
3
+ import typer
4
+ from mm_std import print_plain
5
+
6
+ from mm_btc.cli import cli_utils
7
+ from mm_btc.cli.cmd import mnemonic_cmd
8
+
9
+ app = typer.Typer(no_args_is_help=True, pretty_exceptions_enable=False, add_completion=False)
10
+
11
+
12
+ @app.command(name="mnemonic", help="Generate keys based on a mnemonic")
13
+ def mnemonic_command( # nosec B107:hardcoded_password_default
14
+ mnemonic: Annotated[str, typer.Option("--mnemonic", "-m", help="")] = "",
15
+ passphrase: Annotated[str, typer.Option("--passphrase", "-pass")] = "",
16
+ path: Annotated[str, typer.Option("--path", help="Derivation path. Examples: bip44, bip88, m/44'/0'/0'/0")] = "bip44",
17
+ words: int = typer.Option(12, "--words", "-w", help="Number of mnemonic words"),
18
+ limit: int = typer.Option(10, "--limit", "-l"),
19
+ testnet: bool = typer.Option(False, "--testnet", "-t", help="Testnet network"),
20
+ ) -> None:
21
+ mnemonic_cmd.run(
22
+ mnemonic_cmd.Args(
23
+ mnemonic=mnemonic,
24
+ passphrase=passphrase,
25
+ words=words,
26
+ limit=limit,
27
+ path=path,
28
+ testnet=testnet,
29
+ )
30
+ )
31
+
32
+
33
+ def version_callback(value: bool) -> None:
34
+ if value:
35
+ print_plain(f"mm-eth version: {cli_utils.get_version()}")
36
+ raise typer.Exit()
37
+
38
+
39
+ @app.callback()
40
+ def main(_version: bool = typer.Option(None, "--version", callback=version_callback, is_eager=True)) -> None:
41
+ pass
42
+
43
+
44
+ if __name__ == "__main_":
45
+ app()
@@ -0,0 +1,5 @@
1
+ import importlib.metadata
2
+
3
+
4
+ def get_version() -> str:
5
+ return importlib.metadata.version("mm-btc")
File without changes
@@ -0,0 +1,39 @@
1
+ from dataclasses import dataclass
2
+
3
+ from mm_std import print_plain
4
+
5
+ from mm_btc.wallet import derive_accounts, generate_mnemonic
6
+
7
+
8
+ @dataclass
9
+ class Args:
10
+ mnemonic: str
11
+ passphrase: str
12
+ words: int
13
+ limit: int
14
+ path: str
15
+ testnet: bool
16
+
17
+
18
+ def run(args: Args) -> None:
19
+ mnemonic = args.mnemonic or generate_mnemonic()
20
+ passphrase = args.passphrase
21
+ path = get_derivation_path_prefix(args.path, args.testnet)
22
+ accounts = derive_accounts(mnemonic, passphrase, path, args.limit)
23
+
24
+ print_plain(f"mnemonic: {mnemonic}")
25
+ print_plain(f"passphrase: {passphrase}")
26
+ for acc in accounts:
27
+ print_plain(f"{acc.path} {acc.address} {acc.private}")
28
+
29
+
30
+ def get_derivation_path_prefix(path: str, testnet: bool) -> str:
31
+ if path.startswith("m/"):
32
+ return path
33
+ coin = "1" if testnet else "0"
34
+ if path == "bip44":
35
+ return f"m/44'/{coin}'/0'/0"
36
+ if path == "bip84":
37
+ return f"m/84'/{coin}'/0'/0"
38
+
39
+ raise ValueError("Invalid path")
mm_btc/wallet.py CHANGED
@@ -17,7 +17,8 @@ class Account:
17
17
  path: str
18
18
 
19
19
 
20
- def generate_mnemonic(language: str = "english", strength: int = 128) -> str:
20
+ def generate_mnemonic(language: str = "english", words: int = 12) -> str:
21
+ strength = mnemonic_words_to_strenght(words)
21
22
  return new_mnemonic(language=language, strength=strength) # type: ignore[no-any-return]
22
23
 
23
24
 
@@ -43,3 +44,18 @@ def derive_accounts(mnemonic: str, passphrase: str, path: str, limit: int) -> li
43
44
  w.clean_derivation()
44
45
 
45
46
  return accounts
47
+
48
+
49
+ def mnemonic_words_to_strenght(words: int) -> int:
50
+ if words == 12:
51
+ return 128
52
+ if words == 15:
53
+ return 160
54
+ if words == 18:
55
+ return 192
56
+ if words == 21:
57
+ return 224
58
+ if words == 24:
59
+ return 256
60
+
61
+ raise ValueError("Invalid words")
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mm-btc
3
- Version: 0.0.2
3
+ Version: 0.0.3
4
4
  Requires-Python: >=3.12
5
5
  Requires-Dist: mm-std ~=0.1.0
6
6
  Requires-Dist: hdwallet ~=2.2.1
7
+ Requires-Dist: typer ~=0.12.3
7
8
  Provides-Extra: dev
8
9
  Requires-Dist: build ~=1.2.1 ; extra == 'dev'
9
10
  Requires-Dist: twine ~=5.1.0 ; extra == 'dev'
@@ -0,0 +1,14 @@
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,,
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ mm-btc = mm_btc.cli.cli:app
@@ -1,8 +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=XI2Ju5dELc_2wqyag6M-k5s3EZODN9qJKm3yjurJORE,1375
5
- mm_btc-0.0.2.dist-info/METADATA,sha256=LdFWJbmxkPxaaxnInxW9KlEDh_QMji8xMbf4-n8YxtM,828
6
- mm_btc-0.0.2.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
7
- mm_btc-0.0.2.dist-info/top_level.txt,sha256=0X0Ppv_QY0ulzgCB5HNezpaHfQ4wvih_B72hn5hHTUE,7
8
- mm_btc-0.0.2.dist-info/RECORD,,
File without changes