Skip to main content

Python bindings and CLI for hal-simplicity via PyO3

Project description

hal-simplicity -- a Simplicity-enabled extension of hal -- python interface

This is a fork of Blockstreams hal-simplicity which in turn is a fork of Steven Roose's hal-elements which in turn is an extension of his Bitcoin tool hal.

This project is a research study to create a convinient python interface to hal-simplicity

Usage (Python)

pyhalsimplicity provides Python bindings for the HAL-Simplicity library. You can invoke its CLI commands directly from Python using the run_cli_command function.

Installation

pip install pyhalsimplicity

Basic Example

import sys
import pyhalsimplicity

def main():
    # Setup logging (optional)
    pyhalsimplicity.setup_logger("info")
    
    # Prepare the CLI command as a space-separated string
    cli_args = sys.argv[1:]
    cmdline = " ".join(cli_args)
    
    # Execute the command
    result = pyhalsimplicity.run_cli_command(cmdline)
    
    print(result)

    # Uncomment to see the internal logger buffer
    # print(pyhalsimplicity.get_logs(), flush=True)

if __name__ == "__main__":
    main()

Example Usage

python example.py tx create ...
python example.py keypair generate

Features

  • Run all built-in HAL-Simplicity CLI commands from Python.
  • Capture logs via setup_logger and get_logs.
  • Supports scripting HAL-Simplicity commands in Python workflows.

GitHub Repository

The source code and development repository is available at: https://github.com/coremoon/hal-simplicity

Please note that the sources have been forked from the original project https://github.com/blockstreamresearch/hal-simplicity

Installation (from GitHub source)

⚠️ This section is only relevant if you are building from the GitHub repository. If you installed pyhalsimplicity from PyPI, you can skip this.

To build the Python wheel and CLI binaries directly from source, follow these steps:

  1. Build the complete Rust project The resulting binary (hal-simplicity or hal-simplicity.exe on Windows) will be in target/debug or target/release.
cargo build
  1. Create and activate a Python virtual environment
python -m venv .venv
# Activate:
. .venv/bin/activate      # Linux / macOS
. .venv/Scripts/activate  # Windows (Git Bash)
  1. Install Python dependencies using Poetry
poetry update
  1. Build the Python wheel
  • Debug wheel (located in target/wheels):
maturin build --manifest-path pyhalsimplicity/Cargo.toml
  • Release wheel (optimized build):
maturin build --manifest-path pyhalsimplicity/Cargo.toml --release
  1. Quick install of the newly built wheel
poetry run pip install --force-reinstall "$(ls -t target/wheels/pyhalsimplicity*.whl | head -n 1)"
  1. Optional: run everything in one step via poe
poetry run poe build-wheel
  1. Optional: decode a simplicity binary via poetry run python in the terminal try running
 poetry run python -m python.main simplicity info e4fba0509b4df120e1d320451f14172c46476646daf8d0d6da80e84c986cc5e073f80ed4dcf0210284187248126ac8e671544245742660022ae160c5e14b09ec0c2a17584bf5c548c85961c02b6efc010c03109ad2420c3f00140b16ab91cd75dcbc1e84ea7a320719cbfc6dc95e5194f9eca996d55a7b2d768c511e2a310e1806240a1241b70a35627302ef7da851f75a1f471748121a2b6978930a58ccaee2309401bd1b6e9fcbb0018601881a80e12071190284906e2a37159c2a162cdba0e67e0aad66c82658ec0c7f2a5a2cc38c3f61a892acd0da3a133ff9ead668873dc60c0310b5b0730445fea038d226980c2e6f7e4be9e895848d1fd97f2100db43004cb4eaddefc50601885c078170e6f13a1848e019ef88de2e7a3c1561d1828b3be0f290def9feebf54da94249472c0c0312050920fc8238dc861438a059b630e6ef256702d23cf92f32979f4fcd9ff3909cf7b32538aafb0e3a23ec40079b1d130c03103785c207e4c8201c5a072580e4e0

which should give

