Skip to main content

Python bindings for librustzcash: address parsing, ZIP-321 URIs, and key derivation

Project description

pyzcash

Python bindings for librustzcash. Built with PyO3.

Wraps zcash_address, zip321, and zcash_keys into four Python functions. All crypto runs in Rust.

Install

pip install maturin
git clone https://github.com/craigraw/pyzcash && cd pyzcash
maturin develop

Needs a Rust toolchain. Pre-built wheels coming eventually.

Usage

import pyzcash

# Parse any Zcash address (full checksum validation, not prefix matching)
info = pyzcash.parse_address("tmEZhbWHTpdKMw5it8YDspUXSMGQyFwovpU")
info.address_type  # "p2pkh"
info.network       # "test"
info.is_shielded   # False

# Parse a ZIP-321 payment URI
payments = pyzcash.parse_payment_uri("zcash:tmEZhbWHTpdKMw5it8YDspUXSMGQyFwovpU?amount=42.5")
payments[0].amount_zatoshis  # 4250000000
payments[0].amount_zec       # 42.5

# Generate a ZIP-321 payment URI
pyzcash.create_payment_uri("tmEZhbWHTpdKMw5it8YDspUXSMGQyFwovpU", 4_250_000_000)
# "zcash:tmEZhbWHTpdKMw5it8YDspUXSMGQyFwovpU?amount=42.5"

# Derive a unified address from a seed
import os
result = pyzcash.derive_address(os.urandom(32), network="main", account=0)
result.unified_address  # "u1..."

What it wraps

Function Crate Does
parse_address() zcash_address Validate + classify addresses
parse_payment_uri() zip321 Parse ZIP-321 URIs
create_payment_uri() zip321 Generate ZIP-321 URIs
derive_address() zcash_keys Seed to unified address (Orchard + Sapling)

No reimplemented crypto. Checksums, key derivation, encoding are all handled by the Rust libraries.

Status

Alpha. Four functions that work. Next steps:

  • Transaction building
  • Wallet scanning via zcash_client_backend
  • Viewing key import/export
  • Pre-built wheels so you don't need Rust installed

License

MIT

Project details


Download files

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

Source Distribution

pyzcash-0.1.0.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

pyzcash-0.1.0-cp314-cp314-macosx_11_0_arm64.whl (463.4 kB view details)

Uploaded CPython 3.14macOS 11.0+ ARM64

File details

Details for the file pyzcash-0.1.0.tar.gz.

File metadata

  • Download URL: pyzcash-0.1.0.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.12.6

File hashes

Hashes for pyzcash-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a840ffdb726157376b5749f9e31a055db97c69337b5868bf3980d95ef2783c8b
MD5 51506ddaeae7fe8b5c4b78c0095bcd02
BLAKE2b-256 5b0726b70e5afff9f1590305291a39f17319046934f36a8233b22dfe376e32a9

See more details on using hashes here.

File details

Details for the file pyzcash-0.1.0-cp314-cp314-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for pyzcash-0.1.0-cp314-cp314-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ecf2443e575b4babd110e5f4f470ab3dc0413603b09b7e01f79f112741a58769
MD5 d86a26683db52ac2767570943b74ce35
BLAKE2b-256 45132b7ecc4f4e5ca6bb39271e0c684b2455cc80212ddc2945fdfa1066456da2

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