qudag-cli 0.4.3

Command-line interface for QuDAG - Manage nodes, peers, dark addresses, rUv token exchange, and business plan payouts
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
# QuDAG CLI

Comprehensive command-line interface for QuDAG - the darknet for agent swarms with quantum-resistant distributed communication, rUv token exchange, and business plan payouts.

## Features

- **Node Management**: Start, stop, and manage QuDAG nodes
- **Exchange Operations**: rUv token transfers with dynamic fee models
- **Business Plan**: Automated payout distribution for contributors
- **Dark Addressing**: Anonymous .dark domain registration and routing
- **MCP Server**: Model Context Protocol integration for AI agents
- **Quantum Crypto**: ML-DSA signatures and ML-KEM encryption
- **Password Vault**: Quantum-resistant credential management
- **P2P Networking**: Onion routing and NAT traversal

## Installation

```bash
cargo install qudag-cli
```

> **Note:** The CLI binary is named `qudag` after installation.

## Quick Start

```bash
# Start a QuDAG node with exchange enabled
qudag start --port 8000 --enable-exchange

# Create an rUv token account
qudag exchange create-account --name "alice" --email "alice@example.com"

# Register your darknet domain
qudag address register mynode.dark

# Start MCP server for AI agent integration
qudag mcp start --port 3000

# Check comprehensive status
qudag status
```

## Commands

### Node Management

```bash
# Start a node
qudag start [--port 8000] [--rpc-port 9090]

# Stop the node
qudag stop

# Get node status
qudag status

# Restart node
qudag restart
```

### Peer Operations

```bash
# List connected peers
qudag peer list

# Add a peer
qudag peer add <multiaddr>

# Remove a peer
qudag peer remove <peer_id>

# Ban a peer
qudag peer ban <peer_id>

# Test connectivity
qudag network test
```

### Dark Addressing

```bash
# Register a .dark domain
qudag address register mydomain.dark

# Resolve a domain
qudag address resolve somedomain.dark

# Create temporary shadow address
qudag address shadow --ttl 3600

# Generate quantum fingerprint
qudag address fingerprint --data "Hello World"

# List your registered domains
qudag address list
```

### Exchange Operations

Manage rUv tokens and business plan payouts:

```bash
# Account Management
qudag exchange create-account --name "alice" --email alice@example.com
qudag exchange balance --account "alice"
qudag exchange list-accounts --format table

# Token Transfers
qudag exchange transfer --from "alice" --to "bob" --amount 1000
qudag exchange transfer --from "alice" --to "bob" --amount 5000 --memo "Payment for services"

# Fee Management
qudag exchange fee-info --examples
qudag exchange calculate-fee --account "alice" --amount 10000
qudag exchange verify-agent "alice" --proof-path ./proofs/alice_kyc.proof

# Immutable Deployment
qudag exchange deploy-immutable --key-path ./keys/quantum_master.key
qudag exchange immutable-status --format json
```

### Business Plan Management

Configure and manage automated payout distribution:

```bash
# Enable Business Plan Features
qudag exchange business-plan enable \
    --auto-distribution \
    --vault-management \
    --role-earnings \
    --bounty-rewards

# Check Status
qudag exchange business-plan status

# Configure Payouts
qudag exchange business-plan configure threshold 100
qudag exchange business-plan configure system-fee 0.001
qudag exchange business-plan configure single-agent --agent 0.95 --infrastructure 0.05
qudag exchange business-plan configure plugin-enhanced --agent 0.85 --plugin 0.10 --infrastructure 0.05

# Contributor Management
qudag exchange business-plan contributors register agent-001 agent-provider vault-001
qudag exchange business-plan contributors register plugin-002 plugin-creator vault-002 --custom-percentage 0.12
qudag exchange business-plan contributors list
qudag exchange business-plan contributors show agent-001
qudag exchange business-plan contributors update agent-001 --custom-percentage 0.90

# View Payout History
qudag exchange business-plan payouts --limit 50
qudag exchange business-plan payouts --contributor agent-001
```

### MCP Server Operations

Model Context Protocol server for AI agent integration:

