Lnd

From claude-dev-suite/claude-dev-suite · View interactive version

Lnd is an AI agent skill from the GitHub repository claude-dev-suite/claude-dev-suite. LND (Lightning Network Daemon) by Lightning Labs: gRPC + REST API, macaroons, lncli, autopilot, channel backups (SCB), Tor support, watchtowers, integration with bitcoind/btcd/Neutrino backend. USE WHEN: integrating with LND, scripting lncli, debugging LND-specific issues, designing LND-based servic

How to use this skill

Skill file

LND (Lightning Network Daemon)

LND is the most widely deployed Lightning implementation. Written in

Go, primary backend for many services, exchanges, and apps.

Release lines (as of September 2026)

with go1.26.6.

backports, but see the reorg bug below.

New in v0.21.0-beta:

Request with lncli openchannel --channel_type=taproot;

taproot-staging still opens the legacy staging variant. Must stay

private until announced taproot channels are supported.

(--protocol.rbf-coop-close, the protocol itself added in

v0.19.0).

disable with protocol.no-onion-messages=true. Ingress is rate

limited per peer (~0.5 Mbps default) and globally (~5 Mbps), and

messages from peers with no fully open channel are dropped unless

protocol.onion-msg-relay-all=true.

test_native_sql build tag into mainline builds, for users running

with the native-sql setting enabled.

Security: coop-close reorg bug (fixed in v0.21.0-beta)

Disclosed publicly by Bastien Teinturier on 2026-08-13 (discovered

February 2025; no known victims). Before the fix, lnd forgot a

collaboratively closed channel immediately after the first on-chain

confirmation. After a 1-block reorg an attacker could publish any

revoked commitment for that channel; because lnd had already

forgotten it, no penalty transaction was published and the attacker

could take up to the entire channel balance.

Fixed by #10331:

peer.WaitForChanToClose now registers for a capacity-scaled number of

confirmations instead of a hardcoded 1.

lnwallet.CloseConfsForCapacity scales linearly up to 6 confirmations

at the maximum non-wumbo channel size (MaxBtcFundingAmount,

0.16777215 BTC), with a floor of 3 confirmations even for tiny

channels; wumbo channels always require 6. This follows the BOLT 5

recommendation to wait for confirmations before discarding channel

state.

Mind the fixed version. The disclosure post and Bitcoin Optech both

say "v0.20.0, February 2026", but the fix is not in the 0.20 line:

peer/brontide.go at v0.20.4-beta still registers for 1

confirmation, and lnwallet/confscale.go first appears at

v0.21.0-beta. Treat v0.21.0-beta (2026-06-05) as the minimum safe

version.

Operational consequences:

SubscribeChannelEvents still emits CLOSED_CHANNEL early

(#10794

restored that in v0.21.0), but MarkChannelClosed only fires at

full depth.

close_height on WaitingCloseChannel (#10509) so callers can

track remaining confirmations.

custom cltv_expiry_delta of 18-23 are now rejected; the default of

80 is unaffected.

Components

Neutrino (BIP157/158 SPV).

Configuration

~/.lnd/lnd.conf:

[Application Options]
alias=mynode
listen=0.0.0.0:9735
externalip=mynode.onion:9735
tor.active=true
tor.v3=true
maxpendingchannels=10
debuglevel=info

[Bitcoin]
bitcoin.active=true
bitcoin.mainnet=true
bitcoin.node=bitcoind

[Bitcoind]
bitcoind.rpchost=127.0.0.1:8332
bitcoind.rpcuser=...
bitcoind.rpcpass=...
bitcoind.zmqpubrawblock=tcp://127.0.0.1:28332
bitcoind.zmqpubrawtx=tcp://127.0.0.1:28333

[Wtclient]
wtclient.active=true

Macaroons

Per-action capability tokens.

lncli bakemacaroon \
  --save_to=/path/to/custom.macaroon \
  uri:/lnrpc.Lightning/AddInvoice \
  uri:/lnrpc.Lightning/LookupInvoice

API calls send macaroon as gRPC metadata macaroon: <hex> or HTTP

header Grpc-Metadata-macaroon: <hex>.

Treat macaroon files as hot keys

A macaroon file is bearer authority; admin.macaroon is enough to move

funds. Never let a front-end serve the .lnd directory.

BTCPay Server 2.4.2 (2026-08-07) fixed exactly this: all prior

versions, including the 2.4.2 release candidates, let an

unauthenticated remote attacker fetch .macaroon credential files for

the bundled LND node. BTCPay confirmed the bug was actively exploited

and that funds were stolen. The 2.4.2 update also bumps LND to

v0.21.1-beta, regenerates macaroons automatically, and temporarily

removes public LND API access on Docker deployments (so external

wallets such as Zeus cannot connect through the BTCPay domain or onion

address for now). Only LND deployments were exposed; BTCPay's own

on-chain wallets were not.

If you expose LND through your own reverse proxy, Tor service or

forwarded port rather than through BTCPay, rotate credentials

yourself — updating BTCPay does not close access paths you manage.

gRPC API

Proto: lnrpc/lightning.proto. Subservers:

import grpc, lightning_pb2, lightning_pb2_grpc
cred = grpc.ssl_channel_credentials(open("tls.cert","rb").read())
chan = grpc.secure_channel("localhost:10009", cred)
stub = lightning_pb2_grpc.LightningStub(chan)
mac = open("admin.macaroon","rb").read().hex()
stub.GetInfo(lightning_pb2.GetInfoRequest(),
             metadata=[("macaroon", mac)])

REST API

Same as gRPC but https://localhost:8080/v1/getinfo. Macaroon in

header Grpc-Metadata-macaroon: <hex>.

lncli quickstart

lncli getinfo
lncli newaddress p2tr
lncli connect <pubkey>@<addr>:9735
lncli openchannel <pubkey> --local_amt=1000000 --sat_per_vbyte=10
lncli pendingchannels
lncli listchannels
lncli sendpayment --amt 1000 --dest <pubkey> --keysend
lncli closechannel <funding_txid>:<output_index>
lncli closeallchannels --inactive_only

Channel backups (SCB)

Static Channel Backup:

force-close request from peer (via DLP), peer broadcasts, you sweep

on chain.

Auto-backup:

[Application Options]
backupfilepath=/safe/place/channel.backup

Restore:

lncli restorechanbackup --multi_file=channel.backup

Autopilot

Auto-open channels based on heuristic. Generally not recommended for

serious nodes; prefer manual + analytics.

Integration patterns

Custodial wallet

Lightning Address server

LSP (channel-on-pay)

Common issues

password file via wallet-unlock-password-file=).

close is only final after 3-6 confirmations. Poll

blocks_til_close_confirmed in pendingchannels rather than

treating the first confirmation as done.

See also

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.