@lightninglabs/lightning-mcp-server 0.2.0
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.
- package/.claude-plugin/marketplace.json +36 -0
- package/.claude-plugin/plugin.json +12 -0
- package/README.md +307 -0
- package/bin/lightning-mcp-server +15 -0
- package/docs/architecture.md +455 -0
- package/docs/commerce.md +357 -0
- package/docs/l402-and-lnget.md +267 -0
- package/docs/mcp-server.md +285 -0
- package/docs/quickref.md +263 -0
- package/docs/security.md +298 -0
- package/docs/two-agent-setup.md +394 -0
- package/package.json +52 -0
- package/postinstall.js +160 -0
- package/skills/aperture/SKILL.md +330 -0
- package/skills/aperture/scripts/install.sh +68 -0
- package/skills/aperture/scripts/setup.sh +155 -0
- package/skills/aperture/scripts/start.sh +81 -0
- package/skills/aperture/scripts/stop.sh +57 -0
- package/skills/aperture/templates/aperture-regtest.yaml +36 -0
- package/skills/aperture/templates/aperture.yaml.template +64 -0
- package/skills/aperture/templates/docker-compose-aperture.yml +59 -0
- package/skills/commerce/SKILL.md +211 -0
- package/skills/lib/config-gen.sh +127 -0
- package/skills/lib/rest.sh +69 -0
- package/skills/lightning-security-module/SKILL.md +253 -0
- package/skills/lightning-security-module/references/architecture.md +133 -0
- package/skills/lightning-security-module/scripts/docker-start.sh +117 -0
- package/skills/lightning-security-module/scripts/docker-stop.sh +53 -0
- package/skills/lightning-security-module/scripts/export-credentials.sh +268 -0
- package/skills/lightning-security-module/scripts/install.sh +178 -0
- package/skills/lightning-security-module/scripts/setup-signer.sh +307 -0
- package/skills/lightning-security-module/scripts/start-signer.sh +152 -0
- package/skills/lightning-security-module/scripts/stop-signer.sh +240 -0
- package/skills/lightning-security-module/templates/docker-compose-signer.yml +35 -0
- package/skills/lightning-security-module/templates/signer-lnd.conf.template +69 -0
- package/skills/lnd/SKILL.md +441 -0
- package/skills/lnd/profiles/debug.env +4 -0
- package/skills/lnd/profiles/default.env +3 -0
- package/skills/lnd/profiles/regtest.env +4 -0
- package/skills/lnd/profiles/taproot.env +3 -0
- package/skills/lnd/profiles/wumbo.env +3 -0
- package/skills/lnd/references/security.md +156 -0
- package/skills/lnd/scripts/create-wallet.sh +464 -0
- package/skills/lnd/scripts/docker-start.sh +256 -0
- package/skills/lnd/scripts/docker-stop.sh +109 -0
- package/skills/lnd/scripts/import-credentials.sh +145 -0
- package/skills/lnd/scripts/install.sh +195 -0
- package/skills/lnd/scripts/lncli.sh +150 -0
- package/skills/lnd/scripts/start-lnd.sh +241 -0
- package/skills/lnd/scripts/stop-lnd.sh +218 -0
- package/skills/lnd/scripts/unlock-wallet.sh +134 -0
- package/skills/lnd/templates/docker-compose-regtest.yml +122 -0
- package/skills/lnd/templates/docker-compose-watchonly.yml +71 -0
- package/skills/lnd/templates/docker-compose.yml +49 -0
- package/skills/lnd/templates/litd-regtest.conf.template +61 -0
- package/skills/lnd/templates/litd-watchonly.conf.template +57 -0
- package/skills/lnd/templates/litd.conf.template +88 -0
- package/skills/lnd/templates/lnd.conf.template +91 -0
- package/skills/lnget/SKILL.md +288 -0
- package/skills/lnget/scripts/install.sh +69 -0
- package/skills/macaroon-bakery/SKILL.md +179 -0
- package/skills/macaroon-bakery/scripts/bake.sh +337 -0
- package/skills/mcp-lnc/SKILL.md +280 -0
- package/skills/mcp-lnc/scripts/configure.sh +130 -0
- package/skills/mcp-lnc/scripts/install.sh +103 -0
- package/skills/mcp-lnc/scripts/setup-claude-config.sh +162 -0
- package/skills/mcp-lnc/templates/env.template +16 -0
- package/versions.env +23 -0
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: lnget
|
|
3
|
+
description: Install and use lnget, a Lightning-native HTTP client with automatic L402 payment support. Use when downloading files behind Lightning paywalls, managing L402 tokens, checking Lightning backend status, or making HTTP requests that may require micropayments.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# lnget - Lightning-Native HTTP Client
|
|
7
|
+
|
|
8
|
+
lnget is a wget/curl-like CLI that natively handles L402 (Lightning HTTP 402)
|
|
9
|
+
authentication. When a server responds with HTTP 402 and an L402 challenge,
|
|
10
|
+
lnget automatically pays the Lightning invoice and retries with the paid token.
|
|
11
|
+
|
|
12
|
+
**Source:** `github.com/lightninglabs/lnget`
|
|
13
|
+
|
|
14
|
+
## Quick Start
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
# 1. Install lnget
|
|
18
|
+
skills/lnget/scripts/install.sh
|
|
19
|
+
|
|
20
|
+
# 2. Initialize config (auto-detects local lnd)
|
|
21
|
+
lnget config init
|
|
22
|
+
|
|
23
|
+
# 3. Fetch an L402-protected resource
|
|
24
|
+
lnget --max-cost 1000 https://api.example.com/paid-data
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Installation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
skills/lnget/scripts/install.sh
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
This will:
|
|
34
|
+
- Verify Go is installed
|
|
35
|
+
- Run `go install github.com/lightninglabs/lnget/cmd/lnget@latest`
|
|
36
|
+
- Verify `lnget` is on `$PATH`
|
|
37
|
+
|
|
38
|
+
To install manually:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
go install github.com/lightninglabs/lnget/cmd/lnget@latest
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Or build from source:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
git clone https://github.com/lightninglabs/lnget.git
|
|
48
|
+
cd lnget
|
|
49
|
+
make install
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Basic Usage
|
|
53
|
+
|
|
54
|
+
### Downloads
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
# Fetch URL (output to stdout)
|
|
58
|
+
lnget https://api.example.com/data.json
|
|
59
|
+
|
|
60
|
+
# Save to file
|
|
61
|
+
lnget -o data.json https://api.example.com/data.json
|
|
62
|
+
|
|
63
|
+
# Quiet mode for piping
|
|
64
|
+
lnget -q https://api.example.com/data.json | jq .
|
|
65
|
+
|
|
66
|
+
# Resume partial download
|
|
67
|
+
lnget -c -o largefile.zip https://api.example.com/largefile.zip
|
|
68
|
+
|
|
69
|
+
# Custom HTTP method with data
|
|
70
|
+
lnget -X POST -d '{"query":"test"}' https://api.example.com/search
|
|
71
|
+
|
|
72
|
+
# Custom headers
|
|
73
|
+
lnget -H "Accept: text/plain" https://api.example.com/data
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### Payment Control
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
# Set maximum auto-pay amount (satoshis)
|
|
80
|
+
lnget --max-cost 5000 https://api.example.com/expensive.json
|
|
81
|
+
|
|
82
|
+
# Set maximum routing fee
|
|
83
|
+
lnget --max-fee 50 https://api.example.com/data.json
|
|
84
|
+
|
|
85
|
+
# Preview without paying (shows 402 challenge details)
|
|
86
|
+
lnget --no-pay https://api.example.com/data.json
|
|
87
|
+
|
|
88
|
+
# Custom payment timeout
|
|
89
|
+
lnget --payment-timeout 120s https://api.example.com/data.json
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Output Modes
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
# JSON output (default, best for programmatic use)
|
|
96
|
+
lnget --json https://api.example.com/data.json
|
|
97
|
+
|
|
98
|
+
# Human-readable output
|
|
99
|
+
lnget --human https://api.example.com/data.json
|
|
100
|
+
|
|
101
|
+
# Verbose mode (shows L402 flow details)
|
|
102
|
+
lnget -v https://api.example.com/data.json
|
|
103
|
+
|
|
104
|
+
# Disable progress bar
|
|
105
|
+
lnget --no-progress -o file.zip https://api.example.com/file.zip
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Subcommands
|
|
109
|
+
|
|
110
|
+
### Token Management (`lnget tokens`)
|
|
111
|
+
|
|
112
|
+
Tokens are cached per-domain at `~/.lnget/tokens/<domain>/token.json` and
|
|
113
|
+
reused automatically on subsequent requests.
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
# List all cached tokens
|
|
117
|
+
lnget tokens list
|
|
118
|
+
|
|
119
|
+
# Show token for a specific domain
|
|
120
|
+
lnget tokens show api.example.com
|
|
121
|
+
|
|
122
|
+
# Remove token for a domain (forces re-authentication)
|
|
123
|
+
lnget tokens remove api.example.com
|
|
124
|
+
|
|
125
|
+
# Clear all tokens
|
|
126
|
+
lnget tokens clear --force
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### Configuration (`lnget config`)
|
|
130
|
+
|
|
131
|
+
```bash
|
|
132
|
+
# Initialize config file at ~/.lnget/config.yaml
|
|
133
|
+
lnget config init
|
|
134
|
+
|
|
135
|
+
# Show current configuration
|
|
136
|
+
lnget config show
|
|
137
|
+
|
|
138
|
+
# Show config file path
|
|
139
|
+
lnget config path
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
### Lightning Backend (`lnget ln`)
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
# Check backend connection status
|
|
146
|
+
lnget ln status
|
|
147
|
+
|
|
148
|
+
# Show detailed node info
|
|
149
|
+
lnget ln info
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
#### LNC (Lightning Node Connect)
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
# Pair with a node via LNC pairing phrase
|
|
156
|
+
lnget ln lnc pair "your-pairing-phrase"
|
|
157
|
+
|
|
158
|
+
# Ephemeral pairing (no session persistence)
|
|
159
|
+
lnget ln lnc pair "phrase" --ephemeral
|
|
160
|
+
|
|
161
|
+
# List saved LNC sessions
|
|
162
|
+
lnget ln lnc sessions
|
|
163
|
+
|
|
164
|
+
# Revoke a session
|
|
165
|
+
lnget ln lnc revoke <session-id>
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
#### Neutrino (Embedded Wallet)
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
# Initialize embedded neutrino wallet
|
|
172
|
+
lnget ln neutrino init
|
|
173
|
+
|
|
174
|
+
# Get address to fund wallet
|
|
175
|
+
lnget ln neutrino fund
|
|
176
|
+
|
|
177
|
+
# Check wallet balance
|
|
178
|
+
lnget ln neutrino balance
|
|
179
|
+
|
|
180
|
+
# Show sync status
|
|
181
|
+
lnget ln neutrino status
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
## Configuration File
|
|
185
|
+
|
|
186
|
+
Config lives at `~/.lnget/config.yaml`. Run `lnget config init` to create it.
|
|
187
|
+
|
|
188
|
+
```yaml
|
|
189
|
+
l402:
|
|
190
|
+
max_cost_sats: 1000 # Max invoice to auto-pay
|
|
191
|
+
max_fee_sats: 10 # Max routing fee
|
|
192
|
+
payment_timeout: 60s # Payment timeout
|
|
193
|
+
auto_pay: true # Enable auto-payment
|
|
194
|
+
|
|
195
|
+
http:
|
|
196
|
+
timeout: 30s
|
|
197
|
+
max_redirects: 10
|
|
198
|
+
user_agent: "lnget/0.1.0"
|
|
199
|
+
allow_insecure: false
|
|
200
|
+
|
|
201
|
+
ln:
|
|
202
|
+
mode: lnd # Options: lnd, lnc, neutrino
|
|
203
|
+
lnd:
|
|
204
|
+
host: localhost:10009
|
|
205
|
+
tls_cert: ~/.lnd/tls.cert
|
|
206
|
+
macaroon: ~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
|
|
207
|
+
network: mainnet
|
|
208
|
+
|
|
209
|
+
output:
|
|
210
|
+
format: json
|
|
211
|
+
progress: true
|
|
212
|
+
verbose: false
|
|
213
|
+
|
|
214
|
+
tokens:
|
|
215
|
+
dir: ~/.lnget/tokens
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
Environment variables override config with `LNGET_` prefix:
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
export LNGET_L402_MAX_COST_SATS=5000
|
|
222
|
+
export LNGET_LN_MODE=lnc
|
|
223
|
+
export LNGET_LN_LND_HOST=localhost:10009
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
## Exit Codes
|
|
227
|
+
|
|
228
|
+
| Code | Meaning |
|
|
229
|
+
|------|---------|
|
|
230
|
+
| 0 | Success |
|
|
231
|
+
| 1 | General error |
|
|
232
|
+
| 2 | Payment exceeds max cost |
|
|
233
|
+
| 3 | Payment failed |
|
|
234
|
+
| 4 | Network/connection error |
|
|
235
|
+
|
|
236
|
+
## L402 Flow
|
|
237
|
+
|
|
238
|
+
When lnget encounters a 402 response:
|
|
239
|
+
|
|
240
|
+
1. Parses `WWW-Authenticate: L402 macaroon="...", invoice="..."` header
|
|
241
|
+
2. Decodes the macaroon and BOLT11 invoice
|
|
242
|
+
3. Checks invoice amount against `--max-cost`
|
|
243
|
+
4. Stores a pending token (crash recovery)
|
|
244
|
+
5. Pays the invoice via the configured Lightning backend
|
|
245
|
+
6. Stores the paid token with preimage at `~/.lnget/tokens/<domain>/`
|
|
246
|
+
7. Retries the request with `Authorization: L402 <macaroon>:<preimage>`
|
|
247
|
+
|
|
248
|
+
Subsequent requests to the same domain reuse the cached token without payment.
|
|
249
|
+
|
|
250
|
+
## Agent Integration Patterns
|
|
251
|
+
|
|
252
|
+
### Budget-Aware Fetching
|
|
253
|
+
|
|
254
|
+
```bash
|
|
255
|
+
# Check cost before committing
|
|
256
|
+
result=$(lnget --no-pay --json https://api.example.com/data.json)
|
|
257
|
+
cost=$(echo "$result" | jq -r '.invoice_amount_sat // 0')
|
|
258
|
+
|
|
259
|
+
if [ "$cost" -le "$BUDGET" ]; then
|
|
260
|
+
lnget --max-cost "$BUDGET" -q https://api.example.com/data.json
|
|
261
|
+
fi
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Parsing JSON Output
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
# Extract just the response body
|
|
268
|
+
lnget --json -q https://api.example.com/data.json | jq '.body'
|
|
269
|
+
|
|
270
|
+
# Check if payment was required
|
|
271
|
+
lnget --json https://api.example.com/data.json | jq '.l402_paid'
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Testing with Insecure Connections
|
|
275
|
+
|
|
276
|
+
```bash
|
|
277
|
+
# For local development with aperture (no TLS)
|
|
278
|
+
lnget -k https://localhost:8081/api/data
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
## File Locations
|
|
282
|
+
|
|
283
|
+
| Path | Purpose |
|
|
284
|
+
|------|---------|
|
|
285
|
+
| `~/.lnget/config.yaml` | Configuration file |
|
|
286
|
+
| `~/.lnget/tokens/<domain>/` | Per-domain token storage |
|
|
287
|
+
| `~/.lnget/lnc/sessions/` | LNC session persistence |
|
|
288
|
+
| `~/.lnget/neutrino/` | Embedded wallet data |
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Install lnget from source.
|
|
3
|
+
#
|
|
4
|
+
# Usage:
|
|
5
|
+
# install.sh # Install latest
|
|
6
|
+
# install.sh --version v0.1.0 # Specific version
|
|
7
|
+
|
|
8
|
+
set -e
|
|
9
|
+
|
|
10
|
+
VERSION=""
|
|
11
|
+
|
|
12
|
+
# Parse arguments.
|
|
13
|
+
while [[ $# -gt 0 ]]; do
|
|
14
|
+
case $1 in
|
|
15
|
+
--version)
|
|
16
|
+
VERSION="@$2"
|
|
17
|
+
shift 2
|
|
18
|
+
;;
|
|
19
|
+
-h|--help)
|
|
20
|
+
echo "Usage: install.sh [--version VERSION]"
|
|
21
|
+
echo ""
|
|
22
|
+
echo "Install lnget Lightning-native HTTP client."
|
|
23
|
+
echo ""
|
|
24
|
+
echo "Options:"
|
|
25
|
+
echo " --version VERSION Go module version"
|
|
26
|
+
exit 0
|
|
27
|
+
;;
|
|
28
|
+
*)
|
|
29
|
+
echo "Unknown option: $1" >&2
|
|
30
|
+
exit 1
|
|
31
|
+
;;
|
|
32
|
+
esac
|
|
33
|
+
done
|
|
34
|
+
|
|
35
|
+
echo "=== Installing lnget ==="
|
|
36
|
+
echo ""
|
|
37
|
+
|
|
38
|
+
# Verify Go is installed.
|
|
39
|
+
if ! command -v go &>/dev/null; then
|
|
40
|
+
echo "Error: Go is not installed." >&2
|
|
41
|
+
echo "Install Go from https://go.dev/dl/" >&2
|
|
42
|
+
exit 1
|
|
43
|
+
fi
|
|
44
|
+
|
|
45
|
+
echo "Go version: $(go version | grep -oE 'go[0-9]+\.[0-9]+')"
|
|
46
|
+
echo ""
|
|
47
|
+
|
|
48
|
+
# Install lnget.
|
|
49
|
+
echo "Installing lnget..."
|
|
50
|
+
go install "github.com/lightninglabs/lnget/cmd/lnget${VERSION}"
|
|
51
|
+
echo "Done."
|
|
52
|
+
echo ""
|
|
53
|
+
|
|
54
|
+
# Verify installation.
|
|
55
|
+
if command -v lnget &>/dev/null; then
|
|
56
|
+
echo "lnget installed: $(which lnget)"
|
|
57
|
+
else
|
|
58
|
+
echo "Warning: lnget not found on PATH." >&2
|
|
59
|
+
echo "Ensure \$GOPATH/bin is in your PATH." >&2
|
|
60
|
+
echo " export PATH=\$PATH:\$(go env GOPATH)/bin" >&2
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
echo ""
|
|
64
|
+
echo "Installation complete."
|
|
65
|
+
echo ""
|
|
66
|
+
echo "Next steps:"
|
|
67
|
+
echo " 1. Initialize config: lnget config init"
|
|
68
|
+
echo " 2. Check LN status: lnget ln status"
|
|
69
|
+
echo " 3. Fetch a URL: lnget https://example.com"
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: macaroon-bakery
|
|
3
|
+
description: Bake, inspect, and manage lnd macaroons for least-privilege agent access. Use when an agent needs scoped credentials — pay-only, invoice-only, read-only, or custom permissions. Also covers signer macaroon scoping and macaroon rotation.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Macaroon Bakery
|
|
7
|
+
|
|
8
|
+
Bake custom lnd macaroons so every agent gets only the permissions it needs.
|
|
9
|
+
Never hand out `admin.macaroon` in production — bake a scoped one instead.
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Bake a pay-only macaroon
|
|
15
|
+
skills/macaroon-bakery/scripts/bake.sh --role pay-only
|
|
16
|
+
|
|
17
|
+
# Bake an invoice-only macaroon
|
|
18
|
+
skills/macaroon-bakery/scripts/bake.sh --role invoice-only
|
|
19
|
+
|
|
20
|
+
# Bake a read-only macaroon
|
|
21
|
+
skills/macaroon-bakery/scripts/bake.sh --role read-only
|
|
22
|
+
|
|
23
|
+
# Inspect any macaroon
|
|
24
|
+
skills/macaroon-bakery/scripts/bake.sh --inspect ~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
|
|
25
|
+
|
|
26
|
+
# List all available lnd permissions
|
|
27
|
+
skills/macaroon-bakery/scripts/bake.sh --list-permissions
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Docker
|
|
31
|
+
|
|
32
|
+
The litd container is auto-detected. You can also specify `--container`:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Auto-detect litd container (default)
|
|
36
|
+
skills/macaroon-bakery/scripts/bake.sh --role pay-only
|
|
37
|
+
|
|
38
|
+
# Explicit container
|
|
39
|
+
skills/macaroon-bakery/scripts/bake.sh --role pay-only --container litd
|
|
40
|
+
|
|
41
|
+
# Inspect a macaroon inside a container
|
|
42
|
+
skills/macaroon-bakery/scripts/bake.sh --inspect /root/.lnd/data/chain/bitcoin/testnet/admin.macaroon --container litd
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Remote Nodes
|
|
46
|
+
|
|
47
|
+
To bake macaroons on a remote lnd node, provide the connection credentials:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Bake a pay-only macaroon on a remote node
|
|
51
|
+
skills/macaroon-bakery/scripts/bake.sh --role pay-only \
|
|
52
|
+
--rpcserver remote-host:10009 \
|
|
53
|
+
--tlscertpath ~/remote-tls.cert \
|
|
54
|
+
--macaroonpath ~/remote-admin.macaroon \
|
|
55
|
+
--save-to ~/remote-pay-only.macaroon
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
You need lncli installed locally and copies of the node's TLS cert and a macaroon
|
|
59
|
+
with `macaroon:generate` permission (typically admin.macaroon).
|
|
60
|
+
|
|
61
|
+
## Preset Roles
|
|
62
|
+
|
|
63
|
+
| Role | What the agent can do | Cannot do |
|
|
64
|
+
|------|----------------------|-----------|
|
|
65
|
+
| `pay-only` | Pay invoices, decode invoices, get node info | Create invoices, open channels, see balances |
|
|
66
|
+
| `invoice-only` | Create invoices, lookup invoices, get node info | Pay, open channels, see wallet balance |
|
|
67
|
+
| `read-only` | Get info, balances, list channels/peers/payments | Pay, create invoices, open/close channels |
|
|
68
|
+
| `channel-admin` | All of read-only + open/close channels, connect peers | Pay invoices, create invoices |
|
|
69
|
+
| `signer-only` | Sign transactions, derive keys (for remote signer) | Everything else |
|
|
70
|
+
|
|
71
|
+
## Baking Custom Macaroons
|
|
72
|
+
|
|
73
|
+
For permissions not covered by presets, bake a custom macaroon:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
# Custom: agent can only pay and check wallet balance
|
|
77
|
+
skills/macaroon-bakery/scripts/bake.sh --custom \
|
|
78
|
+
uri:/lnrpc.Lightning/SendPaymentSync \
|
|
79
|
+
uri:/lnrpc.Lightning/DecodePayReq \
|
|
80
|
+
uri:/lnrpc.Lightning/WalletBalance \
|
|
81
|
+
uri:/lnrpc.Lightning/GetInfo
|
|
82
|
+
|
|
83
|
+
# Custom with explicit output path
|
|
84
|
+
skills/macaroon-bakery/scripts/bake.sh --custom \
|
|
85
|
+
uri:/lnrpc.Lightning/AddInvoice \
|
|
86
|
+
uri:/lnrpc.Lightning/GetInfo \
|
|
87
|
+
--save-to ~/my-agent.macaroon
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Discovering Permissions
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
# List all available URI permissions
|
|
94
|
+
skills/macaroon-bakery/scripts/bake.sh --list-permissions
|
|
95
|
+
|
|
96
|
+
# Filter for specific service
|
|
97
|
+
skills/macaroon-bakery/scripts/bake.sh --list-permissions | grep -i invoice
|
|
98
|
+
|
|
99
|
+
# Filter for routing-related permissions
|
|
100
|
+
skills/macaroon-bakery/scripts/bake.sh --list-permissions | grep -i router
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
## Inspecting Macaroons
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
# See what permissions a macaroon has
|
|
107
|
+
skills/macaroon-bakery/scripts/bake.sh --inspect <path-to-macaroon>
|
|
108
|
+
|
|
109
|
+
# Inspect the admin macaroon to see full permissions
|
|
110
|
+
skills/macaroon-bakery/scripts/bake.sh --inspect ~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Signer Macaroon Scoping
|
|
114
|
+
|
|
115
|
+
When using the `lightning-security-module` skill, the credentials bundle includes
|
|
116
|
+
`admin.macaroon` by default. For production, bake a signing-only macaroon on the
|
|
117
|
+
signer machine:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
# On the signer container
|
|
121
|
+
skills/macaroon-bakery/scripts/bake.sh --role signer-only \
|
|
122
|
+
--container litd-signer --rpc-port 10012
|
|
123
|
+
|
|
124
|
+
# Or on a native signer
|
|
125
|
+
skills/macaroon-bakery/scripts/bake.sh --role signer-only \
|
|
126
|
+
--rpc-port 10012 --lnddir ~/.lnd-signer
|
|
127
|
+
|
|
128
|
+
# Then re-export the credentials bundle with the scoped macaroon
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Macaroon Rotation
|
|
132
|
+
|
|
133
|
+
Rotate macaroons regularly to limit the window if one is compromised:
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
# 1. Bake a new macaroon with the same role
|
|
137
|
+
skills/macaroon-bakery/scripts/bake.sh --role pay-only --save-to ~/pay-only-v2.macaroon
|
|
138
|
+
|
|
139
|
+
# 2. Update your agent config to use the new macaroon
|
|
140
|
+
|
|
141
|
+
# 3. Delete the old macaroon's root key (invalidates it)
|
|
142
|
+
skills/lnd/scripts/lncli.sh bakemacaroon --root_key_id 0
|
|
143
|
+
# Note: use lncli listmacaroonids and deletemacaroonid for fine-grained control
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
## Best Practices
|
|
147
|
+
|
|
148
|
+
- **One macaroon per agent role.** Don't share macaroons between agents with
|
|
149
|
+
different responsibilities.
|
|
150
|
+
- **Never use admin.macaroon in production.** It's the master key.
|
|
151
|
+
- **Inspect before deploying.** Always verify what a baked macaroon can do.
|
|
152
|
+
- **Rotate on a schedule.** Monthly for production, immediately if compromised.
|
|
153
|
+
- **Scope signer macaroons too.** The remote signer's credentials bundle should
|
|
154
|
+
use `signer-only`, not `admin`.
|
|
155
|
+
- **Store with 0600 permissions.** Macaroons are bearer tokens — treat like passwords.
|
|
156
|
+
|
|
157
|
+
## Common Permission URIs
|
|
158
|
+
|
|
159
|
+
| Permission | Description |
|
|
160
|
+
|-----------|-------------|
|
|
161
|
+
| `uri:/lnrpc.Lightning/GetInfo` | Node info (version, pubkey, sync status) |
|
|
162
|
+
| `uri:/lnrpc.Lightning/WalletBalance` | On-chain wallet balance |
|
|
163
|
+
| `uri:/lnrpc.Lightning/ChannelBalance` | Lightning channel balance |
|
|
164
|
+
| `uri:/lnrpc.Lightning/ListChannels` | List open channels |
|
|
165
|
+
| `uri:/lnrpc.Lightning/ListPeers` | List connected peers |
|
|
166
|
+
| `uri:/lnrpc.Lightning/SendPaymentSync` | Pay a Lightning invoice |
|
|
167
|
+
| `uri:/lnrpc.Lightning/DecodePayReq` | Decode a BOLT11 invoice |
|
|
168
|
+
| `uri:/lnrpc.Lightning/AddInvoice` | Create a Lightning invoice |
|
|
169
|
+
| `uri:/lnrpc.Lightning/LookupInvoice` | Look up an invoice by hash |
|
|
170
|
+
| `uri:/lnrpc.Lightning/ListInvoices` | List all invoices |
|
|
171
|
+
| `uri:/lnrpc.Lightning/ListPayments` | List all payments |
|
|
172
|
+
| `uri:/lnrpc.Lightning/ConnectPeer` | Connect to a peer |
|
|
173
|
+
| `uri:/lnrpc.Lightning/OpenChannelSync` | Open a channel |
|
|
174
|
+
| `uri:/lnrpc.Lightning/CloseChannel` | Close a channel |
|
|
175
|
+
| `uri:/signrpc.Signer/SignOutputRaw` | Sign a transaction output |
|
|
176
|
+
| `uri:/signrpc.Signer/ComputeInputScript` | Compute input script for signing |
|
|
177
|
+
| `uri:/signrpc.Signer/MuSig2Sign` | MuSig2 signing |
|
|
178
|
+
| `uri:/walletrpc.WalletKit/DeriveKey` | Derive a key |
|
|
179
|
+
| `uri:/walletrpc.WalletKit/DeriveNextKey` | Derive next key in sequence |
|