mm-btc 0.1.3__py3-none-any.whl → 0.2.0__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-0.1.3.dist-info → mm_btc-0.2.0.dist-info}/METADATA +1 -2
- mm_btc-0.2.0.dist-info/RECORD +8 -0
- mm_btc/cli/__init__.py +0 -0
- mm_btc/cli/cli.py +0 -79
- mm_btc/cli/cli_utils.py +0 -5
- mm_btc/cli/cmd/__init__.py +0 -0
- mm_btc/cli/cmd/address_cmd.py +0 -10
- mm_btc/cli/cmd/create_tx_cmd.py +0 -27
- mm_btc/cli/cmd/decode_tx_cmd.py +0 -8
- mm_btc/cli/cmd/mnemonic_cmd.py +0 -49
- mm_btc/cli/cmd/utxo_cmd.py +0 -11
- mm_btc-0.1.3.dist-info/RECORD +0 -18
- mm_btc-0.1.3.dist-info/entry_points.txt +0 -2
- {mm_btc-0.1.3.dist-info → mm_btc-0.2.0.dist-info}/WHEEL +0 -0
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: mm-btc
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Requires-Python: >=3.12
|
|
5
5
|
Requires-Dist: bitcoinlib~=0.7.1
|
|
6
6
|
Requires-Dist: bit~=0.8.0
|
|
7
7
|
Requires-Dist: hdwallet~=3.2.0
|
|
8
8
|
Requires-Dist: mm-std~=0.1.9
|
|
9
9
|
Requires-Dist: mnemonic>=0.21
|
|
10
|
-
Requires-Dist: typer>=0.15.1
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
mm_btc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
mm_btc/blockstream.py,sha256=U2_pc6RYAkFcCvH_WrxjIm13VNavyY3WgK8ePowV-Ic,3620
|
|
3
|
+
mm_btc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
mm_btc/tx.py,sha256=7KTMNuL1n8rRj_245BV1bH9M2_PctNvlvPsLEsRTYx4,245
|
|
5
|
+
mm_btc/wallet.py,sha256=E9XKZMQx48JiGRDG8ij7cbilNPVmcpmS6jAGBzXfV9U,2475
|
|
6
|
+
mm_btc-0.2.0.dist-info/METADATA,sha256=drZ2vHDl89rFCn6SJDDaELptn97EiCTGnXIwD92rWXg,223
|
|
7
|
+
mm_btc-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
8
|
+
mm_btc-0.2.0.dist-info/RECORD,,
|
mm_btc/cli/__init__.py
DELETED
|
File without changes
|
mm_btc/cli/cli.py
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
from typing import Annotated
|
|
3
|
-
|
|
4
|
-
import typer
|
|
5
|
-
import typer.core
|
|
6
|
-
from mm_std import print_plain
|
|
7
|
-
|
|
8
|
-
from mm_btc.cli import cli_utils
|
|
9
|
-
from mm_btc.cli.cmd import address_cmd, create_tx_cmd, decode_tx_cmd, mnemonic_cmd, utxo_cmd
|
|
10
|
-
from mm_btc.wallet import AddressType
|
|
11
|
-
|
|
12
|
-
app = typer.Typer(no_args_is_help=True, pretty_exceptions_enable=False, add_completion=False)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
@app.command("mnemonic")
|
|
16
|
-
@app.command(name="m", hidden=True)
|
|
17
|
-
def mnemonic_command( # nosec B107:hardcoded_password_default
|
|
18
|
-
mnemonic: Annotated[str, typer.Option("--mnemonic", "-m", help="")] = "",
|
|
19
|
-
passphrase: Annotated[str, typer.Option("--passphrase", "-p")] = "",
|
|
20
|
-
path: Annotated[str, typer.Option("--path", help="Derivation path. Examples: bip44, bip88, m/44'/0'/0'/0")] = "bip44",
|
|
21
|
-
address_type: Annotated[AddressType, typer.Option("--address-type", "-a", help="Bitcoin address type")] = AddressType.P2WPKH,
|
|
22
|
-
hex_: Annotated[bool, typer.Option("--hex", help="Print private key in hex format instead of WIF")] = False,
|
|
23
|
-
words: int = typer.Option(12, "--words", "-w", help="Number of mnemonic words"),
|
|
24
|
-
limit: int = typer.Option(10, "--limit", "-l"),
|
|
25
|
-
testnet: bool = typer.Option(False, "--testnet", "-t", help="Testnet network"),
|
|
26
|
-
) -> None:
|
|
27
|
-
"""Generate keys based on a mnemonic"""
|
|
28
|
-
mnemonic_cmd.run(
|
|
29
|
-
mnemonic_cmd.Args(
|
|
30
|
-
mnemonic=mnemonic,
|
|
31
|
-
passphrase=passphrase,
|
|
32
|
-
words=words,
|
|
33
|
-
limit=limit,
|
|
34
|
-
path=path,
|
|
35
|
-
address_type=address_type,
|
|
36
|
-
hex=hex_,
|
|
37
|
-
testnet=testnet,
|
|
38
|
-
)
|
|
39
|
-
)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
@app.command(name="address")
|
|
43
|
-
@app.command(name="a", hidden=True)
|
|
44
|
-
def address_command(address: str) -> None:
|
|
45
|
-
"""Get address info from Blockstream API"""
|
|
46
|
-
address_cmd.run(address)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
@app.command("create-tx")
|
|
50
|
-
def create_tx_command(config_path: Annotated[Path, typer.Argument(exists=True)]) -> None:
|
|
51
|
-
"""Create a transaction"""
|
|
52
|
-
create_tx_cmd.run(config_path)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
@app.command("decode-tx")
|
|
56
|
-
def decode_tx_command(tx_hex: str, testnet: Annotated[bool, typer.Option("--testnet", "-t")] = False) -> None:
|
|
57
|
-
"""Decode a transaction"""
|
|
58
|
-
decode_tx_cmd.run(tx_hex, testnet)
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
@app.command("utxo")
|
|
62
|
-
def utxo_command(address: str) -> None:
|
|
63
|
-
"""Get UTXOs from Blockstream API"""
|
|
64
|
-
utxo_cmd.run(address)
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
def version_callback(value: bool) -> None:
|
|
68
|
-
if value:
|
|
69
|
-
print_plain(f"mm-btc: v{cli_utils.get_version()}")
|
|
70
|
-
raise typer.Exit()
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
@app.callback()
|
|
74
|
-
def main(_version: bool = typer.Option(None, "--version", callback=version_callback, is_eager=True)) -> None:
|
|
75
|
-
pass
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if __name__ == "__main_":
|
|
79
|
-
app()
|
mm_btc/cli/cli_utils.py
DELETED
mm_btc/cli/cmd/__init__.py
DELETED
|
File without changes
|
mm_btc/cli/cmd/address_cmd.py
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
from mm_std import print_json
|
|
2
|
-
|
|
3
|
-
from mm_btc.blockstream import BlockstreamClient
|
|
4
|
-
from mm_btc.wallet import is_testnet_address
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def run(address: str) -> None:
|
|
8
|
-
client = BlockstreamClient(testnet=is_testnet_address(address))
|
|
9
|
-
res = client.get_address(address)
|
|
10
|
-
print_json(res)
|
mm_btc/cli/cmd/create_tx_cmd.py
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
from pathlib import Path
|
|
2
|
-
|
|
3
|
-
from bit import PrivateKey, PrivateKeyTestnet
|
|
4
|
-
from mm_std import BaseConfig, print_console
|
|
5
|
-
|
|
6
|
-
from mm_btc.wallet import is_testnet_address
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class Config(BaseConfig):
|
|
10
|
-
class Output(BaseConfig):
|
|
11
|
-
address: str
|
|
12
|
-
amount: int
|
|
13
|
-
|
|
14
|
-
from_address: str
|
|
15
|
-
private: str
|
|
16
|
-
outputs: list[Output]
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
def run(config_path: Path) -> None:
|
|
20
|
-
config = Config.read_config(config_path)
|
|
21
|
-
testnet = is_testnet_address(config.from_address)
|
|
22
|
-
key = PrivateKeyTestnet(config.private) if testnet else PrivateKey(config.private)
|
|
23
|
-
|
|
24
|
-
outputs = [(o.address, o.amount, "satoshi") for o in config.outputs]
|
|
25
|
-
|
|
26
|
-
tx = key.create_transaction(outputs)
|
|
27
|
-
print_console(tx)
|
mm_btc/cli/cmd/decode_tx_cmd.py
DELETED
mm_btc/cli/cmd/mnemonic_cmd.py
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
from dataclasses import dataclass
|
|
2
|
-
from enum import Enum
|
|
3
|
-
|
|
4
|
-
from mm_std import print_plain
|
|
5
|
-
|
|
6
|
-
from mm_btc.wallet import AddressType, derive_accounts, generate_mnemonic
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
class PrivateType(str, Enum):
|
|
10
|
-
hex = "hex"
|
|
11
|
-
wif = "wif"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
@dataclass
|
|
15
|
-
class Args:
|
|
16
|
-
mnemonic: str
|
|
17
|
-
passphrase: str
|
|
18
|
-
words: int
|
|
19
|
-
limit: int
|
|
20
|
-
hex: bool # Print private key in hex format instead of WIF
|
|
21
|
-
address_type: AddressType
|
|
22
|
-
path: str
|
|
23
|
-
testnet: bool
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def run(args: Args) -> None:
|
|
27
|
-
mnemonic = args.mnemonic or generate_mnemonic()
|
|
28
|
-
passphrase = args.passphrase
|
|
29
|
-
path = get_derivation_path_prefix(args.path, args.testnet)
|
|
30
|
-
accounts = derive_accounts(mnemonic, passphrase, path, args.address_type, args.limit)
|
|
31
|
-
|
|
32
|
-
print_plain(f"{mnemonic}")
|
|
33
|
-
if passphrase:
|
|
34
|
-
print_plain(f"{passphrase}")
|
|
35
|
-
for acc in accounts:
|
|
36
|
-
private = acc.private if args.hex else acc.wif
|
|
37
|
-
print_plain(f"{acc.path} {acc.address} {private}")
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
def get_derivation_path_prefix(path: str, testnet: bool) -> str:
|
|
41
|
-
if path.startswith("m/"):
|
|
42
|
-
return path
|
|
43
|
-
coin = "1" if testnet else "0"
|
|
44
|
-
if path == "bip44":
|
|
45
|
-
return f"m/44'/{coin}'/0'/0"
|
|
46
|
-
if path == "bip84":
|
|
47
|
-
return f"m/84'/{coin}'/0'/0"
|
|
48
|
-
|
|
49
|
-
raise ValueError("Invalid path")
|
mm_btc/cli/cmd/utxo_cmd.py
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
from mm_std import print_json
|
|
2
|
-
|
|
3
|
-
from mm_btc.blockstream import BlockstreamClient
|
|
4
|
-
from mm_btc.wallet import is_testnet_address
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def run(address: str) -> None:
|
|
8
|
-
client = BlockstreamClient(testnet=is_testnet_address(address))
|
|
9
|
-
res = client.get_utxo(address)
|
|
10
|
-
|
|
11
|
-
print_json(res.ok_or_err())
|
mm_btc-0.1.3.dist-info/RECORD
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
mm_btc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
mm_btc/blockstream.py,sha256=U2_pc6RYAkFcCvH_WrxjIm13VNavyY3WgK8ePowV-Ic,3620
|
|
3
|
-
mm_btc/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
-
mm_btc/tx.py,sha256=7KTMNuL1n8rRj_245BV1bH9M2_PctNvlvPsLEsRTYx4,245
|
|
5
|
-
mm_btc/wallet.py,sha256=E9XKZMQx48JiGRDG8ij7cbilNPVmcpmS6jAGBzXfV9U,2475
|
|
6
|
-
mm_btc/cli/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
mm_btc/cli/cli.py,sha256=uD49Nek6ZuBLnNOjGghSHv5eNPS2E6hTyCyjvvMOmGU,2620
|
|
8
|
-
mm_btc/cli/cli_utils.py,sha256=g2o5ySLu-Tw8dZm84ZAsx8862yHij4sDfz4z6uLS2hw,102
|
|
9
|
-
mm_btc/cli/cmd/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
|
-
mm_btc/cli/cmd/address_cmd.py,sha256=fipX9FiQ2EgCEq8nVN6ELnDMoR5KTIX7bpAaRK3t_yg,284
|
|
11
|
-
mm_btc/cli/cmd/create_tx_cmd.py,sha256=dIuQBTOqTSefC6aMbrBN6Pq0EwV2G2ESM1tLU4WyFoU,690
|
|
12
|
-
mm_btc/cli/cmd/decode_tx_cmd.py,sha256=0jGlUjnA1X2Q2aYwSBeAjqVNZIBsW5X2lEwIpSfWJsU,175
|
|
13
|
-
mm_btc/cli/cmd/mnemonic_cmd.py,sha256=CY6tPsqOTNfM-4WhKDhqitCi2OeqSIUMEUTFIRGHwIg,1254
|
|
14
|
-
mm_btc/cli/cmd/utxo_cmd.py,sha256=mp-lVLURpXFqO3IeBIEwnHusEvT5tFjUKxnRYC-rFqQ,294
|
|
15
|
-
mm_btc-0.1.3.dist-info/METADATA,sha256=XP2L_wEpJRZGBh2WG_hSaY6HMhkDPrqEIXf6R-z1pJE,252
|
|
16
|
-
mm_btc-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
17
|
-
mm_btc-0.1.3.dist-info/entry_points.txt,sha256=KphzLNE9eb9H1DO-L0gvBQaQT5ImedyVCN4a6svfiRg,46
|
|
18
|
-
mm_btc-0.1.3.dist-info/RECORD,,
|
|
File without changes
|