Skip to content

Commit 1532df3

Browse files
Script release
1 parent 5825968 commit 1532df3

28 files changed

+1479
-0
lines changed
17.7 KB
Binary file not shown.

__pycache__/config.cpython-311.pyc

5.76 KB
Binary file not shown.

__pycache__/main.cpython-311.pyc

2.81 KB
Binary file not shown.

actions/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# -*- coding: utf-8 -*-
2+
"""Python Bitcoin Utils CLI - Actions"""

actions/about.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# -*- coding: utf-8 -*-
2+
"""About action - Features, installation, donations from README"""
3+
4+
from utils.ui import draw_table, show_tile, print_info
5+
6+
7+
def action_about():
8+
"""Display project info: features, installation, donations"""
9+
# Features
10+
headers = ["Feature", "Status"]
11+
rows = [
12+
("Key and address management", "Available"),
13+
("Transaction creation (SegWit, Taproot)", "Available"),
14+
("Full script support with all opcodes", "Available"),
15+
("Raw block parsing", "Available"),
16+
("Low-level Bitcoin protocol tools", "Available"),
17+
("Simple, readable, extensible codebase", "Available"),
18+
]
19+
draw_table(" FEATURES ", headers, rows, [40, 12])
20+
21+
# Installation
22+
headers = ["Platform", "Command"]
23+
rows = [
24+
("Clone", "git clone https://github.com/kirodaki/btc-python-utils"),
25+
("Install deps", "pip install -r requirements.txt"),
26+
("Setup", "python setup.py"),
27+
("Update", "run update.bat (Windows)"),
28+
]
29+
draw_table(" INSTALLATION ", headers, rows, [15, 55])
30+
31+
# Donations
32+
headers = ["Network", "Address"]
33+
rows = [
34+
("BTC", "bc1q8grhtxdw37npcdadm7xa848vquqgurj9ecvpex"),
35+
("ERC20", "0x2d19c72fb8b3a7cdc7fa4970b5c777966f547854"),
36+
]
37+
draw_table(" DONATIONS & SPONSORSHIP ", headers, rows, [10, 50])
38+
39+
show_tile(
40+
"If you find this project useful, consider supporting future development.\nThank you!",
41+
"Support the Project",
42+
"*"
43+
)
44+
print_info("License: MIT | Early development - API may evolve")

actions/install.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# -*- coding: utf-8 -*-
2+
"""Install dependencies action - pip install -r requirements.txt"""
3+
4+
import subprocess
5+
import sys
6+
from pathlib import Path
7+
8+
from utils.ui import print_success, print_error, print_info, show_install_result_table
9+
10+
11+
def action_install_dependencies():
12+
"""Run pip install -r requirements.txt"""
13+
print_info("Installing dependencies from requirements.txt...")
14+
15+
base_dir = Path(__file__).parent.parent
16+
req_file = base_dir / "requirements.txt"
17+
18+
if not req_file.exists():
19+
print_error("requirements.txt not found")
20+
return
21+
22+
packages = []
23+
with open(req_file, "r", encoding="utf-8") as f:
24+
for line in f:
25+
line = line.strip()
26+
if line and not line.startswith("#"):
27+
pkg = line.split(">=")[0].split("==")[0].strip()
28+
packages.append(pkg)
29+
30+
try:
31+
result = subprocess.run(
32+
[sys.executable, "-m", "pip", "install", "-r", str(req_file), "-q"],
33+
capture_output=True,
34+
text=True,
35+
timeout=120,
36+
cwd=str(base_dir),
37+
)
38+
success = result.returncode == 0
39+
show_install_result_table(packages, success)
40+
if success:
41+
print_success("All dependencies installed successfully")
42+
else:
43+
err = result.stderr[:200] if result.stderr else "Unknown error"
44+
print_error(f"Install failed: {err}")
45+
except subprocess.TimeoutExpired:
46+
print_error("Install timed out (120s)")
47+
except Exception as e:
48+
print_error(f"Install error: {e}")

actions/settings.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# -*- coding: utf-8 -*-
2+
"""Settings action - Development environment setup from README"""
3+
4+
from pathlib import Path
5+
6+
from utils.ui import draw_table, show_tile, print_info
7+
8+
9+
def action_settings():
10+
"""Display development environment setup instructions"""
11+
headers = ["Step", "Command", "Description"]
12+
rows = [
13+
("1", "git clone https://github.com/kirodaki/btc-python-utils", "Clone the repository"),
14+
("2", "cd btc-python-utils", "Enter project directory"),
15+
("3", "virtualenv -p python3 venv", "Create virtual environment"),
16+
("4", ". venv/bin/activate (Linux) or venv\\Scripts\\activate (Win)", "Activate venv"),
17+
("5", "pip install -e \".[dev]\"", "Install package in dev mode"),
18+
("6", "pre-commit install", "Setup pre-commit hooks"),
19+
]
20+
draw_table(" DEVELOPMENT ENVIRONMENT SETUP ", headers, rows, [6, 55, 30])
21+
22+
base_dir = Path(__file__).parent.parent
23+
show_tile(
24+
f"Project path: {base_dir}\n\n"
25+
"Recommended: Python 3.10+\n"
26+
"Use virtualenv for isolation.",
27+
"Paths & Tips",
28+
"#"
29+
)
30+
print_info("See README for full documentation")

