← 返回
未分类 Key

alby-bitcoin-payments

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.
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.
yjkj999999
未分类 community v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 17
下载
💾 0
安装
1
版本
#latest

概述

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.

npx -y @getalby/cli@0.8.0 [options] <command>

Global Options

Connection Secret (Optional)

-c, --connection-secret - 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 to select a named wallet. This is the preferred option over -c when working with multiple wallets:

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-.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:

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 --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

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

Discovering Paid Services

The discover command searches 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"}' ""

```

  1. 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)

# 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)

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 - self-custodial wallet with most complete NWC implementation, supports multiple isolated sub-wallets.
  • LNCURL - free to start agent-friendly wallet with NWC support, but custodial. 1 sat/hour fee.
  • CoinOS - free to start wallet with NWC support, but custodial.
  • Rizful - 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

IssueCauseFix
---------
No connection secret foundWallet not connectedRun auth or connect command
Connection failed / timeoutWallet unreachable or relay downCheck wallet is online, retry
Insufficient balanceNot enough satsFund the wallet
402 payment failedInvoice expired or amount too highRetry; adjust maximum spend amount if needed

版本历史

共 1 个版本

  • v1.0.0 从ClawHub迁移发布 当前
    2026-06-07 12:27 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

ai-agent

Find Skills

root
帮助用户发现和安装智能体技能,当用户询问如「如何做X」、「找X的技能」、「有能做...的吗」等问题时
★ 1,518 📥 573,719
design-media

agnes-image-gen

user_15292d5a
使用 Agnes AI 的图片生成模型生成图片,支持文生图(agnes-image-2.1-flash)和图生图(agnes-image-2.0-flash)。支持自定义 API Key,用户可使用自己的 Agnes Key。优化重点:降低
★ 1 📥 238
ai-agent

Agent Browser

rez0
用于 AI 代理的浏览器自动化 CLI。当用户需要与网站交互(包括浏览页面、填写表单、点击按钮、截图等)时使用。
★ 865 📥 344,125