conduit-lightning 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. conduit_lightning-0.1.0/.env.example +64 -0
  2. conduit_lightning-0.1.0/.gitignore +65 -0
  3. conduit_lightning-0.1.0/LICENSE +21 -0
  4. conduit_lightning-0.1.0/PKG-INFO +297 -0
  5. conduit_lightning-0.1.0/README.md +225 -0
  6. conduit_lightning-0.1.0/alembic/env.py +63 -0
  7. conduit_lightning-0.1.0/alembic/script.py.mako +25 -0
  8. conduit_lightning-0.1.0/alembic/versions/.gitkeep +0 -0
  9. conduit_lightning-0.1.0/alembic/versions/1eb870646862_widen_verification_challenge_column_to_.py +35 -0
  10. conduit_lightning-0.1.0/alembic/versions/7fc82049fb21_add_provider_verification_fields_to_.py +37 -0
  11. conduit_lightning-0.1.0/alembic/versions/8653ac33d7b0_add_spending_logs_table.py +40 -0
  12. conduit_lightning-0.1.0/alembic/versions/a1b2c3d4e5f6_add_platform_fee_fields_to_executions.py +39 -0
  13. conduit_lightning-0.1.0/alembic/versions/aafa0ed79a99_add_unique_constraint_on_rating_.py +29 -0
  14. conduit_lightning-0.1.0/alembic/versions/bab4c7e4bcae_add_unique_constraint_on_rating_.py +29 -0
  15. conduit_lightning-0.1.0/alembic/versions/e5ca7b709dad_add_anomaly_flags_table.py +44 -0
  16. conduit_lightning-0.1.0/alembic/versions/ed0aef0bc1ea_add_unique_constraint_on_rating_.py +29 -0
  17. conduit_lightning-0.1.0/alembic/versions/f6e0d4715ba0_initial_schema.py +151 -0
  18. conduit_lightning-0.1.0/alembic.ini +39 -0
  19. conduit_lightning-0.1.0/pyproject.toml +119 -0
  20. conduit_lightning-0.1.0/src/conduit/__init__.py +3 -0
  21. conduit_lightning-0.1.0/src/conduit/api/__init__.py +0 -0
  22. conduit_lightning-0.1.0/src/conduit/api/deps.py +105 -0
  23. conduit_lightning-0.1.0/src/conduit/api/middleware/__init__.py +7 -0
  24. conduit_lightning-0.1.0/src/conduit/api/middleware/l402.py +205 -0
  25. conduit_lightning-0.1.0/src/conduit/api/middleware/rate_limit.py +151 -0
  26. conduit_lightning-0.1.0/src/conduit/api/middleware/verification.py +160 -0
  27. conduit_lightning-0.1.0/src/conduit/api/routers/__init__.py +5 -0
  28. conduit_lightning-0.1.0/src/conduit/api/routers/admin.py +77 -0
  29. conduit_lightning-0.1.0/src/conduit/api/routers/lightning.py +218 -0
  30. conduit_lightning-0.1.0/src/conduit/api/routers/marketplace.py +636 -0
  31. conduit_lightning-0.1.0/src/conduit/api/routers/nostr.py +235 -0
  32. conduit_lightning-0.1.0/src/conduit/api/routers/security.py +189 -0
  33. conduit_lightning-0.1.0/src/conduit/core/__init__.py +0 -0
  34. conduit_lightning-0.1.0/src/conduit/core/config.py +129 -0
  35. conduit_lightning-0.1.0/src/conduit/core/database.py +31 -0
  36. conduit_lightning-0.1.0/src/conduit/main.py +213 -0
  37. conduit_lightning-0.1.0/src/conduit/mcp_server.py +2334 -0
  38. conduit_lightning-0.1.0/src/conduit/models/__init__.py +23 -0
  39. conduit_lightning-0.1.0/src/conduit/models/anomaly_flag.py +43 -0
  40. conduit_lightning-0.1.0/src/conduit/models/base.py +27 -0
  41. conduit_lightning-0.1.0/src/conduit/models/execution.py +74 -0
  42. conduit_lightning-0.1.0/src/conduit/models/invoice.py +54 -0
  43. conduit_lightning-0.1.0/src/conduit/models/payment.py +58 -0
  44. conduit_lightning-0.1.0/src/conduit/models/rating.py +49 -0
  45. conduit_lightning-0.1.0/src/conduit/models/skill.py +85 -0
  46. conduit_lightning-0.1.0/src/conduit/models/spending_log.py +35 -0
  47. conduit_lightning-0.1.0/src/conduit/models/wallet.py +42 -0
  48. conduit_lightning-0.1.0/src/conduit/schemas/__init__.py +0 -0
  49. conduit_lightning-0.1.0/src/conduit/schemas/invoice.py +32 -0
  50. conduit_lightning-0.1.0/src/conduit/schemas/payment.py +30 -0
  51. conduit_lightning-0.1.0/src/conduit/schemas/wallet.py +36 -0
  52. conduit_lightning-0.1.0/src/conduit/services/__init__.py +0 -0
  53. conduit_lightning-0.1.0/src/conduit/services/anomaly_detector.py +274 -0
  54. conduit_lightning-0.1.0/src/conduit/services/fee_calculator.py +61 -0
  55. conduit_lightning-0.1.0/src/conduit/services/l402.py +377 -0
  56. conduit_lightning-0.1.0/src/conduit/services/lnd.py +284 -0
  57. conduit_lightning-0.1.0/src/conduit/services/macaroon_auth.py +332 -0
  58. conduit_lightning-0.1.0/src/conduit/services/nostr.py +819 -0
  59. conduit_lightning-0.1.0/src/conduit/services/nwc.py +728 -0
  60. conduit_lightning-0.1.0/src/conduit/services/proto_generated/lightning_pb2.py +683 -0
  61. conduit_lightning-0.1.0/src/conduit/services/proto_generated/lightning_pb2_grpc.py +3377 -0
  62. conduit_lightning-0.1.0/src/conduit/services/provider_verification.py +482 -0
  63. conduit_lightning-0.1.0/src/conduit/services/rate_limiter.py +450 -0
  64. conduit_lightning-0.1.0/src/conduit/services/rating_integrity.py +201 -0
  65. conduit_lightning-0.1.0/src/conduit/services/skill_executor.py +191 -0
  66. conduit_lightning-0.1.0/src/conduit/services/spending_limiter.py +383 -0
  67. conduit_lightning-0.1.0/src/conduit/services/url_safety.py +192 -0
  68. conduit_lightning-0.1.0/src/conduit/services/wallet_backend.py +149 -0