```bash
# Start MCP Server
qudag mcp start --port 3000 --host 0.0.0.0
qudag mcp start --stdio  # For stdio transport

# Server Management
qudag mcp status
qudag mcp stop
qudag mcp logs --follow

# List Available Tools
qudag mcp tools list
qudag mcp resources list

# Configuration
qudag mcp config show
qudag mcp config set max_connections 100
```

### Quantum Cryptography

Generate and manage quantum-resistant keys:

```bash
# Key Generation
qudag key generate --algorithm ml-dsa    # ML-DSA-87 signatures
qudag key generate --algorithm ml-kem    # ML-KEM-768 encryption
qudag key generate --algorithm hqc       # HQC hybrid encryption
qudag key list
qudag key export <key-id> --format pem

# Signing Operations
qudag sign "message to sign" --key <key-id>
qudag sign --file document.pdf --key <key-id> --output document.sig
qudag verify <signature> "message" --key <public-key>

# Encryption Operations
qudag encrypt "secret message" --recipient <public-key>
qudag encrypt --file secret.doc --recipient <public-key> --output secret.enc
qudag decrypt <ciphertext> --key <private-key>
qudag hybrid-encrypt <data> --recipients key1,key2,key3
```

### DAG Visualization

Generate and analyze DAG structure:

```bash
# Generate DAG visualization
qudag dag --output dag_graph.dot
qudag dag --format png --output dag_graph.png
qudag dag --depth 10 --highlight-tips

# DAG Analysis
qudag dag analyze --metrics
qudag dag tips --format json
qudag dag ancestors <vertex-id>
qudag dag descendants <vertex-id>
```

### Password Vault

The QuDAG CLI includes a quantum-resistant password vault for secure credential management:

```bash
# Initialize a new vault
qudag vault init

# Generate secure passwords
qudag vault generate                    # Default 16-character password
qudag vault generate --length 32       # 32-character password
qudag vault generate --count 5         # Generate 5 passwords
qudag vault generate --no-symbols      # Alphanumeric only

# Add password entries
qudag vault add github --username myuser    # Prompts for password
qudag vault add email --generate           # Auto-generates password

# Retrieve passwords
qudag vault get github                 # Shows password details
qudag vault get github --clipboard     # Copies to clipboard

# List vault entries
qudag vault list                       # Simple list
qudag vault list --format json        # JSON output
qudag vault list --format tree        # Tree structure

# Update existing entries
qudag vault update github --password   # Change password
qudag vault update github --username   # Change username

# Remove entries
qudag vault remove github             # Remove entry
qudag vault remove github --force     # Skip confirmation

# Vault management
qudag vault export backup.qdag        # Export encrypted backup
qudag vault import backup.qdag        # Import from backup
qudag vault passwd                     # Change master password
qudag vault stats                      # Show vault statistics

# Configuration
qudag vault config show               # Show vault settings
qudag vault config set auto_lock 600  # Set auto-lock timeout
```

### Network Operations

```bash
# Show network statistics
qudag network stats

# Test peer connectivity
qudag network test

# Monitor network events
qudag network monitor --interval 5

# NAT Traversal
qudag nat status
qudag nat configure --upnp
qudag nat test

# Routing Configuration
qudag route onion --hops 3
qudag route direct --peer <peer-id>
qudag tunnel create --to <destination>
```

### Monitoring and Debugging

```bash
# Real-time monitoring
qudag monitor --metrics --log --interval 1

# Performance metrics
qudag metrics --format prometheus
qudag metrics export --output metrics.json

# Debug operations
qudag debug network --verbose
qudag debug consensus --verbose
qudag debug profile --duration 60

# Benchmarking
qudag benchmark --test crypto --duration 30
qudag benchmark --test network --parallel

# Health checks
qudag health --detailed
qudag health export --format json
```

### Configuration

```bash
# Show current configuration
qudag config show

# Set configuration value
qudag config set key value

# Import/Export configuration
qudag config import config.toml
qudag config export --output backup-config.toml

# Generate systemd service
qudag systemd --output /etc/systemd/system/
```

## Examples

### Setting Up Your First Node

```bash
# 1. Start your node
qudag start --port 8000

# 2. Register your identity
qudag address register mynode.dark

# 3. Connect to the network (use bootstrap peers)
qudag peer add /ip4/bootstrap.qudag.io/tcp/8000/p2p/12D3KooW...

# 4. Check status
qudag status
```

