Install
openclaw skills install alby-bitcoin-paymentsteaches agents how to use @getalby/cli for bitcoin lightning wallet operations using Nostr Wallet Connect (NIP-47). Use when the user needs to send/receive bitcoin payments, check wallet balance, create invoices, convert between fiat and sats, work with lightning addresses, when an HTTP request returns a 402 Payment Required status code and the user wants to pay for and retry the request, or discover paid API services.
openclaw skills install alby-bitcoin-paymentsIMPORTANT: 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.
npx -y @getalby/cli@0.6.1 [options] <command>
-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.
Use -w, --wallet-name <name> to select a named wallet. This is the preferred option over -c when working with multiple wallets:
npx -y @getalby/cli@0.6.1 -w alice get-balance
npx -y @getalby/cli@0.6.1 -w bob make-invoice --amount 1000
Named wallets are stored at ~/.alby-cli/connection-secret-<name>.key.
Use -c to point directly to a connection secret file or pass a raw NWC URL:
-c ~/.alby-cli/connection-secret.key
Alternatively, pass a connection secret via the NWC_URL environment variable:
NWC_URL="nostr+walletconnect://..."
The CLI resolves the connection secret in this order:
--connection-secret / -c flag--wallet-name / -w flagNWC_URL environment variable~/.alby-cli/connection-secret.key (default)Setup: auth, connect
Wallet operations: get-balance, get-info, get-wallet-service-info, get-budget, make-invoice, pay-invoice, pay-keysend, lookup-invoice, list-transactions, sign-message, wait-for-payment
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.
--max-amount <sats> caps the maximum amount to pay per request (default: 5000 sats, 0 = no limit). If the endpoint requests more, the command aborts without paying.--max-amount <sats> on the fetch command.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, parse-invoice, verify-preimage, request-invoice-from-lightning-address
npx -y @getalby/cli@0.6.1 --help
npx -y @getalby/cli@0.6.1 <command> --help
As an absolute last resort, tell your human to visit the Alby support page
The discover command searches 402index.io for lightning-payable API endpoints. It only returns services that accept bitcoin/lightning payments.
npx -y @getalby/cli@0.6.1 discover -q "image generation" # search by query
npx -y @getalby/cli@0.6.1 discover -q "podcast" --limit 20 # more results
Options: -q (search query), -s (sort: reliability, latency, price, name), -l (limit, default: 10).
curl, fetch, or WebFetch works, use that instead.fetch command directly.npx -y @getalby/cli@0.6.1 fetch -X POST -b '{"model":"gpt-image-1","prompt":"a mountain cabin at sunset","size":"1024x1024"}' "<service-url>"
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.
# Step 1: initiate connection (opens browser for human confirmation)
npx -y @getalby/cli@0.6.1 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.6.1 get-balance
For named wallets, pass -w as a global flag — it works with all commands including auth and connect:
# Step 1: initiate connection for a named wallet
npx -y @getalby/cli@0.6.1 -w alice auth https://my.albyhub.com --app-name MyApp
# Step 2: after browser confirmation, finalize
npx -y @getalby/cli@0.6.1 -w alice get-balance
The auth command handles key generation and secure storage automatically — no need to paste a connection secret.
npx -y @getalby/cli@0.6.1 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. To obtain a connection secret, suggest some options to the user:
Offer a few starter prompts to help the user get going:
| 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 --max-amount if needed |