@@ -0,0 +1,64 @@
1
+ # =============================================================================
2
+ # Conduit Environment Configuration
3
+ # Copy this file to .env and fill in your values
4
+ # =============================================================================
5
+
6
+ # --- App ---
7
+ APP_NAME=Conduit
8
+ APP_ENV=development
9
+ DEBUG=false
10
+ API_HOST=127.0.0.1
11
+ API_PORT=8000
12
+
13
+ # --- API Authentication ---
14
+ # Generate a strong random key: python3 -c "import secrets; print(secrets.token_urlsafe(32))"
15
+ CONDUIT_API_KEY=CHANGE-ME-generate-a-random-key
16
+
17
+ # --- PostgreSQL ---
18
+ DATABASE_URL=postgresql+asyncpg://conduit:conduit@localhost:5432/conduit
19
+
20
+ # --- Redis (optional, falls back to in-memory rate limiting) ---
21
+ REDIS_URL=redis://localhost:6379/0
22
+
23
+ # --- Wallet Backend ---
24
+ # "lnd" = direct gRPC to your LND node
25
+ # "nwc" = Nostr Wallet Connect (Alby, Primal, Zeus, etc.)
26
+ # "auto" = use NWC if connection string is set, else LND
27
+ WALLET_BACKEND=auto
28
+
29
+ # --- NWC (Nostr Wallet Connect) ---
30
+ # Paste your connection string from your wallet app (e.g. Alby)
31
+ # NWC_CONNECTION_STRING=nostr+walletconnect://...
32
+
33
+ # --- LND Node (only needed if WALLET_BACKEND=lnd) ---
34
+ LND_HOST=localhost
35
+ LND_GRPC_PORT=10009
36
+ LND_REST_PORT=8080
37
+ LND_TLS_CERT_PATH=~/.lnd/tls.cert
38
+ LND_MACAROON_PATH=~/.lnd/data/chain/bitcoin/regtest/admin.macaroon
39
+ # Set to "mainnet", "testnet", or "regtest"
40
+ LND_NETWORK=regtest
41
+
42
+ # --- L402 Auth ---
43
+ L402_ENABLED=false
44
+ # Generate a unique secret: python3 -c "import secrets; print(secrets.token_urlsafe(32))"
45
+ L402_SECRET_KEY=CHANGE-ME-generate-a-random-secret
46
+ L402_TOKEN_EXPIRY_SECONDS=3600
47
+ L402_DEFAULT_PRICE_SATS=10
48
+
49
+ # --- Fees ---
50
+ TRANSACTION_FEE_PERCENT=1.5
51
+
52
+ # --- Spending Limits (sats, 0 = unlimited) ---
53
+ SPENDING_LIMIT_PER_PAYMENT_SATS=10000
54
+ SPENDING_LIMIT_HOURLY_SATS=50000
55
+ SPENDING_LIMIT_DAILY_SATS=200000
56
+ SPENDING_CONFIRM_ABOVE_SATS=1000
57
+
58
+ # --- CORS ---
59
+ # Comma-separated origins. Never use "*" in production.
60
+ CORS_ALLOW_ORIGINS=http://localhost:3000
61
+
62
+ # --- Nostr (optional) ---
63
+ # NOSTR_PRIVATE_KEY=nsec1...
64
+ # NOSTR_RELAYS=wss://relay.damus.io,wss://nos.lol
@@ -0,0 +1,65 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.egg-info/
6
+ dist/
7
+ build/
8
+ .eggs/
9
+
10
+ # Virtual environments
11
+ .venv/
12
+ venv/
13
+ env/
14
+
15
+ # Environment files
16
+ .env
17
+
18
+ # IDE
19
+ .vscode/
20
+ .idea/
21
+ *.swp
22
+ *.swo
23
+
24
+ # Testing
25
+ .coverage
26
+ htmlcov/
27
+ .pytest_cache/
28
+
29
+ # Raw proto definitions (generated stubs ARE committed)
30
+ src/conduit/services/protos/
31
+
32
+ # Alembic auto-stamp
33
+ alembic/versions/__pycache__/
34
+
35
+ # OS
36
+ .DS_Store
37
+ Thumbs.db
38
+
39
+ # LND credentials (NEVER commit these)
40
+ credentials/
41
+
42
+ # L4: Catch credential files anywhere in the tree
43
+ *.macaroon
44
+ *.pem
45
+ *.cert
46
+ *.key
47
+ *.nsec
48
+
49
+ # Docker volumes
50
+ postgres_data/
51
+ get-pip.py
52
+
53
+ # Sensitive scripts (keep local only)
54
+ cleanup_db.py
55
+ demo_e2e.py
56
+ SECURITY_AUDIT.md
57
+
58
+ # Internal strategy/architecture docs (keep local only)
59
+ conduit_competitive_intel.md
60
+ conduit_full_architecture.md
61
+ conduit_noncustodial_architecture.md
62
+
63
+ # Local-only project guide for Claude (loaded from disk; kept out of the public repo)
64
+ CLAUDE.md
65
+ CLAUDE.local.md
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Conduit-Agentic
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,297 @@
1
+ Metadata-Version: 2.4
2
+ Name: conduit-lightning
3
+ Version: 0.1.0
4
+ Summary: Lightning Payment Rails for AI Agents — discover, pay for, and execute skills over Lightning via MCP or REST
5
+ Project-URL: Homepage, https://github.com/Lightning-Linq/Conduit
6
+ Project-URL: Repository, https://github.com/Lightning-Linq/Conduit
7
+ Project-URL: Issues, https://github.com/Lightning-Linq/Conduit/issues
8
+ Author: Lightning Linq
9
+ License: MIT License
10
+
11
+ Copyright (c) 2026 Conduit-Agentic
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining a copy
14
+ of this software and associated documentation files (the "Software"), to deal
15
+ in the Software without restriction, including without limitation the rights
16
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17
+ copies of the Software, and to permit persons to whom the Software is
18
+ furnished to do so, subject to the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be included in all
21
+ copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29
+ SOFTWARE.
30
+ License-File: LICENSE
31
+ Keywords: ai-agents,bitcoin,l402,lightning,mcp,nostr,nwc,payments
32
+ Classifier: Development Status :: 4 - Beta
33
+ Classifier: Framework :: FastAPI
34
+ Classifier: Intended Audience :: Developers
35
+ Classifier: License :: OSI Approved :: MIT License
36
+ Classifier: Operating System :: OS Independent
37
+ Classifier: Programming Language :: Python :: 3
38
+ Classifier: Programming Language :: Python :: 3.11
39
+ Classifier: Programming Language :: Python :: 3.12
40
+ Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
41
+ Requires-Python: >=3.11
42
+ Requires-Dist: alembic>=1.13.0
43
+ Requires-Dist: asyncpg>=0.29.0
44
+ Requires-Dist: coincurve>=20.0.0
45
+ Requires-Dist: cryptography>=42.0.0
46
+ Requires-Dist: fastapi>=0.111.0
47
+ Requires-Dist: grpcio>=1.64.0
48
+ Requires-Dist: httpx>=0.27.0
49
+ Requires-Dist: mcp>=1.0.0
50
+ Requires-Dist: protobuf>=5.27.0
51
+ Requires-Dist: pydantic-settings>=2.3.0
52
+ Requires-Dist: pydantic>=2.7.0
53
+ Requires-Dist: pymacaroons>=0.13.0
54
+ Requires-Dist: python-dotenv>=1.0.0
55
+ Requires-Dist: qrcode[pil]>=7.4.0
56
+ Requires-Dist: redis>=5.0.0
57
+ Requires-Dist: sqlalchemy[asyncio]>=2.0.30
58
+ Requires-Dist: uvicorn[standard]>=0.30.0
59
+ Requires-Dist: websockets>=12.0
60
+ Provides-Extra: dev
61
+ Requires-Dist: grpcio-tools>=1.64.0; extra == 'dev'
62
+ Requires-Dist: mypy>=1.10.0; extra == 'dev'
63
+ Requires-Dist: pre-commit>=3.7.0; extra == 'dev'
64
+ Requires-Dist: pytest-asyncio>=0.23.0; extra == 'dev'
65
+ Requires-Dist: pytest-cov>=5.0.0; extra == 'dev'
66
+ Requires-Dist: pytest>=8.2.0; extra == 'dev'
67
+ Requires-Dist: ruff>=0.4.0; extra == 'dev'
68
+ Provides-Extra: publish
69
+ Requires-Dist: build>=1.2.0; extra == 'publish'
70
+ Requires-Dist: twine>=5.0.0; extra == 'publish'
71
+ Description-Content-Type: text/markdown
72
+
73
+ # Conduit
74
+
75
+ **Lightning Payment Rails for AI Agents** | by [Lightning Linq](https://lightninglinq.com)
76
+
77
+ Conduit is a non-custodial payment infrastructure layer that lets AI agents transact over the Lightning Network. It exposes a skill marketplace and Lightning tools via the [Model Context Protocol (MCP)](https://modelcontextprotocol.io), enabling any MCP-compatible AI (like Claude) to discover, purchase, and rate agent-provided services -- all settled instantly in Bitcoin.
78
+
79
+ Conduit never takes custody of funds. Payments flow directly between agents on Lightning. Conduit provides coordination, discovery, reputation, and security -- never custody.
80
+
81
+ > Conduit is the first product from **Lightning Linq**, an open-source company building Lightning infrastructure for AI agents.
82
+
83
+ ## How It Works
84
+
85
+ ```
86
+ ┌──────────────────────────────────────────────────────────┐
87
+ │ Claude Desktop │
88
+ │ (or any MCP client) │
89
+ └──────────────┬───────────────────────────────────────────┘
90
+ │ MCP (stdio)
91
+
92
+ ┌──────────────────────────────────────────────────────────┐
93
+ │ Conduit MCP Server │
94
+ │ │
95
+ │ ┌─────────────┐ ┌──────────────┐ ┌─────────────────┐ │
96
+ │ │ Lightning │ │ Marketplace │ │ Security │ │
97
+ │ │ Tools │ │ Tools │ │ Layer │ │
98
+ │ │ │ │ │ │ │ │
99
+ │ │ • invoices │ │ • discover │ │ • API key auth │ │
100
+ │ │ • payments │ │ • register │ │ • macaroons │ │
101
+ │ │ • balance │ │ • execute │ │ • spending limits │ │
102
+ │ │ • decode │ │ • rate │ │ • rate limiting │ │
103
+ │ │ │ │ • verify │ │ • anomaly detect │ │
104
+ │ └──────┬──────┘ └──────┬───────┘ └─────────────────┘ │
105
+ │ │ │ │
106
+ └─────────┼────────────────┼────────────────────────────────┘
107
+ │ │
108
+ ▼ ▼
109
+ ┌──────────────┐ ┌──────────────┐
110
+ │ LND Node │ │ PostgreSQL │
111
+ │ (your node) │ │ (local DB) │
112
+ │ │ │ │
113
+ │ non-custodial │ skills, │
114
+ │ payments │ │ executions, │
115
+ │ │ │ ratings, │
116
+ │ │ │ audit logs │
117
+ └──────────────┘ └──────────────┘
118
+ ```
119
+
120
+ ## Features
121
+
122
+ **Lightning Network Integration** — Create and pay invoices via your own LND node. Decode payment requests, check payment status, view node info and channel balances. Non-custodial: your keys, your node, your sats.
123
+
124
+ **Skill Marketplace** — Register skills with pricing, categories, and input/output schemas. Discover skills by keyword, category, or price range. Request executions with automatic Lightning invoicing. Webhook-based execution engine with payment proof delivery. Rating system backed by cryptographic payment proofs.
125
+
126
+ **Security Stack** — API key authentication, scoped macaroon authorization (8 permissions, 4 profiles), per-payment/hourly/daily spending limits, in-memory sliding window rate limiting, anomaly detection (self-payment, rapid repeat, structuring, volume spike), rating integrity (preimage verification, duplicate prevention, weighted averages), and provider verification via Lightning node signatures and domain proof.
127
+
128
+ ## Quick Start
129
+
130
+ ```bash
131
+ git clone https://github.com/Lightning-Linq/conduit.git
132
+ cd conduit
133
+ chmod +x install.sh
134
+ ./install.sh
135
+ ```
136
+
137
+ The install script handles everything: checks prerequisites (Python 3.11+, PostgreSQL), creates virtual environment, installs dependencies, generates a secure API key, sets up the database, runs migrations, and shows you how to wire it into Claude Desktop.
138
+
139
+ ### Prerequisites
140
+
141
+ - **Python 3.11+** — `brew install python@3.11` or use pyenv
142
+ - **PostgreSQL 16** — `brew install postgresql@16 && brew services start postgresql@16`
143
+ - **LND node** — running and accessible (local, remote, or via Tor)
144
+
145
+ ### Claude Desktop Configuration
146
+
147
+ Add this to your `claude_desktop_config.json`:
148
+
149
+ ```json
150
+ {
151
+ "mcpServers": {
152
+ "conduit-lightning": {
153
+ "command": "/path/to/conduit/.venv/bin/python",
154
+ "args": ["-m", "conduit.mcp_server"],
155
+ "env": {
156
+ "PYTHONPATH": "/path/to/conduit/src"
157
+ }
158
+ }
159
+ }
160
+ }
161
+ ```
162
+
163
+ Restart Claude Desktop. Ask Claude: *"What's my Lightning node balance?"*
164
+
165
+ ## MCP Tools Reference
166
+
167
+ Conduit exposes 19 tools over the Model Context Protocol.
168
+
169
+ ### Lightning Tools
170
+
171
+ | Tool | Permission | Description |
172
+ |------|-----------|-------------|
173
+ | `get_node_info` | lightning:read | Node alias, pubkey, active channels, peers |
174
+ | `get_balance` | lightning:read | On-chain and channel balances |
175
+ | `create_invoice` | lightning:invoice | Generate a Lightning invoice |
176
+ | `pay_invoice` | lightning:pay | Pay a Lightning invoice (with spending limits) |
177
+ | `decode_invoice` | lightning:read | Decode a payment request without paying |
178
+ | `check_payment` | lightning:read | Check if a payment has settled |
179
+
180
+ ### Marketplace Tools
181
+
182
+ | Tool | Permission | Description |
183
+ |------|-----------|-------------|
184
+ | `discover_skills` | marketplace:read | Search skills by keyword, category, price |
185
+ | `get_skill_details` | marketplace:read | Full details including schemas and ratings |
186
+ | `register_skill` | marketplace:write | List a new skill on the marketplace |
187
+ | `request_skill_execution` | marketplace:execute | Request execution (generates invoice) |
188
+ | `confirm_skill_execution` | marketplace:execute | Confirm payment and trigger webhook |
189
+ | `submit_rating` | marketplace:execute | Rate a skill (requires payment proof) |
190
+
191
+ ### Verification Tools
192
+
193
+ | Tool | Permission | Description |
194
+ |------|-----------|-------------|
195
+ | `request_verification` | marketplace:write | Start node or domain verification |
196
+ | `submit_verification` | marketplace:write | Complete verification with proof |
197
+ | `get_verification_status` | marketplace:read | Check a skill's verification badges |
198
+
199
+ ### Security Tools
200
+
201
+ | Tool | Permission | Description |
202
+ |------|-----------|-------------|
203
+ | `get_spending_status` | security:read | Current spending vs. limits |
204
+ | `create_macaroon` | security:admin | Mint a scoped authorization token |
205
+ | `list_permissions` | security:read | Show active permissions |
206
+ | `get_anomaly_report` | security:read | View flagged suspicious patterns |
207
+
208
+ ## Security Model
209
+
210
+ Conduit uses defense-in-depth with multiple security layers.
211
+
212
+ **Authentication** — An API key is required to start the server. Without it, the MCP server refuses to run.
213
+
214
+ **Authorization** — Macaroon-based scoping with 8 permission levels. Create restricted tokens for specific use cases (read-only, marketplace-only, spending-only).
215
+
216
+ **Spending Controls** — Configurable per-payment limits (default 10,000 sats), hourly caps (50,000 sats), daily caps (200,000 sats), and confirmation prompts for payments above a threshold.
217
+
218
+ **Rate Limiting** — Per-tool sliding window rate limits. Write operations are tightly limited (e.g., 5 skill registrations per 10 minutes). Read operations are generous (60/min).
219
+
220
+ **Anomaly Detection** — Runs after every payment and execution. Detects self-payment, rapid repeat transactions, structuring near limits, and volume spikes. Advisory mode: flags are logged but transactions aren't blocked.
221
+
222
+ **Rating Integrity** — Ratings require a payment preimage (SHA-256 proof of purchase). One rating per execution (enforced by unique constraint). 30-second minimum delay. Weighted averages discount repeat reviewers (1/n diminishing weight).
223
+
224
+ **Provider Verification** — Providers can prove identity via Lightning node signatures (`lncli signmessage`) or domain verification (`.well-known` URL). Verified skills display trust badges in marketplace listings.
225
+
226
+ ## Configuration
227
+
228
+ All settings via environment variables or `.env`:
229
+
230
+ ```bash
231
+ # API Key (required)
232
+ CONDUIT_API_KEY=your-secret-key
233
+
234
+ # LND Connection
235
+ LND_HOST=192.168.1.x
236
+ LND_GRPC_PORT=10009
237
+ LND_TLS_CERT_PATH=credentials/full-chain.pem
238
+ LND_MACAROON_PATH=credentials/admin.macaroon
239
+ LND_NETWORK=mainnet
240
+
241
+ # Database
242
+ DATABASE_URL=postgresql+asyncpg://conduit:conduit@localhost:5432/conduit
243
+
244
+ # Spending Limits (sats, 0 = no limit)
245
+ SPENDING_LIMIT_PER_PAYMENT_SATS=10000
246
+ SPENDING_LIMIT_HOURLY_SATS=50000
247
+ SPENDING_LIMIT_DAILY_SATS=200000
248
+ SPENDING_CONFIRM_ABOVE_SATS=5000
249
+
250
+ # Keep false for MCP servers (echo corrupts stdio transport)
251
+ DEBUG=false
252
+ ```
253
+
254
+ ## Project Structure
255
+
256
+ ```
257
+ src/conduit/
258
+ ├── mcp_server.py # MCP server entry point — 19 tools
259
+ ├── core/
260
+ │ ├── config.py # Settings from .env
261
+ │ └── database.py # Async SQLAlchemy + asyncpg
262
+ ├── models/
263
+ │ ├── skill.py # Skill marketplace listings
264
+ │ ├── execution.py # Skill execution tracking
265
+ │ ├── rating.py # Payment-proof-backed ratings
266
+ │ ├── spending_log.py # Spending audit trail
267
+ │ └── anomaly_flag.py # Suspicious pattern flags
268
+ ├── services/
269
+ │ ├── lnd.py # LND gRPC client (sign, verify, pay)
270
+ │ ├── spending_limiter.py # Payment limit enforcement
271
+ │ ├── macaroon_auth.py # Scoped authorization tokens
272
+ │ ├── rate_limiter.py # Sliding window rate limits
273
+ │ ├── anomaly_detector.py # Transaction pattern detection
274
+ │ ├── rating_integrity.py # Anti-gaming for ratings
275
+ │ ├── provider_verification.py # Node + domain verification
276
+ │ └── skill_executor.py # Webhook-based execution engine
277
+ └── alembic/ # Database migrations
278
+ ```
279
+
280
+ ## Roadmap
281
+
282
+ - [x] Lightning Network integration (LND gRPC)
283
+ - [x] MCP server with 19 tools
284
+ - [x] Skill marketplace (register, discover, execute, rate)
285
+ - [x] PostgreSQL persistence with Alembic migrations
286
+ - [x] Full security stack (auth, macaroons, limits, anomaly detection)
287
+ - [x] Provider verification (Lightning node + domain)
288
+ - [x] One-command install script
289
+ - [x] Nostr protocol for decentralized skill discovery (NIP-01/19/33)
290
+ - [x] Nostr Wallet Connect (NWC) with NIP-44 v2 encryption
291
+ - [x] REST API layer alongside MCP (27 endpoints, FastAPI)
292
+ - [ ] Multi-node federation
293
+ - [ ] Package for distribution (`pip install conduit-lightning`)
294
+
295
+ ## License
296
+
297
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,225 @@
1
+ # Conduit
2
+
3
+ **Lightning Payment Rails for AI Agents** | by [Lightning Linq](https://lightninglinq.com)
4
+
5
+ Conduit is a non-custodial payment infrastructure layer that lets AI agents transact over the Lightning Network. It exposes a skill marketplace and Lightning tools via the [Model Context Protocol (MCP)](https://modelcontextprotocol.io), enabling any MCP-compatible AI (like Claude) to discover, purchase, and rate agent-provided services -- all settled instantly in Bitcoin.
6
+
7
+ Conduit never takes custody of funds. Payments flow directly between agents on Lightning. Conduit provides coordination, discovery, reputation, and security -- never custody.
8
+
9
+ > Conduit is the first product from **Lightning Linq**, an open-source company building Lightning infrastructure for AI agents.
10
+
11
+ ## How It Works
12
+
13
+ ```
14
+ ┌──────────────────────────────────────────────────────────┐
15
+ │ Claude Desktop │
16
+ │ (or any MCP client) │
17
+ └──────────────┬───────────────────────────────────────────┘
18
+ │ MCP (stdio)
19
+
20
+ ┌──────────────────────────────────────────────────────────┐
21
+ │ Conduit MCP Server │
22
+ │ │
23
+ │ ┌─────────────┐ ┌──────────────┐ ┌─────────────────┐ │
24
+ │ │ Lightning │ │ Marketplace │ │ Security │ │
25
+ │ │ Tools │ │ Tools │ │ Layer │ │
26
+ │ │ │ │ │ │ │ │
27
+ │ │ • invoices │ │ • discover │ │ • API key auth │ │
28
+ │ │ • payments │ │ • register │ │ • macaroons │ │
29
+ │ │ • balance │ │ • execute │ │ • spending limits │ │
30
+ │ │ • decode │ │ • rate │ │ • rate limiting │ │
31
+ │ │ │ │ • verify │ │ • anomaly detect │ │
32
+ │ └──────┬──────┘ └──────┬───────┘ └─────────────────┘ │
33
+ │ │ │ │
34
+ └─────────┼────────────────┼────────────────────────────────┘
35
+ │ │
36
+ ▼ ▼
37
+ ┌──────────────┐ ┌──────────────┐
38
+ │ LND Node │ │ PostgreSQL │
39
+ │ (your node) │ │ (local DB) │
40
+ │ │ │ │
41
+ │ non-custodial │ skills, │
42
+ │ payments │ │ executions, │
43
+ │ │ │ ratings, │
44
+ │ │ │ audit logs │
45
+ └──────────────┘ └──────────────┘
46
+ ```
47
+
48
+ ## Features
49
+
50
+ **Lightning Network Integration** — Create and pay invoices via your own LND node. Decode payment requests, check payment status, view node info and channel balances. Non-custodial: your keys, your node, your sats.
51
+
52
+ **Skill Marketplace** — Register skills with pricing, categories, and input/output schemas. Discover skills by keyword, category, or price range. Request executions with automatic Lightning invoicing. Webhook-based execution engine with payment proof delivery. Rating system backed by cryptographic payment proofs.
53
+
54
+ **Security Stack** — API key authentication, scoped macaroon authorization (8 permissions, 4 profiles), per-payment/hourly/daily spending limits, in-memory sliding window rate limiting, anomaly detection (self-payment, rapid repeat, structuring, volume spike), rating integrity (preimage verification, duplicate prevention, weighted averages), and provider verification via Lightning node signatures and domain proof.
55
+
56
+ ## Quick Start
57
+
58
+ ```bash
59
+ git clone https://github.com/Lightning-Linq/conduit.git
60
+ cd conduit
61
+ chmod +x install.sh
62
+ ./install.sh
63
+ ```
64
+
65
+ The install script handles everything: checks prerequisites (Python 3.11+, PostgreSQL), creates virtual environment, installs dependencies, generates a secure API key, sets up the database, runs migrations, and shows you how to wire it into Claude Desktop.
66
+
67
+ ### Prerequisites
68
+
69
+ - **Python 3.11+** — `brew install python@3.11` or use pyenv
70
+ - **PostgreSQL 16** — `brew install postgresql@16 && brew services start postgresql@16`
71
+ - **LND node** — running and accessible (local, remote, or via Tor)
72
+
73
+ ### Claude Desktop Configuration
74
+
75
+ Add this to your `claude_desktop_config.json`:
76
+
77
+ ```json
78
+ {
79
+ "mcpServers": {
80
+ "conduit-lightning": {
81
+ "command": "/path/to/conduit/.venv/bin/python",
82
+ "args": ["-m", "conduit.mcp_server"],
83
+ "env": {
84
+ "PYTHONPATH": "/path/to/conduit/src"
85
+ }
86
+ }
87
+ }
88
+ }
89
+ ```
90
+
91
+ Restart Claude Desktop. Ask Claude: *"What's my Lightning node balance?"*
92
+
93
+ ## MCP Tools Reference
94
+
95
+ Conduit exposes 19 tools over the Model Context Protocol.
96
+
97
+ ### Lightning Tools
98
+
99
+ | Tool | Permission | Description |
100
+ |------|-----------|-------------|
101
+ | `get_node_info` | lightning:read | Node alias, pubkey, active channels, peers |
102
+ | `get_balance` | lightning:read | On-chain and channel balances |
103
+ | `create_invoice` | lightning:invoice | Generate a Lightning invoice |
104
+ | `pay_invoice` | lightning:pay | Pay a Lightning invoice (with spending limits) |
105
+ | `decode_invoice` | lightning:read | Decode a payment request without paying |
106
+ | `check_payment` | lightning:read | Check if a payment has settled |
107
+
108
+ ### Marketplace Tools
109
+
110
+ | Tool | Permission | Description |
111
+ |------|-----------|-------------|
112
+ | `discover_skills` | marketplace:read | Search skills by keyword, category, price |
113
+ | `get_skill_details` | marketplace:read | Full details including schemas and ratings |
114
+ | `register_skill` | marketplace:write | List a new skill on the marketplace |
115
+ | `request_skill_execution` | marketplace:execute | Request execution (generates invoice) |
116
+ | `confirm_skill_execution` | marketplace:execute | Confirm payment and trigger webhook |
117
+ | `submit_rating` | marketplace:execute | Rate a skill (requires payment proof) |
118
+
119
+ ### Verification Tools
120
+
121
+ | Tool | Permission | Description |
122
+ |------|-----------|-------------|
123
+ | `request_verification` | marketplace:write | Start node or domain verification |
124
+ | `submit_verification` | marketplace:write | Complete verification with proof |
125
+ | `get_verification_status` | marketplace:read | Check a skill's verification badges |
126
+
127
+ ### Security Tools
128
+
129
+ | Tool | Permission | Description |
130
+ |------|-----------|-------------|
131
+ | `get_spending_status` | security:read | Current spending vs. limits |
132
+ | `create_macaroon` | security:admin | Mint a scoped authorization token |
133
+ | `list_permissions` | security:read | Show active permissions |
134
+ | `get_anomaly_report` | security:read | View flagged suspicious patterns |
135
+
136
+ ## Security Model
137
+
138
+ Conduit uses defense-in-depth with multiple security layers.
139
+
140
+ **Authentication** — An API key is required to start the server. Without it, the MCP server refuses to run.
141
+
142
+ **Authorization** — Macaroon-based scoping with 8 permission levels. Create restricted tokens for specific use cases (read-only, marketplace-only, spending-only).
143
+
144
+ **Spending Controls** — Configurable per-payment limits (default 10,000 sats), hourly caps (50,000 sats), daily caps (200,000 sats), and confirmation prompts for payments above a threshold.
145
+
146
+ **Rate Limiting** — Per-tool sliding window rate limits. Write operations are tightly limited (e.g., 5 skill registrations per 10 minutes). Read operations are generous (60/min).
147
+
148
+ **Anomaly Detection** — Runs after every payment and execution. Detects self-payment, rapid repeat transactions, structuring near limits, and volume spikes. Advisory mode: flags are logged but transactions aren't blocked.
149
+
150
+ **Rating Integrity** — Ratings require a payment preimage (SHA-256 proof of purchase). One rating per execution (enforced by unique constraint). 30-second minimum delay. Weighted averages discount repeat reviewers (1/n diminishing weight).
151
+
152
+ **Provider Verification** — Providers can prove identity via Lightning node signatures (`lncli signmessage`) or domain verification (`.well-known` URL). Verified skills display trust badges in marketplace listings.
153
+
154
+ ## Configuration
155
+
156
+ All settings via environment variables or `.env`:
157
+
158
+ ```bash
159
+ # API Key (required)
160
+ CONDUIT_API_KEY=your-secret-key
161
+
162
+ # LND Connection
163
+ LND_HOST=192.168.1.x
164
+ LND_GRPC_PORT=10009
165
+ LND_TLS_CERT_PATH=credentials/full-chain.pem
166
+ LND_MACAROON_PATH=credentials/admin.macaroon
167
+ LND_NETWORK=mainnet
168
+
169
+ # Database
170
+ DATABASE_URL=postgresql+asyncpg://conduit:conduit@localhost:5432/conduit
171
+
172
+ # Spending Limits (sats, 0 = no limit)
173
+ SPENDING_LIMIT_PER_PAYMENT_SATS=10000
174
+ SPENDING_LIMIT_HOURLY_SATS=50000
175
+ SPENDING_LIMIT_DAILY_SATS=200000
176
+ SPENDING_CONFIRM_ABOVE_SATS=5000
177
+
178
+ # Keep false for MCP servers (echo corrupts stdio transport)
179
+ DEBUG=false
180
+ ```
181
+
182
+ ## Project Structure
183
+
184
+ ```
185
+ src/conduit/
186
+ ├── mcp_server.py # MCP server entry point — 19 tools
187
+ ├── core/
188
+ │ ├── config.py # Settings from .env
189
+ │ └── database.py # Async SQLAlchemy + asyncpg
190
+ ├── models/
191
+ │ ├── skill.py # Skill marketplace listings
192
+ │ ├── execution.py # Skill execution tracking
193
+ │ ├── rating.py # Payment-proof-backed ratings
194
+ │ ├── spending_log.py # Spending audit trail
195
+ │ └── anomaly_flag.py # Suspicious pattern flags
196
+ ├── services/
197
+ │ ├── lnd.py # LND gRPC client (sign, verify, pay)
198
+ │ ├── spending_limiter.py # Payment limit enforcement
199
+ │ ├── macaroon_auth.py # Scoped authorization tokens
200
+ │ ├── rate_limiter.py # Sliding window rate limits
201
+ │ ├── anomaly_detector.py # Transaction pattern detection
202
+ │ ├── rating_integrity.py # Anti-gaming for ratings
203
+ │ ├── provider_verification.py # Node + domain verification
204
+ │ └── skill_executor.py # Webhook-based execution engine
205
+ └── alembic/ # Database migrations
206
+ ```
207
+
208
+ ## Roadmap
209
+
210
+ - [x] Lightning Network integration (LND gRPC)
211
+ - [x] MCP server with 19 tools
212
+ - [x] Skill marketplace (register, discover, execute, rate)
213
+ - [x] PostgreSQL persistence with Alembic migrations
214
+ - [x] Full security stack (auth, macaroons, limits, anomaly detection)
215
+ - [x] Provider verification (Lightning node + domain)
216
+ - [x] One-command install script
217
+ - [x] Nostr protocol for decentralized skill discovery (NIP-01/19/33)
218
+ - [x] Nostr Wallet Connect (NWC) with NIP-44 v2 encryption
219
+ - [x] REST API layer alongside MCP (27 endpoints, FastAPI)
220
+ - [ ] Multi-node federation
221
+ - [ ] Package for distribution (`pip install conduit-lightning`)
222
+
223
+ ## License
224
+
225
+ MIT — see [LICENSE](LICENSE).