### Creating a Private Network

```bash
# Node 1
qudag start --port 8001
qudag address register node1.dark

# Node 2
qudag start --port 8002
qudag address register node2.dark
qudag peer add /ip4/127.0.0.1/tcp/8001/p2p/...

# Node 3
qudag start --port 8003
qudag address register node3.dark
qudag peer add /ip4/127.0.0.1/tcp/8001/p2p/...
qudag peer add /ip4/127.0.0.1/tcp/8002/p2p/...
```

### Dark Domain System

```bash
# Register domains for different services
qudag address register chat.dark
qudag address register files.dark
qudag address register api.dark

# Create temporary addresses for ephemeral communication
qudag address shadow --ttl 3600  # 1 hour
qudag address shadow --ttl 86400 # 24 hours

# Resolve any .dark domain to find peers
qudag address resolve chat.dark
qudag address resolve files.dark
```

### Exchange and Business Plan Workflow

```bash
# Initialize exchange with business plan
qudag exchange business-plan enable --auto-distribution --role-earnings

# Create accounts for participants
qudag exchange create-account --name "agent-provider" --email agent@example.com
qudag exchange create-account --name "plugin-creator" --email plugin@example.com
qudag exchange create-account --name "node-operator" --email node@example.com

# Register contributors
qudag exchange business-plan contributors register agent-001 agent-provider vault-001
qudag exchange business-plan contributors register plugin-002 plugin-creator vault-002 --custom-percentage 0.12
qudag exchange business-plan contributors register node-003 node-operator vault-003

# Configure payout thresholds
qudag exchange business-plan configure threshold 100
qudag exchange business-plan configure system-fee 0.001

# Process transactions with automatic fee distribution
qudag exchange transfer --from "user" --to "service" --amount 10000  # Fees auto-distributed

# Check payout history
qudag exchange business-plan payouts --limit 20
```

### MCP Server for AI Agents

```bash
# Start MCP server with full QuDAG integration
qudag mcp start --port 3000 --enable-vault --enable-exchange

# In another terminal, list available tools for agents
qudag mcp tools list

# Example output:
# - vault_create: Create secure vaults
# - vault_unlock: Access vault contents
# - exchange_transfer: Send rUv tokens
# - dag_query: Query DAG structure
# - network_peer_info: Get peer information

# Check server status
qudag mcp status
```

### Password Vault Setup

```bash
# Initialize your vault
qudag vault init

# Generate and store service passwords
qudag vault add github --username myuser --generate
qudag vault add docker --username dockerhub_user --generate
qudag vault add email --username user@example.com

# Create organized structure
qudag vault add work/aws --username admin --generate
qudag vault add work/kubernetes --generate
qudag vault add personal/social/twitter --username @myhandle

# Backup your vault
qudag vault export ~/secure-backup.qdag

# Daily usage
qudag vault get github --clipboard  # Copy to clipboard
qudag vault list work/             # List work passwords
qudag vault generate --length 32   # Generate new password
```

## Configuration File

QuDAG CLI uses a configuration file at `~/.qudag/config.toml`:

```toml
[node]
port = 8000
rpc_port = 9090
data_dir = "~/.qudag/data"
log_level = "info"

[network]
max_peers = 50
bootstrap_peers = [
    "/ip4/bootstrap1.qudag.io/tcp/8000/p2p/12D3KooW...",
    "/ip4/bootstrap2.qudag.io/tcp/8000/p2p/12D3KooW..."
]

[dark_addressing]
enable = true
ttl_default = 3600

[security]
enable_encryption = true
quantum_resistant = true

[vault]
path = "~/.qudag/vault.qdag"
auto_lock = 300  # seconds
clipboard_timeout = 30  # seconds
kdf_iterations = 3
kdf_memory = 65536  # KB

[exchange]
enable = true
network_name = "qudag-mainnet"
chain_id = 1
immutable_deployment = false

[exchange.fee_model]
f_min = 0.001  # 0.1%
f_max = 0.01   # 1.0%
f_min_verified = 0.0025  # 0.25%
f_max_verified = 0.005   # 0.5%
time_constant_days = 30
usage_threshold = 10000

[exchange.business_plan]
enabled = true
auto_distribution = true
vault_management = true
role_earnings = true
bounty_rewards = true
min_payout_threshold = 100
system_fee_percentage = 0.001

[mcp]
enable = true
port = 3000
host = "127.0.0.1"
transport = "http"  # http, stdio, or websocket
enable_vault_tools = true
enable_exchange_tools = true
enable_dag_tools = true
enable_network_tools = true

[monitoring]
enable_metrics = true
metrics_port = 9091
enable_tracing = true
trace_export = "jaeger"  # jaeger, otlp, or none
```

