New BitVMX Open Source Components Delivery: Introducing the BitVMX Protocol Builder – Graph-Based Transaction Design for Bitcoin

Fairgate Team
·
September 30, 2025
·

We’re continuing to expand the BitVMX open source stack, this time with one of our most foundational libraries: the BitVMX Protocol Builder.

This component enables developers to define, simulate, and manage Bitcoin protocol flows as directed acyclic graphs (DAGs) of pre-signed transactions. It abstracts away the complexity of crafting multi-step Bitcoin interactions, allowing protocols to be built from composable, auditable, and broadcast-ready units.

By releasing the Protocol Builder as open source, we hope to support researchers, protocol designers, and engineers building next-generation Bitcoin applications: from state channels and bridges to conditional dispute systems and Taproot fan-outs.


Why It Matters

Protocols that rely on pre-signed transactions, like payment channels, bridges, and fraud proofs—must guarantee that every possible path works under every possible condition. Manually crafting these flows is error-prone, especially when combining multiple signature types, timelocks, or Taproot scripts.

The BitVMX Protocol Builder addresses this challenge by automating the construction, signing, and validation of entire execution graphs. It enables reproducibility, auditability, and correctness, without requiring developers to manually wire inputs, outputs, and sighashes for every branch.


Core Features

  • Build protocol DAGs with Protocol and ProtocolBuilder
  • Combine Taproot (key/script path), P2WPKH, timelocks, and speedups in a single graph
  • Wire outputs and inputs manually or let the builder do it
  • Integrate MuSig2 and Winternitz signatures alongside ECDSA/Schnorr
  • Support for external UTXOs and CPFP speedup outputs
  • Estimate fees and balance flows with AUTO_AMOUNT and RECOVER_AMOUNT
  • Export transaction graphs as Graphviz visualizations

Functionalities Overview

Auto-Wired Protocol


let spend_key = key_manager.derive_keypair(0)?;
let mut protocol = Protocol::new("basic-flow");
let builder = ProtocolBuilder {};

builder
  .add_p2wpkh_output(&mut protocol, "funding", 75_000, &spend_key)?
  .add_p2wpkh_connection(
      &mut protocol,
      "funding_to_spend",
      "funding",
      75_000,
      &spend_key,
      "spend",
      &SighashType::ecdsa_all(),
  )?;

let protocol = protocol.build_and_sign(&key_manager, "basic-flow")?;
let tx = protocol.transaction_to_send("spend", &[InputArgs::new_segwit_args()])?;
println!("Ready to broadcast {}", tx.compute_txid());


Connecting External UTXOs


let txid = Txid::from_str("ce5ad9...")?;
builder.add_external_connection(
    &mut protocol,
    "onchain",
    txid,
    OutputSpec::Index(1),
    "funding",
    InputSpec::Auto(SighashType::ecdsa_all(), SpendMode::Segwit),
)?;

This attaches an externally provided UTXO to your flow, great for anchoring Taproot trees or pegging into your protocol logic.


Speedup Child-Pays-For-Parent transactions (CPFP)


let cpfp = builder.speedup_transactions(
    &[SpeedupData::new(target_utxo)],
    funding_utxo,
    &change_key,
    1000, // sats fee
    &key_manager,
)?;

This produces a fully signed transaction that merges inputs and helps accelerate confirmation via CPFP, key for time-sensitive protocols.


Auto-Balancing Outputs


let mut protocol = Protocol::new("auto-values");

let auto_output = OutputType::segwit_key(AUTO_AMOUNT, &spend_key)?;
protocol.add_transaction_output("parent", &auto_output)?;

let recover_output = OutputType::segwit_key(RECOVER_AMOUNT, &spend_key)?;
protocol.add_transaction_output("child", &recover_output)?;

protocol.compute_minimum_output_values()?; // Estimate & adjust outputs

No need to guess amounts. AUTO_AMOUNT automatically adjusts so child transactions can cover their own fees (1 sat/vB with a small buffer), while RECOVER_AMOUNT collects any leftover value so nothing gets stranded.


Visualizing the Graph


let dot = protocol.visualize(GraphOptions::Default)?;
std::fs::write("protocol.dot", dot)?;
// Then: dot -Tpng protocol.dot -o protocol.png

Perfect for debugging or auditing the full transaction flow before broadcast.


Status & Availability

This library is under active development, not audited, and not production-ready.

That said, we believe it's already a powerful tool for prototyping, research, and collaboration.


Get Involved

We invite developers, researchers, and protocol designers to experiment with the BitVMX Protocol Builder and help shape its evolution.

Let’s build more secure, reproducible, and Bitcoin-native systems, together.


Repository

GitHub FairgateLabs

🔗 BitVMX Protocol Builder

Join our community

New BitVMX Open Source Components Delivery: Introducing the BitVMX Protocol Builder – Graph-Based Transaction Design for Bitcoin

BitVMX's Open Source Journey Continues: Bitcoin Monitoring, Coordination and Indexing components now available

Introducing BitVMX New Open Source Components: Key Management, Storage, and Configuration

Building Secure and Watchtower-efficient Bitcoin Payment Channels with BitVMX

From Blueprint to Backend

Introducing the BitVMX 2025 Roadmap

Why RISC-V is the Optimal Architecture for the BitVMX Proving System

Improving BitVMX with Bitcoin Soft-forks

ESSPI: ECDSA / Schnorr Signed Program Input for BitVMX

BitVMX off-chain communication system: Multi-Exchange Handler

PKMN_BTTL: A Pokemon Battle Game, Written in Zig and Executed with BitVMX

Zero Knowledge Proof Verification On Bitcoin

BitVMX off-chain communication system: Key Components and Secure Strategies

Unlocking Trustless Bridges: BitVMX Goes Open Source

Union Bridge: A Trustless Gateway Between Bitcoin and Rootstock Powered by BitVMX

BitVMX: a practical exploration

First Release of BitVMX Implementation: Union Bridge by Rootstock

Optimizing Algorithms for Bitcoin Script (part 3)

BitVMX off-chain communication system: Protocol Implementation and Practical Applications

Optimizing Algorithms for Bitcoin Script (part 2)

Optimizing Algorithms for Bitcoin Script

Interactive SNARK Verification on Bitcoin using BitVMX!

A New Era for Bitcoin: Successful SNARK Proof Verification with BitVMX

We bitcoiners have a card under our sleeve: unpredictable innovation

Latest Innovations in BitVMX

The near future of bitcoin CPU: BitVMX

How BitVMX Differs from BitVM

BitVMX: A CPU for Universal Computation on Bitcoin

Keynote at Bitcoin++ ATX24 Script Edition for the BitVMX Presentation