{
  "jets": "core",
  "commit_base64": "5PugUJtN8SDh0yBFHxQXLEZHZkba+NDW2oDoTJhsxeBz+A7U3PAhAoQYckgSasjmcVRCRXQmYAIq4WDF4UsJ7AwqF1hL9cVIyFlhwCtu/AEMAxCa0kIMPwAUCxarkc113LwehOp6MgcZy/xtyV5RlPnsqZbVWnstdoxRHioxDhgGJAoSQbcKNWJzAu99qFH3Wh9HF0gSGitpeJMKWMyu4jCUAb0bbp/LsAGGAYgagOEgcRkChJBuKjcVnCoWLNug5n4KrWbIJljsDH8qWizDjD9hqJKs0No6Ez/56tZohz3GDAMQtbBzBEX+oDjSJpgMLm9+S+nolYSNH9l/IQDbQwBMtOrd78UGAYhcB4Fw5vE6GEjgGe+I3i56PBVh0YKLO+DykN75/uv1TalCSUcsDAMSBQkg/II43IYUOKBZtjDm7yVnAtI8+S8yl59PzZ/zkJz3syU4qvsOOiPsQAebHRMMAxA3hcIH5MggHFoHJYDk4A==",
  "commit_decode": "(witness  & iden); (((unit; const 0xbe241c3a6408a3e282e588c8ecc8db5f1a1adb501d09930d98bc0e7f01da9b9e ) & iden); (((IOH; ((((false & unit); assertl drop jet_sha_256_ctx_8_init ) & iden); ((((false & (OH & IH)); assertl drop jet_sha_256_ctx_8_add_32 ) & iden); ((false & OH); assertl drop jet_sha_256_ctx_8_finalize )))) & iden); ((((false & ((false & (OH & IOH)); assertl drop jet_eq_256 )); assertl drop jet_verify ) & ((((false & unit); assertl drop jet_sig_all_hash ) & iden); ((false & ((IIIOH & OH) & witness )); assertl drop jet_bip_0340_verify ))); IH)))",
  "type_arrow": "1 → 1",
  "cmr": "7fd424f70498ef2fb6dd05ffbb7368dc796e6c47f24404e0b1ff138cfce89a7a",
  "liquid_address_unconf": "ex1pyuvwaqedernfdc7c6qf7r67en3szas6s0sdegzq3jxduhj4mhles29dz23",
  "liquid_testnet_address_unconf": "tex1pyuvwaqedernfdc7c6qf7r67en3szas6s0sdegzq3jxduhj4mhlestul9m7",
  "is_redeem": false
}

Once installed, you can use pyhalsimplicity in Python or run the hal-simplicity CLI directly.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pyhalsimplicity-0.1.0-cp312-cp312-win_amd64.whl (5.4 MB view details)

Uploaded CPython 3.12Windows x86-64

pyhalsimplicity-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.34+ x86-64

pyhalsimplicity-0.1.0-cp312-cp312-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

pyhalsimplicity-0.1.0-cp311-cp311-win_amd64.whl (5.4 MB view details)

Uploaded CPython 3.11Windows x86-64

pyhalsimplicity-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.34+ x86-64

pyhalsimplicity-0.1.0-cp311-cp311-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

pyhalsimplicity-0.1.0-cp310-cp310-win_amd64.whl (5.4 MB view details)

Uploaded CPython 3.10Windows x86-64

pyhalsimplicity-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.34+ x86-64

pyhalsimplicity-0.1.0-cp310-cp310-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

pyhalsimplicity-0.1.0-cp39-cp39-win_amd64.whl (5.4 MB view details)

Uploaded CPython 3.9Windows x86-64

