Skip to content

GaloisField2718/test_opi_tools

Repository files navigation

TEST_OPI - Bitcoin OP_RETURN Transaction Builder

A modular framework for creating Bitcoin transactions with OP_RETURN outputs for BRC-20 operations, specifically designed for the test_opi operation.

🚀 Quick Start

Installation

# Install dependencies
npm install

# Copy and configure environment
cp .env.example .env
# Edit .env with your Bitcoin RPC settings and keys

Simple Usage

🎯 Main command:

npm run interactive

This command launches the interactive mode that guides you through all available test scenarios.

Essential Commands

# Interactive mode (recommended)
npm run interactive

# Test Bitcoin connection
npm run start test-connection

# Execute a specific scenario
npm run start execute single-op-return
npm run start execute two-outputs --tick test_opi --amount 10
npm run start execute external-address --external-address bc1q... --value 1000

# Dry-run mode (without broadcast)
npm run start execute single-op-return --dry-run

# Display configuration
npm run start config

⚙️ Required Configuration

Create a .env file with:

# Bitcoin RPC Configuration
BITCOIN_RPC_USER=your_rpc_user
BITCOIN_RPC_PASSWORD=your_rpc_password
BITCOIN_RPC_HOST=127.0.0.1
BITCOIN_RPC_PORT=8332

# Test OPI Configuration
WIF_OPI_TEST=your_wif_private_key
ADDRESS_OPI_TEST=your_test_funded_address
PUBKEY_OPI_TEST=your_public_key_hex

# Network Configuration
BITCOIN_NETWORK=testnet
FEE_RATE=10

📋 Test Scenarios

  1. Single OP_RETURN : Transaction with only an OP_RETURN output
  2. Two Outputs : OP_RETURN + 1200 sats to test address
  3. External Address : OP_RETURN + amount to external address
  4. Three Outputs : OP_RETURN in position 0 + 2 other outputs

🛠️ Available Scripts

# Interactive mode (recommended)
npm run interactive

# Individual scenarios
npm run scenario:1    # Single OP_RETURN
npm run scenario:2    # Two Outputs
npm run scenario:3    # External Address
npm run scenario:4    # Three Outputs

# Tests
npm run test          # All tests
npm run test:unit     # Unit tests
npm run test:integration # Integration tests

# Examples
npm run example:basic    # Basic example
npm run example:advanced # Advanced example

🔧 Features

  • Modular architecture : Easily extensible
  • 4 predefined test scenarios
  • Intuitive CLI interface with interactive mode
  • Bitcoin RPC support for finalization and broadcast
  • Smart UTXO management
  • Multi-network support (mainnet, testnet, regtest)
  • P2TR (Taproot) support with .equals error fixes
  • Complete logging with Winston
  • BRC-20 validation compliant with standards

📊 OP_RETURN Format

The project generates OP_RETURN messages in BRC-20 format:

{
  "p": "brc-20",
  "op": "test_opi",
  "tick": "test_opi",
  "amt": "10"
}

🔒 Security

  • Private keys are never logged
  • Strict Bitcoin address validation
  • Robust error handling
  • Support for different address types (P2PKH, P2WPKH, P2TR)

🆘 Support

For any questions or issues:

  1. Check logs in logs/test_opi.log
  2. Validate your configuration with npm run start validate-config
  3. Test Bitcoin connection with npm run start test-connection
  4. Consult the complete documentation in docs/README.md

📄 License

MIT License - see the LICENSE file for more details.


💡 Tip: Always start with npm run interactive for a guided experience!

About

Tools to test Universal BRC-20 test_opi PSBTs building

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors