$npx -y skills add lightninglabs/lightning-agent-tools --skill macaroon-bakeryBake, 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.
| 1 | # Macaroon Bakery |
| 2 | |
| 3 | Bake custom lnd macaroons so every agent gets only the permissions it needs. |
| 4 | Never hand out `admin.macaroon` in production — bake a scoped one instead. |
| 5 | |
| 6 | ## Quick Start |
| 7 | |
| 8 | ```bash |
| 9 | # Bake a pay-only macaroon |
| 10 | skills/macaroon-bakery/scripts/bake.sh --role pay-only |
| 11 | |
| 12 | # Bake an invoice-only macaroon |
| 13 | skills/macaroon-bakery/scripts/bake.sh --role invoice-only |
| 14 | |
| 15 | # Bake a read-only macaroon |
| 16 | skills/macaroon-bakery/scripts/bake.sh --role read-only |
| 17 | |
| 18 | # Inspect any macaroon |
| 19 | skills/macaroon-bakery/scripts/bake.sh --inspect ~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon |
| 20 | |
| 21 | # List all available lnd permissions |
| 22 | skills/macaroon-bakery/scripts/bake.sh --list-permissions |
| 23 | ``` |
| 24 | |
| 25 | ### Docker |
| 26 | |
| 27 | The litd container is auto-detected. You can also specify `--container`: |
| 28 | |
| 29 | ```bash |
| 30 | # Auto-detect litd container (default) |
| 31 | skills/macaroon-bakery/scripts/bake.sh --role pay-only |
| 32 | |
| 33 | # Explicit container |
| 34 | skills/macaroon-bakery/scripts/bake.sh --role pay-only --container litd |
| 35 | |
| 36 | # Inspect a macaroon inside a container |
| 37 | skills/macaroon-bakery/scripts/bake.sh --inspect /root/.lnd/data/chain/bitcoin/testnet/admin.macaroon --container litd |
| 38 | ``` |
| 39 | |
| 40 | ### Remote Nodes |
| 41 | |
| 42 | To bake macaroons on a remote lnd node, provide the connection credentials: |
| 43 | |
| 44 | ```bash |
| 45 | # Bake a pay-only macaroon on a remote node |
| 46 | skills/macaroon-bakery/scripts/bake.sh --role pay-only \ |
| 47 | --rpcserver remote-host:10009 \ |
| 48 | --tlscertpath ~/remote-tls.cert \ |
| 49 | --macaroonpath ~/remote-admin.macaroon \ |
| 50 | --save-to ~/remote-pay-only.macaroon |
| 51 | ``` |
| 52 | |
| 53 | You need lncli installed locally and copies of the node's TLS cert and a macaroon |
| 54 | with `macaroon:generate` permission (typically admin.macaroon). |
| 55 | |
| 56 | ## Preset Roles |
| 57 | |
| 58 | | Role | What the agent can do | Cannot do | |
| 59 | |------|----------------------|-----------| |
| 60 | | `pay-only` | Pay invoices, decode invoices, get node info | Create invoices, open channels, see balances | |
| 61 | | `invoice-only` | Create invoices, lookup invoices, get node info | Pay, open channels, see wallet balance | |
| 62 | | `read-only` | Get info, balances, list channels/peers/payments | Pay, create invoices, open/close channels | |
| 63 | | `channel-admin` | All of read-only + open/close channels, connect peers | Pay invoices, create invoices | |
| 64 | | `signer-only` | Sign transactions, derive keys (for remote signer) | Everything else | |
| 65 | |
| 66 | ## Baking Custom Macaroons |
| 67 | |
| 68 | For permissions not covered by presets, bake a custom macaroon: |
| 69 | |
| 70 | ```bash |
| 71 | # Custom: agent can only pay and check wallet balance |
| 72 | skills/macaroon-bakery/scripts/bake.sh --custom \ |
| 73 | uri:/lnrpc.Lightning/SendPaymentSync \ |
| 74 | uri:/lnrpc.Lightning/DecodePayReq \ |
| 75 | uri:/lnrpc.Lightning/WalletBalance \ |
| 76 | uri:/lnrpc.Lightning/GetInfo |
| 77 | |
| 78 | # Custom with explicit output path |
| 79 | skills/macaroon-bakery/scripts/bake.sh --custom \ |
| 80 | uri:/lnrpc.Lightning/AddInvoice \ |
| 81 | uri:/lnrpc.Lightning/GetInfo \ |
| 82 | --save-to ~/my-agent.macaroon |
| 83 | ``` |
| 84 | |
| 85 | ## Discovering Permissions |
| 86 | |
| 87 | ```bash |
| 88 | # List all available URI permissions |
| 89 | skills/macaroon-bakery/scripts/bake.sh --list-permissions |
| 90 | |
| 91 | # Filter for specific service |
| 92 | skills/macaroon-bakery/scripts/bake.sh --list-permissions | grep -i invoice |
| 93 | |
| 94 | # Filter for routing-related permissions |
| 95 | skills/macaroon-bakery/scripts/bake.sh --list-permissions | grep -i router |
| 96 | ``` |
| 97 | |
| 98 | ## Inspecting Macaroons |
| 99 | |
| 100 | ```bash |
| 101 | # See what permissions a macaroon has |
| 102 | skills/macaroon-bakery/scripts/bake.sh --inspect <path-to-macaroon> |
| 103 | |
| 104 | # Inspect the admin macaroon to see full permissions |
| 105 | skills/macaroon-bakery/scripts/bake.sh --inspect ~/.lnd/data/chain/bitcoin/mainnet/admin.macaroon |
| 106 | ``` |
| 107 | |
| 108 | ## Signer Macaroon Scoping |
| 109 | |
| 110 | When using the `lightning-security-module` skill, the credentials bundle includes |
| 111 | `admin.macaroon` by default. For production, bake a signing-only macaroon on the |
| 112 | signer machine: |
| 113 | |
| 114 | ```bash |
| 115 | # On the signer container |
| 116 | skills/macaroon-bakery/scripts/bake.sh --role signer-only \ |
| 117 | --container litd-signer --rpc-port 10012 |
| 118 | |
| 119 | # Or on a native signer |
| 120 | skills/macaroon-bakery/scripts/bake.sh --role signer-only \ |
| 121 | --rpc-port 10012 --lnddir ~/.lnd-signer |
| 122 | |
| 123 | # Then re-export the credentials bundle with the scoped macaroon |
| 124 | ``` |
| 125 | |
| 126 | ## Macaroon Rotation |
| 127 | |
| 128 | Rotate macaroons regularly to limit the window if one is compromised: |
| 129 | |
| 130 | ```bash |
| 131 | # 1. Bake a new macaroon with the same role |
| 132 | skills/macaroon-bakery/scripts/bake.sh --role pay-only --save-to ~/pay-only-v2.macaroon |
| 133 | |
| 134 | # 2. Update your agent config to use the new macaroon |
| 135 | |
| 136 | # 3. Delete the old macaroon's root key (invalidates it) |
| 137 | skills/lnd/scripts/lncli.sh bakemacaroon --root_key_id 0 |
| 138 | # Note: use lncli listmacaroonids and deletemacaroonid for fine-grained control |
| 139 | ``` |
| 140 | |
| 141 | ## Best Practices |
| 142 | |
| 143 | - **One macaroon per agent role.** Don't share macaroons between agents with |
| 144 | different responsibilities. |
| 145 | - **Never use admin.macaroon in production.** It's the master key. |
| 146 | - |