pyhalsimplicity-0.1.0-cp39-cp39-manylinux_2_34_x86_64.whl (2.4 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.34+ x86-64

pyhalsimplicity-0.1.0-cp39-cp39-macosx_11_0_arm64.whl (2.2 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file pyhalsimplicity-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for pyhalsimplicity-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ac893f520578c0f2fc1aeebe5c3fc4b534dc3d6d6c0c90da679b369013c3a929
MD5 1f86f061e169850a1751f07467dac666
BLAKE2b-256 f8a88f31b6d330336ee26665c6562fd8dba38c36ee6b71658430a49ef636ce4e

See more details on using hashes here.

File details

Details for the file pyhalsimplicity-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyhalsimplicity-0.1.0-cp312-cp312-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 796901eb0075b34664e5f490f8f6f3a5d2115148910b63359be4b94ff9b30912
MD5 997b3854748d0db3f00c8719b3af4464
BLAKE2b-256 1bd69974397ecc8f9776093b1c98e597cf14e96ed2c0b694945422967d89b35a

See more details on using hashes here.

File details

Details for the file pyhalsimplicity-0.1.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyhalsimplicity-0.1.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 b8a17c919412ed453cbe73732a9dc5b8560e2f9c2ee989501716096813112aea
MD5 ef85dbc810ca9fb1cb15acdffddad6e2
BLAKE2b-256 3ac65708e8086e25b828b622cb9befca74b7ea97747465c1bab84dc19776a193

See more details on using hashes here.

File details

Details for the file pyhalsimplicity-0.1.0-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for pyhalsimplicity-0.1.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 c980e6376f4fa7cb0d7330999e59b8fb3abccde588b83aca10a6cae0ee2e8744
MD5 aec7b3391b5a6ece23931e3ce2783ac2
BLAKE2b-256 5fef9e9ff91d186ecbd7d9701d14c62bbb8fb23412bf6a34b2fae4bb2086cda2

See more details on using hashes here.

File details

Details for the file pyhalsimplicity-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyhalsimplicity-0.1.0-cp311-cp311-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d0840f458cad55a2a008c7fe7fe427c50ec8eaa437497cc8a1f5658014e5c69c
MD5 b9ce1834b6e3175e9f65ec9f4f60ff28
BLAKE2b-256 fea3819ba75bc432f5532ef9db0bd4f9bb88e4866e3a2cad439c53499694c809

See more details on using hashes here.

File details

Details for the file pyhalsimplicity-0.1.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyhalsimplicity-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ad480bf71986704caa64a876f598fd29660abf85501476c3aac805e1e1281952
MD5 e71b6d450b4527fabd0b42201fdd5b42
BLAKE2b-256 63dbab5b2169627fb41328247db509c2b32bcd23cd5baff3dc700029da2226fa

See more details on using hashes here.

File details

Details for the file pyhalsimplicity-0.1.0-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for pyhalsimplicity-0.1.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 e9d08e6378a53965a21bcea7732e39ed81fc695ca122cd055b75cac507b1236d
MD5 07ac2fe894315bbfe1cb3874cc639f1b
BLAKE2b-256 ca96828c7d6007b4689ca382bd0bf34df92e712e1e880d8466fa959f8184dbbe

See more details on using hashes here.

File details

Details for the file pyhalsimplicity-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyhalsimplicity-0.1.0-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 d5e1baac99ca47e13cbb1aa43217c02b5929a860627d7658810e421490f2a786
MD5 5bf8e6af877170ea909873c27d6be435
BLAKE2b-256 a819f22b8901992f2333836d976f9c5a155bdbe4167c971431315f6fe95c4f8a

See more details on using hashes here.

File details

Details for the file pyhalsimplicity-0.1.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyhalsimplicity-0.1.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e672b8eff4f39ef0de7d21f31f7d31b6f8ca158accfedfb17b9b1484e6381ce3
MD5 3f2ba6cba71d4bc8d5f54fdeccdd6e94
BLAKE2b-256 6b03f61b6417181150a8c79b7129a3ceee1b8d3e0471b360d944ed3ea987cab1

See more details on using hashes here.

File details

Details for the file pyhalsimplicity-0.1.0-cp39-cp39-win_amd64.whl.

File metadata

File hashes

Hashes for pyhalsimplicity-0.1.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a72ce498bcc7bbdfcec01e2b13d3f3263f0028db08fb1b3d369cc71ddd3ac716
MD5 82afc0861d8d278d15e4c4e842878bf6
BLAKE2b-256 484275f361090a7d08df71246406953af94710399528fbf6597b8355129bc8d8

See more details on using hashes here.

File details

Details for the file pyhalsimplicity-0.1.0-cp39-cp39-manylinux_2_34_x86_64.whl.

File metadata

File hashes

Hashes for pyhalsimplicity-0.1.0-cp39-cp39-manylinux_2_34_x86_64.whl
Algorithm Hash digest
SHA256 4db58a047b7ca335464892c47427bf6887523f393b5d377983700f3781ba430d
MD5 5de58e171b4272ba99a4c3d4216aff35
BLAKE2b-256 2848ae1f14db0625153e0ab5819d049651a0ab998586daed275d0f2ba08d8f7f

See more details on using hashes here.

File details

Details for the file pyhalsimplicity-0.1.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyhalsimplicity-0.1.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 50c01eccc839be779217b4e2b8148376f919f099efb866dd16daaa08c125ea04
MD5 9269099d78469816eb8fb81211b8cb7f
BLAKE2b-256 3979a379043167edf5e7ad5445f576e20b7d50caac1d4c15ba26359b75a80bd8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page