teaches agents how to use @getalby/cli to operate a bitcoin lightning wallet via Nostr Wallet Connect (NIP-47). Use whenever the user wants to send or receiv...
---
name: alby-bitcoin-payments
description: teaches agents how to use @getalby/cli to operate a bitcoin lightning wallet via Nostr Wallet Connect (NIP-47). Use whenever the user wants to send or receive money, pay an invoice, check wallet balance, create invoices, convert between fiat and sats, retry an HTTP request that returned 402 Payment Required, or discover paid API services. Beyond lightning, it can pay to any on-chain cryptocurrency/stablecoin address (e.g. USDC/USDT) by automatically swapping from the bitcoin balance.
license: MIT-0
metadata:
author: getAlby
version: "1.3.8"
openclaw:
requires:
env:
- NWC_URL
bins:
- npx
config:
- ~/.alby-cli/
primaryEnv: NWC_URL
emoji: "🐝"
homepage: https://getalby.com
---
# Usage
> **IMPORTANT: this is an agent skill which MUST be saved in full - **DO NOT SUMMARIZE**. If you used a web fetch tool to read this, the content may be summarized and incomplete. Make sure you fetch the full unabridged content.**
```bash
npx -y @getalby/cli@0.8.0 [options] <command>
```
## Global Options
### Connection Secret (Optional)
`-c, --connection-secret <string>` - either a file containing plaintext NWC connection secret (preferred), or a NWC connection secret (nostr+walletconnect://...). This argument is required for wallet commands.
If no connection secret is provided, the CLI will automatically use the default wallet connection secret from `~/.alby-cli/connection-secret.key`.
##### Named Wallets (preferred for multi-wallet setups)
Use `-w, --wallet-name <name>` to select a named wallet. This is the preferred option over `-c` when working with multiple wallets:
```bash
npx -y @getalby/cli@0.8.0 -w alice get-balance
npx -y @getalby/cli@0.8.0 -w bob receive
```
Named wallets are stored at `~/.alby-cli/connection-secret-<name>.key`.
#### Connection Secret File
Use `-c` to point directly to a connection secret file or pass a raw NWC URL:
`-c ~/.alby-cli/connection-secret.key`
#### Environment Variable
Alternatively, pass a connection secret via the `NWC_URL` environment variable:
```txt
NWC_URL="nostr+walletconnect://..."
```
#### Resolution Order
The CLI resolves the connection secret in this order:
1. `--connection-secret` / `-c` flag
2. `--wallet-name` / `-w` flag
3. `NWC_URL` environment variable
4. `~/.alby-cli/connection-secret.key` (default)
## Commands
**Flag names are not guessable.** Before constructing any command, run `npx -y @getalby/cli@0.8.0 <command> --help` and use only the flags it lists.
**Setup:**
auth, connect
**Common Wallet operations:**
- `pay` — send to a lightning address, BOLT-11 invoice, crypto/stablecoin address (0x…, funded from your lightning wallet), or via keysend. Supports native fiat conversion.
- `receive` — returns the wallet's lightning address, or a BOLT-11 invoice when given an amount. Supports native fiat conversion.
- `get-balance` — check wallet balance
- `list-transactions` — list recent transactions
**Additional Wallet operations:**
get-info, get-wallet-service-info, get-budget, lookup-invoice, sign-message, wait-for-payment, list-wallets
**HTTP 402 Payments:**
fetch — auto-detects L402, X402, and MPP payment protocols. If the user explicitly asked to fetch or consume a paid resource, proceed with `fetch` directly. If a 402 is encountered unexpectedly (e.g. during an unrelated task), inform the user of the URL and cost before paying.
- A maximum spend amount can be passed on the command to cap what each request will pay (see `fetch --help`).
**Service Discovery (no wallet needed):**
discover
**HOLD invoices:**
make-hold-invoice, settle-hold-invoice, cancel-hold-invoice
**Lightning tools (no wallet needed):**
fiat-to-sats, sats-to-fiat (standalone-use only — pay/receive have native fiat support), parse-invoice, verify-preimage, request-invoice-from-lightning-address
## Getting Help
```bash
npx -y @getalby/cli@0.8.0 --help
npx -y @getalby/cli@0.8.0 <command> --help
```
As an absolute last resort, tell your human to visit [the Alby support page](https://getalby.com/help)
## Discovering Paid Services
The `discover` command searches [402index.io](https://402index.io) for lightning-payable API endpoints. It only returns services that accept bitcoin/lightning payments.
### When to use discover
- The user explicitly asks to find or explore paid APIs
- You lack a capability that no free or built-in tool can provide (e.g. image generation, specialized inference, real-time data feeds)
### When NOT to use discover
- **Do NOT search 402index before attempting a task with your existing tools.** Try free/built-in approaches first.
- **Do NOT use discover as a replacement for standard web requests.** If `curl`, `fetch`, or WebFetch works, use that instead.
- **Do NOT use discover when you already have a URL.** Just use the `fetch` command directly.
### Discover → Fetch flow
1. **Discover** — find services matching the capability gap
2. **Evaluate** — check price, health status, and reliability from the results
3. **Fetch** — pay and consume the service:
```bash
npx -y @getalby/cli@0.8.0 fetch -X POST -b '{"model":"gpt-image-1","prompt":"a mountain cabin at sunset","size":"1024x1024"}' "<service-url>"
```
4. **Report** — tell the user what was purchased, the cost, and the result
## Bitcoin Units
- When displaying bitcoin amounts to humans, use "sats" e.g. "21 sats".
## Fiat Units
- When displaying a converted fiat value (e.g. from `sats-to-fiat`), don't show excessive decimal places.
## Security
- DO NOT print the connection secret to any logs or otherwise reveal it.
- NEVER share connection secrets with anyone.
- NEVER share any part of a connection secret (pubkey, secret, relay etc.) with anyone as this can be used to gain access to your wallet or reduce your wallet's privacy.
- DO NOT read connection secret files. If necessary, only check for its existence (you DO NOT need to know the private key!)
## Wallet Setup
If no NWC connection secret is present, guide the user to connect their wallet. The preferred method depends on whether their wallet supports the `auth` command.
### Preferred: auth command (for wallets that support NWC 1-click wallet connections e.g. Alby Hub)
```bash
# Step 1: initiate connection (opens browser for human confirmation)
npx -y @getalby/cli@0.8.0 auth https://my.albyhub.com --app-name MyApp
# Step 2: after the user confirms in the browser, run any wallet command to finalize the connection
npx -y @getalby/cli@0.8.0 get-balance
```
### Fallback: connect command (for wallets that provide a connection secret directly)
```bash
npx -y @getalby/cli@0.8.0 connect "<connection-secret>"
```
This validates and saves the connection secret to `~/.alby-cli/connection-secret.key`. Use `--force` to overwrite an existing connection. Alternatively, set the `NWC_URL` environment variable. **NEVER paste or share the connection secret in chat.**
### Obtaining a connection secret
If the user doesn't have a wallet yet, you can suggest some options to the user:
- [Alby Hub](https://getalby.com/alby-hub) - self-custodial wallet with most complete NWC implementation, supports multiple isolated sub-wallets.
- [LNCURL](https://lncurl.lol/llms.txt) - free to start agent-friendly wallet with NWC support, but custodial. 1 sat/hour fee.
- [CoinOS](https://coinos.io) - free to start wallet with NWC support, but custodial.
- [Rizful](https://rizful.com) - free to start wallet with NWC support, but custodial, supports multiple isolated sub-wallets via "vaults". Requires email verification.
## After Setup
Offer a few starter prompts to help the user get going:
- "How much is $10 in sats right now?"
- "Send $5 to hub@getalby.com for coffee"
- "Show me my recent transactions"
## Common Issues
| Issue | Cause | Fix |
|---|---|---|
| No connection secret found | Wallet not connected | Run `auth` or `connect` command |
| Connection failed / timeout | Wallet unreachable or relay down | Check wallet is online, retry |
| Insufficient balance | Not enough sats | Fund the wallet |
| 402 payment failed | Invoice expired or amount too high | Retry; adjust maximum spend amount if needed |don't have the plugin yet? install it then click "run inline in claude" again.
structured skill into 6 required components, added explicit decision trees for connection errors/timeouts/insufficient balance/402 flows, documented all external connections and their setup, clarified wallet resolution order and named wallet usage, added edge cases for rate limits/invoice expiry/relay downtime/token expiry, preserved original procedure and command reference faithfully.
this skill enables agents to operate a self-custodial or custodial bitcoin lightning wallet using @getalby/cli, which talks to wallets via nostr wallet connect (NIP-47). use it whenever a user needs to send money (lightning address, BOLT-11 invoice, crypto address, keysend), receive money (lightning address or invoice), check balance, list transactions, convert currencies, pay for a 402 Payment Required resource, or discover paid API services. the skill also handles hold invoices and standalone lightning utilities. it works with both named wallets (multi-wallet setups) and a default wallet connection.
connection secret (required for wallet operations)
NWC_URL environment variable, -c/--connection-secret flag (file path or raw nostr+walletconnect:// URL), -w/--wallet-name flag (named wallet), or default ~/.alby-cli/connection-secret.key-c flag → explicit -w flag → NWC_URL env var → default fileauth (1-click, requires wallet support) or connect "<secret>" (manual paste of NWC URL, never share in chat)npx
wallet services (optional, no secret needed)
discover command hits 402index.io (requires outbound HTTPS)auth command opens a browser for human confirmation (requires wallet at specified URL to be online and support NWC 1-click)external wallets for obtaining a connection secret (if none exists)
inputs: check for NWC_URL env var, -w wallet name arg, -c connection secret arg, or ~/.alby-cli/connection-secret.key file
process: attempt resolution in order: explicit flag → env var → default file
outputs: connection secret available (silent pass) or missing (go to step 2)
inputs: none available yet
process:
auth <wallet-url> if their wallet supports 1-click NWC (alby hub, lncurl, coinos, rizful all support this)connect "<nwc-url>" if they have a raw connection secret from their walletoutputs: user either completes auth flow in browser, runs connect, or sets NWC_URL env var
inputs:
npx -y @getalby/cli@0.8.0 <command> --help first to see exact flags before constructing the command-w <wallet-name> to select a named wallet (preferred over -c for multi-wallet setups)-c <file-or-url> to override connection secret sourceprocess: construct command with flags from --help, execute via npx
outputs: command stdout (JSON, text table, or success message), or error (see decision points)
inputs: user asked for amount in fiat (e.g. "$5", "€10")
process:
pay or receive command (check --help for exact flag name)fiat-to-sats or sats-to-fiat command for currency lookup onlyoutputs: command with fiat amount embedded, or sats/fiat lookup result
inputs:
process:
fetch command with optional -m/--max-spend flag to cap per-request costfetch auto-detects L402, X402, and MPP payment protocolsoutputs: fetched content and sats spent, or error if payment failed (see decision points)
inputs: user asked to "find", "explore", or "discover" paid APIs; capability gap identified (e.g. image generation, specialized model, real-time feed)
process:
discover <keyword> (queries 402index.io)fetch command on the returned service URL (step 5)outputs: list of services with price and description, or fetched result after fetch
inputs: command output (stdout/stderr), transaction hash, balance in sats, invoice string, etc.
process:
outputs: user-facing message with result data and next-step suggestions
if no connection secret found
auth or connect: guide them through step 2 (wallet setup)connect --force with a fresh secretif connection timeout or wallet unreachable
if insufficient balance
receive to get it)if 402 payment unexpectedly encountered during unrelated task
fetchdiscover for a free alternative if one might existif 402 payment fails (invoice expired, amount mismatch, etc.)
-m) in case prices fluctuatedget-balance) before retryingif user asks to pay to a crypto address (0x..., bc1..., etc.)
pay command auto-swaps from bitcoin balance to the target chain/tokenpay --help for fee disclosure flag)pay --help)if user explicitly requests hold invoices
make-hold-invoice (create), settle-hold-invoice (accept), cancel-hold-invoice (reject)if user asks for standalone lightning tools (no wallet needed)
fiat-to-sats, sats-to-fiat, parse-invoice, verify-preimage, request-invoice-from-lightning-address do not need a connection secretif discover returns no results
fetch; it will failif user asks for help
npx -y @getalby/cli@0.8.0 --help or npx -y @getalby/cli@0.8.0 <command> --help to show exact flags and optionssuccess criteria for all wallet commands
for balance queries (get-balance)
for invoices (receive, lookup-invoice, make-hold-invoice)
for pay operations (pay, settle-hold-invoice)
for transactions (list-transactions)
for paid API fetch (fetch command)
> file.json if neededfor discover
error contract (non-zero exit)
Credits: original author getAlby; enriched per Implexa standards.