> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bitrune.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Bitrune Verify (CLI)

> Command-line tool for independently verifying Bitrune transactions on the Bitcoin blockchain.

**bitrune-verify** is a command-line tool for independently verifying Bitrune transactions on the Bitcoin blockchain. It decodes the on-chain audit tags embedded in Runestone OP\_RETURN outputs and validates that the AMM math is correct — without trusting Bitrune's servers.

## Installation

Build from the project repository:

```bash theme={null}
cd cli
cargo build --release
```

The binary is produced at `target/release/bitrune-verify`.

## Usage

```
bitrune-verify <txid_or_hex> [options]
```

**Arguments:**

| Argument        | Description                                                                  |
| --------------- | ---------------------------------------------------------------------------- |
| `<txid_or_hex>` | A 64-character transaction ID (fetched from bitcoind) or raw transaction hex |

**Options:**

| Option       | Default                  | Description                       |
| ------------ | ------------------------ | --------------------------------- |
| `--rpc-url`  | `http://127.0.0.1:18443` | bitcoind RPC endpoint             |
| `--rpc-user` | `rpc`                    | RPC username                      |
| `--rpc-pass` | `rpc`                    | RPC password                      |
| `--json`     | off                      | Output results as structured JSON |
| `--help`     |                          | Show usage information            |

RPC credentials can also be set via environment variables: `BITRUNE_RPC_URL`, `BITRUNE_RPC_USER`, `BITRUNE_RPC_PASS`.

## What It Verifies

The tool decodes all Bitrune audit tags present in a transaction and runs validation checks against each:

| Tag  | Name                | Checks Performed                                                                                                                       |
| ---- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| 111  | Tax Specification   | Tax rates within valid range (0–10000 bps), bucket shares sum to 100%                                                                  |
| 333  | Swap Data           | Direction valid, amounts positive                                                                                                      |
| 555  | Reserve Proof       | Reserve deltas are directionally consistent (one up, one down), fee within range, LP shares positive, constant-product invariant holds |
| 777  | Tax Execution Proof | `gross = tax + net`, bucket distribution sums to total tax, `params_hash` matches etch-time commitment                                 |
| 889  | Pool Parameters     | Fee within range, initial reserve positive                                                                                             |
| 999  | LP Event Proof      | Operation type valid, reserve deltas match amounts, deposits have zero reward claims                                                   |
| 1111 | Batch Settlement    | User count positive, reserve changes consistent with total input/output                                                                |
| 1333 | LP-Rune Linkage     | Fee within range, LP premine positive                                                                                                  |

## Example

**Verify a swap transaction:**

```
$ bitrune-verify abc123...def456

Bitrune Tag Verifier
txid: abc123...def456

Tag 333 — Swap Data
  rune_id              840001:5
  direction            Buy (AToB)
  amount_in            1000000
  amount_out           4900000
  fee_in               3000
  [OK] direction valid
  [OK] amounts positive

Tag 555 — Reserve Proof
  reserve_a (pre)      100000000
  reserve_b (pre)      500000000000
  reserve_a (post)     101000000
  reserve_b (post)     495100000000
  fee_bps              30
  lp_total_shares      223606797
  [OK] directional consistency
  [OK] fee_bps in range
  [OK] constant-product invariant holds

Summary: 2 tags found, 2 passed, 0 failed
```

**JSON output for programmatic use:**

```bash theme={null}
bitrune-verify abc123...def456 --json
```

```json theme={null}
{
  "txid": "abc123...def456",
  "tags": [
    {
      "tag_id": 333,
      "name": "Swap Data",
      "fields": {
        "rune_id": "840001:5",
        "direction": "Buy",
        "amount_in": "1000000",
        "amount_out": "4900000",
        "fee_in": "3000"
      },
      "checks": [
        { "label": "direction valid", "passed": true },
        { "label": "amounts positive", "passed": true }
      ],
      "passed": true
    }
  ],
  "summary": { "total": 2, "passed": 2, "failed": 0 }
}
```

## Use Cases

* **Auditors**: Verify that every swap executed by Bitrune follows the constant-product formula and applies fees correctly.
* **Rune creators**: Confirm that deflationary tax rules are applied exactly as configured at etch time, with no modifications.
* **LP providers**: Validate that deposit/withdraw share calculations match the published AMM formulas.
* **Block explorers**: Integrate structured Bitrune tag data into transaction detail pages.

## Connecting to a Node

For mainnet verification, point the tool at a Bitcoin Core node with `txindex=1` enabled:

```bash theme={null}
bitrune-verify <txid> \
  --rpc-url http://127.0.0.1:8332 \
  --rpc-user myuser \
  --rpc-pass mypass
```

The tool only reads transactions; it does not broadcast or modify any blockchain state.
