hal – Bitcoin CLI swiss-army-knife (based on rust-bitcoin)

19.02.2024
hal - Bitcoin CLI swiss-army-knife (based on rust-bitcoin)

GitHub: https://github.com/stevenroose/hal

hal is a powerful command-line interface tool for Bitcoin that is built on top of rust-bitcoin. It is designed to be a Swiss army knife of sorts, providing a wide range of functionality for Bitcoin users and developers.

Some of the key features of hal include:

  1. Address generation: hal can generate new Bitcoin addresses for you to use.
  2. Transaction creation: you can use hal to create new Bitcoin transactions, specifying the inputs, outputs, and any other necessary parameters.
  3. Transaction signing: once you’ve created a transaction, you can use hal to sign it using your private keys.
  4. Transaction broadcasting: once your transaction is signed, you can use hal to broadcast it to the Bitcoin network.
  5. Block and transaction parsing: hal can parse Bitcoin blocks and transactions, allowing you to extract data from them.
  6. Wallet management: you can use hal to manage your Bitcoin wallets, including creating new wallets, importing and exporting keys, and managing your balances.
  7. Scripting: hal includes a powerful scripting language that allows you to automate complex Bitcoin-related tasks.

Overall, hal is a highly useful tool for anyone who works with Bitcoin on a regular basis. Whether you’re a developer building Bitcoin applications, a trader managing your Bitcoin holdings, or simply someone who wants to explore the capabilities of the Bitcoin protocol, hal can help you get the job done.

Script:

import subprocess

def execute_hal():
    subprocess.run(["hal", "--help"])

execute_hal()

this script uses the subprocess module in python to execute the command “hal –help” in the terminal. you can modify this script to execute any other command you want.

hal is a command line tool that provides all kinds of Bitcoin-related utilities.

Installation:

$ cargo install --locked hal

Summary of commands:

  • address
    • inspect: get information about addresses
    • create: create addresses using public keys or scripts
  • bech32
    • decode: parse the elements of the Bech32 format
    • encode: encode data in the Bech32 format
  • bip32
    • derive: derive keys and addresses from extended keys
    • inspect: inspect a BIP-32 xpub or xpriv
  • bip39
    • generate: generate a new BIP-39 mnemonic
    • get-seed: get the seed value and BIP-32 master key for a given BIP-39 mnemonic
  • block
    • create: create a binary block from JSON
    • decode: decode a binary block to JSON
  • hash
    • sha256: hash data with SHA-256
    • sha256d: hash data with double SHA-256
  • key
    • generate: generate a random keypair
    • derive: generate a public key from a private key
    • inspect: inspect private keys
    • ecdsa-sign: make ECDSA signatures
    • ecdsa-verify: verify ECDSA signatures
    • pubkey-tweak-add: add a scalar to a point
    • pubkey-combine: add two points together
  • ln
    • invoice
      • decode: decode Lightning invoices
  • merkle
    • proof-create: create a merkle proof
    • proof-check: check a merkle proof
  • message
    • hash: get hashes of Bitcoin Signed Message
    • sign: sign a message using Bitcoin Signed Message
    • verify: verify a Bitcoin Signed Message
    • recover: recover the pubkey or address that signed a message
  • miniscript
    • descriptor: get information about an output descriptor
    • instpect: inspect miniscripts
    • parse: parse a script into a miniscript
    • policy: inspect policies
  • psbt
    • create: create a PSBT from a raw unsigned transaction
    • decode: decode a PSBT to JSON
    • edit: edit a PSBT inline
    • finalize: finalize a PSBT into a fully signed transaction
    • merge: merge multiple PSBTs into one
  • random
    • bytes: generate random bytes
  • script
    • decode: decode a PSBT to JSON
  • tx
    • create: create a binary transaction from JSON
    • decode: decode a binary transaction to JSON

Minimum Supported Rust Version (MSRV):

hal should always compile on Rust 1.41.1. Note that it should be build using the Cargo.lock file, so using --locked


Useful information for enthusiasts:

Contact me via Telegram: @ExploitDarlenePRO