Archon Lightning - Lightning Network Payments for DIDs
Lightning Network integration for Archon decentralized identities. Send and receive Bitcoin over Lightning using your DID.
Related skills:
- -
archon-keymaster — Core DID identity management - INLINECODE1 — Encrypted backups
Capabilities
- - Lightning Wallet Management - Create Lightning wallets for DIDs
- Invoice Generation - Create BOLT11 invoices to receive payments
- Invoice Payment - Pay BOLT11 invoices
- Payment Verification - Verify payments settled (critical security pattern)
- Lightning Address Zapping - Send to Lightning Addresses (
user@domain.com) - Payment History - Track all Lightning transactions
- Balance Checking - Query wallet balance
- DID Integration - Publish Lightning endpoint to DID document
- Invoice Decoding - Inspect BOLT11 invoice details
Prerequisites
- - Node.js installed (for
npx @didcid/keymaster) - Archon identity configured (
~/.archon.env with ARCHON_WALLET_PATH, ARCHON_PASSPHRASE) - INLINECODE7 recommended for JSON parsing
All created by archon-keymaster setup. If you don't have Archon configured yet, see the archon-keymaster skill first.
Security Notes
This skill handles Lightning Network payments:
- 1. Non-custodial: You control your Lightning node and private keys
- Payment verification is built-in:
lightning-pay.sh automatically verifies payments; if using keymaster directly, you must verify manually with lightning-check (see Payment Verification Pattern below) - Environment access: Scripts source
~/.archon.env for wallet access - Network connectivity: Connects to Lightning Network via Archon gatekeeper
Quick Start
Create Lightning Wallet
CODEBLOCK0
Creates a Lightning wallet for your current DID (or specified DID alias).
Examples:
CODEBLOCK1
Check Balance
CODEBLOCK2
Returns current balance in satoshis.
Example output:
CODEBLOCK3
Receiving Payments
Create Invoice
CODEBLOCK4
Creates a BOLT11 invoice to receive payment.
Arguments:
- -
amount - Amount in satoshis (1000 = 0.00001 BTC) - INLINECODE14 - Description/memo for the invoice
- INLINECODE15 - (optional) DID alias, defaults to current identity
Example:
CODEBLOCK5
Output:
CODEBLOCK6
Share this invoice with the payer. They can:
- - Scan as QR code
- Paste into any Lightning wallet
- Pay via Lightning-enabled app
Sending Payments
Pay Invoice (Basic)
CODEBLOCK7
Pay a BOLT11 invoice with automatic payment verification.
Arguments:
- -
bolt11 - BOLT11 invoice string - INLINECODE17 - (optional) DID alias to pay from
Output: Success or failure message with exit code
Example:
CODEBLOCK8
The script automatically verifies the payment settled before outputting success.
⚠️ Payment Verification Pattern (CRITICAL)
The payment hash is NOT proof of payment! Lightning payments can fail, time out, or remain pending.
Our lightning-pay.sh script handles verification automatically:
CODEBLOCK9
The script verifies the payment settled and outputs a clear success/failure message. No manual checking needed.
Why verification matters:
- - Payment hash ≠ success (can fail after returning hash)
- Prevents false confirmation (thinking you paid when you didn't)
Verify Payment Status
CODEBLOCK10
Check whether a payment settled.
Arguments:
- -
paymentHash - Payment hash from INLINECODE20 - INLINECODE21 - (optional) DID alias
Returns:
CODEBLOCK11
- -
"paid": true — Payment settled successfully - INLINECODE23 — Payment failed or still pending
Lightning Address Zapping
CODEBLOCK12
Send sats to a Lightning Address, DID, or alias.
Arguments:
- -
recipient - Lightning Address (user@domain.com), DID, or alias - INLINECODE26 - Amount in satoshis
- INLINECODE27 - (optional) Message/memo
- INLINECODE28 - (optional) DID alias to send from
Examples:
CODEBLOCK13
Output: Success or failure message with exit code
Example:
CODEBLOCK14
The script automatically verifies the payment settled before outputting success.
What it does:
- 1. Resolves Lightning Address to LNURL endpoint
- Requests invoice for specified amount
- Pays invoice
- Returns payment hash (you still need to verify!)
Payment History
List Payments
CODEBLOCK15
Show all Lightning payments (sent and received).
Example output:
CODEBLOCK16
Format: YYYY/MM/DD HH:MM:SS [+/-]amount sats ["memo"]
- - Negative amounts = payments sent
- Positive amounts = payments received
- Memo is optional
DID Integration
Publish Lightning Endpoint
CODEBLOCK17
Add your Lightning endpoint to your DID document.
What it does:
- - Updates your DID document with Lightning service info
- Makes your Lightning endpoint publicly discoverable
- Others can look up your DID and pay you
Example:
CODEBLOCK18
Unpublish Lightning Endpoint
CODEBLOCK19
Remove Lightning endpoint from your DID document.
Utilities
Decode Invoice
CODEBLOCK20
Inspect BOLT11 invoice details before paying.
Example output:
CODEBLOCK21
Use cases:
- - Verify amount before paying
- Check invoice hasn't expired
- Confirm recipient/description
- Extract payment hash for tracking
Complete Workflow Examples
Example 1: Simple Payment
CODEBLOCK22
Example 2: Lightning Address Zap
CODEBLOCK23
Example 3: Invoice Verification
CODEBLOCK24
Example 4: Multi-DID Wallet Management
CODEBLOCK25
Example 5: Publishing Lightning to DID
CODEBLOCK26
Example 6: Sending Invoice via Dmail
CODEBLOCK27
Why this matters: Agents can request payment without needing email, phone numbers, or centralized messaging platforms. Just DIDs + Lightning + dmail.
Environment Setup
All scripts require:
CODEBLOCK28
This is automatically sourced by the wrapper scripts. npx is used to run keymaster, so no nvm sourcing is needed.
Environment variables (~/.archon.env):
- -
ARCHON_WALLET_PATH - Path to your wallet file - INLINECODE33 - Wallet encryption passphrase
- INLINECODE34 - (optional) Gatekeeper endpoint
Advanced Usage
Lightning Node Details
Archon Lightning wallets are:
- - Non-custodial - You control the keys
- Self-hosted - Runs via Archon gatekeeper
- DID-integrated - Same identity across protocols
The wallet is managed by @didcid/keymaster which interfaces with Lightning infrastructure.
Payment Amounts
Lightning amounts are in satoshis:
- - 1 satoshi = 0.00000001 BTC
- 1000 sats = 0.00001 BTC (~$0.01 at $100k BTC)
- 100,000 sats = 0.001 BTC (~$1 at $100k BTC)
Minimum payment typically 1 sat, maximum depends on channel capacity.
Invoice Expiry
BOLT11 invoices typically expire after 1 hour. Check expiry with:
CODEBLOCK29
Lightning Address Resolution
Lightning Addresses resolve via LNURL:
CODEBLOCK30
The lightning-zap.sh script handles this automatically.
Error Handling
Common Issues
"No route found":
- - Lightning Network couldn't find path to recipient
- Try smaller amount or wait for better routing
"Insufficient balance":
- - Check balance: INLINECODE37
- Add funds to your wallet
"Invoice expired":
- - Request new invoice from recipient
- Check expiry: INLINECODE38
"Payment failed":
- - Always verify with INLINECODE39
- Payment hash ≠ success
- May need to retry with new invoice
Verification Workflow
CODEBLOCK31
Security Best Practices
Payment Verification
Always verify payments settled:
CODEBLOCK32
Invoice Validation
Before paying, verify:
- - Amount is correct
- Recipient is expected
- Invoice hasn't expired
- Description matches expectation
CODEBLOCK33
Key Security
- - Lightning private keys derived from DID seed
- Keep
ARCHON_PASSPHRASE secure - Backup your 12-word mnemonic (see
archon-vault skill) - Use separate DIDs for different risk profiles
Amount Limits
- - Start with small amounts for testing
- Lightning is for micropayments (< $100 typical)
- Large amounts should use on-chain Bitcoin
- Check balance before sending
Troubleshooting
"Command not found: npx"
Ensure Node.js is installed and in your PATH:
CODEBLOCK34
If not installed, install Node.js via your package manager or from https://nodejs.org
"Cannot read wallet"
CODEBLOCK35
"Payment hash not found"
Payment may still be pending or failed. Wait 5-10 seconds and try lightning-check again.
"Lightning wallet not found"
CODEBLOCK36
Network Issues
If Archon gatekeeper is unreachable:
CODEBLOCK37
Data Storage
Lightning payment data is stored:
- - Locally: Wallet state in INLINECODE43
- Network: Channel state on Lightning Network
- DID document: Public endpoint (if published)
No payment history or balances are exposed publicly unless you explicitly publish them.
Use Cases
Agent-to-Agent Payments:
- - Pay for API access
- Skill marketplace transactions
- Service subscriptions
- Bounty payments
Content Monetization:
- - Paywalled articles
- Per-use API access
- Streaming sats for media
- Microtips for social posts
Real-Time Payments:
- - Pay-per-compute
- Storage payments
- Data feed subscriptions
- Time-based access
Value-4-Value:
- - Podcast boosts
- Creator support
- Open source tips
- P2P payments
References
- - Archon documentation: https://github.com/archetech/archon
- Keymaster reference: https://github.com/archetech/archon/tree/main/keymaster
- Lightning Network: https://lightning.network
- BOLT specifications: https://github.com/lightning/bolts
- Lightning Address: https://lightningaddress.com
Related Skills
- - archon-keymaster — Core DID management and credentials
- archon-vault — Encrypted backups and disaster recovery
- archon-cashu — Ecash tokens with DID locking
⚡ Powered by Lightning. Secured by Archon. Built for agents.
Archon Lightning - 面向DID的闪电网络支付
Archon去中心化身份体系的闪电网络集成。使用您的DID通过闪电网络发送和接收比特币。
相关技能:
- - archon-keymaster — 核心DID身份管理
- archon-vault — 加密备份
功能
- - 闪电钱包管理 - 为DID创建闪电钱包
- 发票生成 - 创建BOLT11发票以接收付款
- 发票支付 - 支付BOLT11发票
- 支付验证 - 验证支付是否结算(关键安全模式)
- 闪电地址打赏 - 向闪电地址发送(user@domain.com)
- 支付历史 - 追踪所有闪电交易
- 余额查询 - 查询钱包余额
- DID集成 - 将闪电端点发布到DID文档
- 发票解码 - 检查BOLT11发票详情
前提条件
- - 已安装Node.js(用于npx @didcid/keymaster)
- 已配置Archon身份(~/.archon.env包含ARCHONWALLETPATH、ARCHON_PASSPHRASE)
- 推荐安装jq用于JSON解析
以上均由archon-keymaster设置创建。如果您尚未配置Archon,请先查看archon-keymaster技能。
安全说明
本技能处理闪电网络支付:
- 1. 非托管:您控制自己的闪电节点和私钥
- 内置支付验证:lightning-pay.sh自动验证支付;如果直接使用keymaster,您必须使用lightning-check手动验证(见下方支付验证模式)
- 环境访问:脚本引用~/.archon.env以访问钱包
- 网络连接:通过Archon网关连接到闪电网络
快速开始
创建闪电钱包
bash
./scripts/lightning/add-lightning.sh [id]
为当前DID(或指定DID别名)创建闪电钱包。
示例:
bash
./scripts/lightning/add-lightning.sh # 当前DID
./scripts/lightning/add-lightning.sh work # 指定DID别名
查询余额
bash
./scripts/lightning/lightning-balance.sh [id]
以聪为单位返回当前余额。
输出示例:
2257 sats
接收付款
创建发票
bash
./scripts/lightning/lightning-invoice.sh <金额> <备注> [id]
创建BOLT11发票以接收付款。
参数:
- - 金额 - 以聪为单位的金额(1000 = 0.00001 BTC)
- 备注 - 发票的描述/备注
- id - (可选)DID别名,默认为当前身份
示例:
bash
./scripts/lightning/lightning-invoice.sh 1000 咖啡付款
输出:
json
{
paymentRequest: lnbc10u1p...,
paymentHash: a3f7b8c9...
}
将此发票分享给付款方。他们可以:
- - 扫描为二维码
- 粘贴到任何闪电钱包
- 通过支持闪电网络的应用支付
发送付款
支付发票(基础)
bash
./scripts/lightning/lightning-pay.sh [id]
支付BOLT11发票,自动验证支付。
参数:
- - bolt11 - BOLT11发票字符串
- id - (可选)用于支付的DID别名
输出: 成功或失败消息及退出码
示例:
bash
./scripts/lightning/lightning-pay.sh lnbc10u1p...
✅ 支付已确认
(成功退出码0,失败退出码1)
脚本在输出成功前会自动验证支付已结算。
⚠️ 支付验证模式(关键)
支付哈希不是支付证明! 闪电支付可能失败、超时或保持待处理状态。
我们的lightning-pay.sh脚本自动处理验证:
bash
./scripts/lightning/lightning-pay.sh lnbc10u1p...
✅ 支付已确认
(或❌ 支付失败或待处理 + 退出码1)
脚本验证支付已结算并输出清晰的成功/失败消息。无需手动检查。
为什么验证很重要:
- - 支付哈希 ≠ 成功(可能在返回哈希后失败)
- 防止虚假确认(以为已支付但实际未支付)
验证支付状态
bash
./scripts/lightning/lightning-check.sh [id]
检查支付是否已结算。
参数:
- - paymentHash - 来自lightning-pay的支付哈希
- id - (可选)DID别名
返回:
json
{
paid: true,
preimage: ...,
amount: 1000
}
- - paid: true — 支付已成功结算
- paid: false — 支付失败或仍待处理
闪电地址打赏
bash
./scripts/lightning/lightning-zap.sh <接收方> <金额> [备注] [id]
向闪电地址、DID或别名发送聪。
参数:
- - 接收方 - 闪电地址(user@domain.com)、DID或别名
- 金额 - 以聪为单位的金额
- 备注 - (可选)消息/备注
- id - (可选)发送方的DID别名
示例:
bash
向闪电地址打赏
./scripts/lightning/lightning-zap.sh user@getalby.com 1000 好文章!
向DID打赏
./scripts/lightning/lightning-zap.sh did:cid:bagaaiera... 5000
向别名打赏
./scripts/lightning/lightning-zap.sh alice 2000 咖啡
输出: 成功或失败消息及退出码
示例:
bash
./scripts/lightning/lightning-zap.sh user@getalby.com 1000 好文章!
✅ 支付已确认
(成功退出码0,失败退出码1)
脚本在输出成功前会自动验证支付已结算。
功能说明:
- 1. 将闪电地址解析为LNURL端点
- 请求指定金额的发票
- 支付发票
- 返回支付哈希(您仍需验证!)
支付历史
列出支付记录
bash
./scripts/lightning/lightning-payments.sh [id]
显示所有闪电支付记录(发送和接收)。
输出示例:
2026/03/05 11:17:38 -100 sats 支付备注
2026/03/04 17:08:14 +20 sats 收到付款
2026/03/03 17:16:31 +25 sats 测试发票
格式:YYYY/MM/DD HH:MM:SS [+/-]金额 sats [备注]
- - 负金额 = 已发送的付款
- 正金额 = 已收到的付款
- 备注为可选
DID集成
发布闪电端点
bash
./scripts/lightning/publish-lightning.sh [id]
将您的闪电端点添加到DID文档中。
功能说明:
- - 使用闪电服务信息更新您的DID文档
- 使您的闪电端点可公开发现
- 其他人可以查找您的DID并向您付款
示例:
bash
./scripts/lightning/publish-lightning.sh
您的DID文档现在包含:
{
didDocument: {
id: did:cid:bagaaiera...,
service: [{
id: did:cid:bagaaiera...#lightning,
type: Lightning,
serviceEndpoint: http://...onion:4222/invoice/bagaaiera...
}]
}
}
取消发布闪电端点
bash
./scripts/lightning/unpublish-lightning.sh [id]
从DID文档中移除闪电端点。
工具
解码发票
bash
./scripts/lightning/lightning-decode.sh
在支付前检查BOLT11发票详情。
输出示例:
json
{
amount: 1000,
description: 咖啡付款,
paymentHash: a3f7b8c9...,
timestamp: 1709635800,
expiry: 3600,
destination: 03...
}
使用场景: