← 返回
AI智能 中文

lnd macaroon bakery

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.
烘焙、检查并管理 lnd macaroon,用于最小权限代理访问。适用于需要限定凭证的代理——仅支付、仅发票、仅读取或自定义权限。也涉及签名者 macaroon 作用域及 macaroon 轮换。
roasbeef
AI智能 clawhub v1.0.0 1 版本 99923.7 Key: 无需
★ 0
Stars
📥 1,310
下载
💾 65
安装
1
版本
#latest

概述

Macaroon Bakery

Bake custom lnd macaroons so every agent gets only the permissions it needs.

Never hand out admin.macaroon in production — bake a scoped one instead.

Quick Start

# Bake a pay-only macaroon
skills/macaroon-bakery/scripts/bake.sh --role pay-only

# Bake an invoice-only macaroon
skills/macaroon-bakery/scripts/bake.sh --role invoice-only

# Bake a read-only macaroon
skills/macaroon-bakery/scripts/bake.sh --role read-only

# Inspect any macaroon
skills/macaroon-bakery/scripts/bake.sh --inspect ~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon

# List all available lnd permissions
skills/macaroon-bakery/scripts/bake.sh --list-permissions

Docker

The litd container is auto-detected. You can also specify --container:

# Auto-detect litd container (default)
skills/macaroon-bakery/scripts/bake.sh --role pay-only

# Explicit container
skills/macaroon-bakery/scripts/bake.sh --role pay-only --container litd

# Inspect a macaroon inside a container
skills/macaroon-bakery/scripts/bake.sh --inspect /root/.lnd/data/chain/bitcoin/testnet/admin.macaroon --container litd

Remote Nodes

To bake macaroons on a remote lnd node, provide the connection credentials:

# Bake a pay-only macaroon on a remote node
skills/macaroon-bakery/scripts/bake.sh --role pay-only \
    --rpcserver remote-host:10009 \
    --tlscertpath ~/remote-tls.cert \
    --macaroonpath ~/remote-admin.macaroon \
    --save-to ~/remote-pay-only.macaroon

You need lncli installed locally and copies of the node's TLS cert and a macaroon

with macaroon:generate permission (typically admin.macaroon).

Preset Roles

RoleWhat the agent can doCannot do
---------------------------------------
pay-onlyPay invoices, decode invoices, get node infoCreate invoices, open channels, see balances
invoice-onlyCreate invoices, lookup invoices, get node infoPay, open channels, see wallet balance
read-onlyGet info, balances, list channels/peers/paymentsPay, create invoices, open/close channels
channel-adminAll of read-only + open/close channels, connect peersPay invoices, create invoices
signer-onlySign transactions, derive keys (for remote signer)Everything else

Baking Custom Macaroons

For permissions not covered by presets, bake a custom macaroon:

# Custom: agent can only pay and check wallet balance
skills/macaroon-bakery/scripts/bake.sh --custom \
    uri:/lnrpc.Lightning/SendPaymentSync \
    uri:/lnrpc.Lightning/DecodePayReq \
    uri:/lnrpc.Lightning/WalletBalance \
    uri:/lnrpc.Lightning/GetInfo

# Custom with explicit output path
skills/macaroon-bakery/scripts/bake.sh --custom \
    uri:/lnrpc.Lightning/AddInvoice \
    uri:/lnrpc.Lightning/GetInfo \
    --save-to ~/my-agent.macaroon

Discovering Permissions

# List all available URI permissions
skills/macaroon-bakery/scripts/bake.sh --list-permissions

# Filter for specific service
skills/macaroon-bakery/scripts/bake.sh --list-permissions | grep -i invoice

# Filter for routing-related permissions
skills/macaroon-bakery/scripts/bake.sh --list-permissions | grep -i router

Inspecting Macaroons

# See what permissions a macaroon has
skills/macaroon-bakery/scripts/bake.sh --inspect <path-to-macaroon>