## Output Formats

Many commands support different output formats:

```bash
# JSON output
qudag status --output json

# Table output (default)
qudag peer list --output table

# Raw output for scripting
qudag peer list --output raw
```

## Logging

```bash
# View logs
qudag logs

# Follow logs in real-time
qudag logs --follow

# Filter by level
qudag logs --level error

# Save logs to file
qudag logs --output /var/log/qudag.log
```

## Systemd Integration

Generate systemd service files:

```bash
# Generate service file
qudag systemd --output /etc/systemd/system/

# Enable and start
sudo systemctl enable qudag
sudo systemctl start qudag
sudo systemctl status qudag
```

## Environment Variables

- `QUDAG_CONFIG` - Path to configuration file
- `QUDAG_DATA_DIR` - Data directory override
- `QUDAG_LOG_LEVEL` - Log level (trace, debug, info, warn, error)
- `QUDAG_PORT` - Default port override
- `QUDAG_RPC_PORT` - RPC port override
- `QUDAG_EXCHANGE_ENABLED` - Enable/disable exchange (true/false)
- `QUDAG_MCP_PORT` - MCP server port override
- `QUDAG_MCP_TRANSPORT` - MCP transport (http, stdio, websocket)
- `QUDAG_VAULT_PATH` - Vault file path override
- `QUDAG_NETWORK_NAME` - Network name for exchange
- `QUDAG_CHAIN_ID` - Chain ID for exchange

## Exit Codes

- `0` - Success
- `1` - General error
- `2` - Configuration error
- `3` - Network error
- `4` - Permission error
- `5` - Not found error

## Shell Completion

Generate shell completion scripts:

```bash
# Bash
qudag completions bash > /etc/bash_completion.d/qudag

# Zsh
qudag completions zsh > ~/.zsh/completions/_qudag

# Fish
qudag completions fish > ~/.config/fish/completions/qudag.fish
```

## Security Considerations

- All communication is quantum-resistant encrypted
- Private keys are stored securely in `~/.qudag/keys/`
- Configuration supports file permissions verification
- Network traffic uses onion routing for anonymity

## Troubleshooting

### Common Issues

**Node won't start**
```bash
# Check if port is in use
netstat -ln | grep :8000

# Check logs
qudag logs --level error
```

**Can't connect to peers**
```bash
# Test network connectivity
qudag network test

# Check firewall settings
sudo ufw status
```

**Permission errors**
```bash
# Check data directory permissions
ls -la ~/.qudag/

# Fix permissions
chmod 700 ~/.qudag/
```

**Exchange not working**
```bash
# Check if exchange is enabled
qudag exchange status

# Verify configuration
qudag config show | grep exchange

# Check vault connectivity
qudag vault status
```

**MCP server issues**
```bash
# Check if port is available
lsof -i :3000

# Test MCP server
qudag mcp status

# View MCP logs
qudag mcp logs --level debug
```

**Business plan payout issues**
```bash
# Check business plan status
qudag exchange business-plan status

# Verify contributor registration
qudag exchange business-plan contributors list

# Check minimum thresholds
qudag exchange business-plan configure show
```

## Documentation

- [QuDAG CLI Documentation]https://docs.rs/qudag-cli
- [Exchange Core Documentation]https://docs.rs/qudag-exchange-core
- [MCP Server Documentation]https://docs.rs/qudag-mcp
- [QuDAG Project]https://github.com/ruvnet/QuDAG
- [User Guide]https://github.com/ruvnet/QuDAG/blob/main/docs/cli/README.md
- [Exchange Business Plan]https://github.com/ruvnet/QuDAG/blob/main/qudag-exchange/docs/business-plan.md

## License

Licensed under either MIT or Apache-2.0 at your option.