RPC Middleware Interceptor

The RPC middleware interceptor allows interception and modification of any RPC call made to LND.

The RPC middleware interceptor is a powerful feature of LND. Once enabled, it intercepts all incoming RPC requests to LND and forwards them, allowing these requests to be inspected, validated and modified before they are sent back to LND for execution.

This interceptor is used by Lightning Terminal to enable the Accounts feature, which allows a node operator to virtually segregate funds in their Lightning Network node between multiple accounts, enforced by Macaroons.

Read the API documentation: Middleware

Enable the RPC Middleware Interceptor

To enable the interceptor, add this line to your lnd.conf file and restart your node.

rpcmiddleware.enable=true

Any software attempting to inspect, validate or even modify is required to authenticate itself to LND with a custom macaroon indicating which caveats it wants to be responsible for. Only requests pertaining to these specific caveats will then be forwarded to the middleware.

Multiple connections to the RPC Middleware are possible, though when replacing calls, each interceptor should be limited to their exclusive caveats only, as each call can only be replaced once.

Code examples:

Lightning Terminal

https://github.com/lightninglabs/lightning-terminal/blob/master/accounts/interceptor.go#L45

lndclient:

https://github.com/lightninglabs/lndclient/blob/master/lightning_client.go

Last updated

Was this helpful?