Skip to content

A testing tool for Zcash transaction generation

Notifications You must be signed in to change notification settings

QED-it/zcash_tx_tool

Repository files navigation

Zcash Transaction Tool

License

The Zcash Transaction Tool is designed to create and send Zcash transactions to a node (e.g., Zebra). It currently supports transaction versions V5 and V6, including the Orchard ZSA (Zcash Shielded Assets) functionality.

This repository includes a simple Zebra Docker image that incorporates the OrchardZSA version of Zebra and runs in regtest mode.

WARNING: This tool is not a wallet and should not be used as a wallet. This tool is in the early stages of development and should not be used in production environments.

Table of Contents

Features

  • Transaction Creation: Craft custom Zcash transactions.
  • Transaction Submission: Send transactions to a Zcash node.
  • ZSA Support: Work with Zcash Shielded Assets (Orchard ZSA).
  • Version Compatibility: Supports transaction versions V5 and V6.

Supported systems

  • Tested on Ubuntu 22.04 LTS but should work on any Linux distribution that support the Prerequisites.

Status

  • Alpha - Everything, including APIs and data structures, is subject to breaking changes. Feature set is incomplete.

Core Components

  1. librustzcash: Used for transaction creation and serialization. This version includes slight modifications for additional functionality.
  2. Diesel ORM Framework: A safe and extensible ORM and query builder for Rust.
  3. Abscissa Framework: A microframework for building Rust applications.

Prerequisites

sudo apt update

sudo apt install pkg-config libssl-dev libsqlite3-dev 

Getting Started

1. Build and Run the Zebra Docker Image

Open a terminal and execute the following commands:

# Build the Zebra Docker image
docker build -t qedit/zebra-regtest-txv6 .

# Run the Zebra Docker container
docker run -p 18232:18232 qedit/zebra-regtest-txv6

For more details on how the Docker image is created and synchronized, refer to the Dockerfile.

2. Set Up and Run the Zcash Transaction Tool

In a separate terminal window, perform the following steps:

One-Time Setup

Install Diesel CLI and set up the database and get Zcash Params for Sapling:

# Install Diesel CLI with SQLite support
cargo install diesel_cli --no-default-features --features sqlite

# Set up the database
diesel setup

# Get Zcash Params for Sapling (if needed)
./zcutil/fetch-params.sh

Build and Run the Orchard ZSA Test Case

Build and run the test case using the Zcash Transaction Tool:

# Build and run with ZSA feature enabled
cargo run --release --package zcash_tx_tool --bin zcash_tx_tool test-orchard-zsa

Note: To re-run the test scenario, reset the Zebra node by stopping and restarting the Zebra Docker container.

The detailed script for the ZSA flow can be found in test_orchard_zsa.rs.

Configuration

You can specify the path to the configuration file using the --config flag when running the application. The default configuration file name is config.toml.

An example configuration file with default values is provided in regtest_config.toml.

Build Instructions

To set up the Diesel database:

  1. Install Diesel CLI:

    cargo install diesel_cli --no-default-features --features sqlite
  2. Set Up the Database:

    diesel setup

To build the application:

# Debug build
cargo build

# Release build (recommended for performance)
cargo build --release

To test ZSA functionality with the tool, enable the corresponding feature flag:

cargo build --release

ZSA Orchard Test Scenario

The main test scenario (src/commands/test_orchard_zsa.rs) consists of the following steps:

  1. Issue an Asset: Create and issue a new ZSA.
  2. Transfer the Asset: Send the issued asset to another account.
  3. Burn the Asset (Twice): Burn the asset in two separate transactions.

To run the test scenario:

cargo run --release --package zcash_tx_tool --bin zcash_tx_tool test-orchard-zsa

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements


Feel free to contribute to this project by opening issues or submitting pull requests.