# Inspect the admin macaroon to see full permissions
skills/macaroon-bakery/scripts/bake.sh --inspect ~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon

Signer Macaroon Scoping

When using the lightning-security-module skill, the credentials bundle includes

admin.macaroon by default. For production, bake a signing-only macaroon on the

signer machine:

# On the signer container
skills/macaroon-bakery/scripts/bake.sh --role signer-only \
    --container litd-signer --rpc-port 10012

# Or on a native signer
skills/macaroon-bakery/scripts/bake.sh --role signer-only \
    --rpc-port 10012 --lnddir ~/.lnd-signer

# Then re-export the credentials bundle with the scoped macaroon

Macaroon Rotation

Rotate macaroons regularly to limit the window if one is compromised:

# 1. Bake a new macaroon with the same role
skills/macaroon-bakery/scripts/bake.sh --role pay-only --save-to ~/pay-only-v2.macaroon

# 2. Update your agent config to use the new macaroon

# 3. Delete the old macaroon's root key (invalidates it)
skills/lnd/scripts/lncli.sh bakemacaroon --root_key_id 0
# Note: use lncli listmacaroonids and deletemacaroonid for fine-grained control

Best Practices

  • One macaroon per agent role. Don't share macaroons between agents with

different responsibilities.

  • Never use admin.macaroon in production. It's the master key.
  • Inspect before deploying. Always verify what a baked macaroon can do.
  • Rotate on a schedule. Monthly for production, immediately if compromised.
  • Scope signer macaroons too. The remote signer's credentials bundle should

use signer-only, not admin.

  • Store with 0600 permissions. Macaroons are bearer tokens — treat like passwords.

Common Permission URIs

PermissionDescription
------------------------
uri:/lnrpc.Lightning/GetInfoNode info (version, pubkey, sync status)
uri:/lnrpc.Lightning/WalletBalanceOn-chain wallet balance
uri:/lnrpc.Lightning/ChannelBalanceLightning channel balance
uri:/lnrpc.Lightning/ListChannelsList open channels
uri:/lnrpc.Lightning/ListPeersList connected peers
uri:/lnrpc.Lightning/SendPaymentSyncPay a Lightning invoice
uri:/lnrpc.Lightning/DecodePayReqDecode a BOLT11 invoice
uri:/lnrpc.Lightning/AddInvoiceCreate a Lightning invoice
uri:/lnrpc.Lightning/LookupInvoiceLook up an invoice by hash
uri:/lnrpc.Lightning/ListInvoicesList all invoices
uri:/lnrpc.Lightning/ListPaymentsList all payments
uri:/lnrpc.Lightning/ConnectPeerConnect to a peer
uri:/lnrpc.Lightning/OpenChannelSyncOpen a channel
uri:/lnrpc.Lightning/CloseChannelClose a channel
uri:/signrpc.Signer/SignOutputRawSign a transaction output
uri:/signrpc.Signer/ComputeInputScriptCompute input script for signing
uri:/signrpc.Signer/MuSig2SignMuSig2 signing
uri:/walletrpc.WalletKit/DeriveKeyDerive a key
uri:/walletrpc.WalletKit/DeriveNextKeyDerive next key in sequence

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 00:27 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

Lnd

roasbeef
安装并运行 Lightning Terminal (litd),该终端将 lnd、loop、pool、tapd 和 faraday 集成在单个 Docker 容器中。默认使用 neutrino 后端,在测试网上采用 SQLite 存储。支持
★ 0 📥 1,640
ai-intelligence

Self-Improving + Proactive Agent

ivangdavila
自我反思+自我批评+自我学习+自组织记忆。智能体评估自身工作、发现错误并持续改进。
★ 1,362 📥 318,921
ai-intelligence

ontology

oswalpalash
类型化知识图谱,用于结构化智能体记忆与可组合技能。支持创建/查询实体(人员、项目、任务、事件、文档)及关联...
★ 714 📥 244,075