actions/setup.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# -*- coding: utf-8 -*-
2+
"""Setup action - run python setup.py"""
3+
4+
import subprocess
5+
import sys
6+
from pathlib import Path
7+
8+
from utils.ui import print_success, print_error, print_info
9+
10+
11+
def action_run_setup():
12+
"""Run python setup.py to configure the package"""
13+
print_info("Running setup.py...")
14+
15+
base_dir = Path(__file__).parent.parent
16+
setup_py = base_dir / "setup.py"
17+
18+
if not setup_py.exists():
19+
print_error("setup.py not found in project directory")
20+
print_info("For btc-python-utils: clone repo and run setup.py from there")
21+
return
22+
23+
try:
24+
result = subprocess.run(
25+
[sys.executable, str(setup_py)],
26+
cwd=str(base_dir),
27+
capture_output=True,
28+
text=True,
29+
timeout=60,
30+
)
31+
if result.returncode == 0:
32+
print_success("Setup completed successfully")
33+
if result.stdout:
34+
print_info(result.stdout[:500])
35+
else:
36+
print_error(f"Setup failed: {result.stderr[:200] if result.stderr else 'Unknown error'}")
37+
except subprocess.TimeoutExpired:
38+
print_error("Setup timed out")
39+
except Exception as e:
40+
print_error(f"Setup error: {e}")

actions/tools.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# -*- coding: utf-8 -*-
2+
"""Bitcoin tools actions - Key/Address, Transaction, Script info"""
3+
4+
from utils.ui import draw_table, show_tile, print_info
5+
6+
7+
def action_key_address_info():
8+
"""Display Key & Address management info"""
9+
headers = ["Capability", "Description"]
10+
rows = [
11+
("Private/Public keys", "ECDSA secp256k1 key generation and handling"),
12+
("Legacy addresses", "P2PKH (1...) format"),
13+
("SegWit addresses", "P2WPKH (bc1q...) Bech32 format"),
14+
("Taproot addresses", "P2TR (bc1p...) Schnorr signatures"),
15+
]
16+
draw_table(" KEY & ADDRESS TOOLS ", headers, rows, [25, 45])
17+
18+
show_tile(
19+
"To use these tools, clone and install btc-python-utils:\n"
20+
" git clone https://github.com/kirodaki/btc-python-utils\n"
21+
" pip install -r requirements.txt\n"
22+
" python setup.py",
23+
"Setup Required"
24+
)
25+
print_info("Library provides low-level key and address management APIs")
26+
27+
28+
def action_transaction_info():
29+
"""Display Transaction tools info"""
30+
headers = ["Type", "Support"]
31+
rows = [
32+
("Legacy transactions", "P2PKH inputs/outputs"),
33+
("SegWit (BIP141)", "P2WPKH, reduced fees"),
34+
("Taproot (BIP340/341)", "Schnorr, MAST, improved privacy"),
35+
]
36+
draw_table(" TRANSACTION TOOLS ", headers, rows, [25, 35])
37+
38+
show_tile(
39+
"Create and sign Bitcoin transactions.\n"
40+
"Supports all modern Bitcoin address types.",
41+
"Transaction Creation"
42+
)
43+
print_info("See btc-python-utils docs for transaction examples")
44+
45+
46+
def action_script_block_info():
47+
"""Display Script & Block parsing info"""
48+
headers = ["Component", "Description"]
49+
rows = [
50+
("Script opcodes", "Full support for all Bitcoin script opcodes"),
51+
("Script parsing", "Parse and build complex scripts"),
52+
("Block parsing", "Raw block structure parsing"),
53+
]
54+
draw_table(" SCRIPT & BLOCK TOOLS ", headers, rows, [20, 45])
55+
56+
show_tile(
57+
"For script and block parsing, use the btc-python-utils library.\n"
58+
"Designed for developers who want to understand Bitcoin internals.",
59+
"Low-Level Tools"
60+
)
61+
print_info("Library is in early development - API may evolve")

actions/update.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# -*- coding: utf-8 -*-
2+
"""Update package action - run update.bat"""
3+
4+
import subprocess
5+
import sys
6+
from pathlib import Path
7+
8+
from utils.ui import print_success, print_error, print_info
9+
10+
11+
def action_update():
12+
"""Run update.bat to install latest version"""
13+
print_info("Running update script...")
14+
15+
base_dir = Path(__file__).parent.parent
16+
update_bat = base_dir / "update.bat"
17+
18+
if not update_bat.exists():
19+
print_error("update.bat not found in project directory")
20+
print_info("Create update.bat or run: pip install -U btc-python-utils")
21+
return
22+
23+
try:
24+
if sys.platform == "win32":
25+
result = subprocess.run(
26+
["cmd", "/c", str(update_bat)],
27+
cwd=str(base_dir),
28+
shell=False,
29+
timeout=180,
30+
)
31+
else:
32+
result = subprocess.run(
33+
["bash", str(update_bat)] if (base_dir / "update.sh").exists() else ["python", "-m", "pip", "install", "-U", "btc-python-utils"],
34+
cwd=str(base_dir),
35+
timeout=180,
36+
)
37+
if result.returncode == 0:
38+
print_success("Update completed successfully")
39+
else:
40+
print_error(f"Update failed with code {result.returncode}")
41+
except subprocess.TimeoutExpired:
42+
print_error("Update timed out")
43+
except Exception as e:
44+
print_error(f"Update error: {e}")

0 commit comments

Comments
 (0)