Main Menu
Implementation Cheatsheet
Info / Balances
7 min
info / balances understanding your lightning node's status and current balances is a fundamental part of managing your liquidity this page covers how to use lnd's rest api to retrieve essential node information, as well as your on chain and channel balances these endpoints are crucial for monitoring the health of your node and managing your funds 1\ get basic node info the /v1/getinfo endpoint provides a quick snapshot of your node's identity, synchronization status, and network connectivity this is a common "health check" to ensure your lnd instance is running and connected to the bitcoin and lightning networks the response includes your node's alias , current block height , version , and key statistics like the number of active channels and peers rest endpoint https //lightning engineering/api docs/api/lnd/lightning/get info/ https //lightning engineering/api docs/api/lnd/lightning/get info/ const getnodeinfo = async () => { try { const info = await lnd get("/v1/getinfo"); return info data; } catch (error) { console error("failed to get node info ", error); throw error; } }; 2\ get on chain balance the /v1/balance/blockchain endpoint retrieves your on chain bitcoin balances managed by lnd this balance represents the funds in your node's lightning wallet that are not yet committed to payment channels this is an important metric for managing channel liquidity, as these funds can be used to open new channels the response provides a breakdown of your total balance , confirmed balance (funds available to spend), and unconfirmed balance (funds received but not yet confirmed on the blockchain) rest endpoint https //lightning engineering/api docs/api/lnd/lightning/wallet balance/ https //lightning engineering/api docs/api/lnd/lightning/wallet balance/ const getonchainbalance = async () => { try { const balance = await lnd get("/v1/balance/blockchain"); return balance data; } catch (error) { console error("failed to get on chain balance ", error); throw error; } }; 3\ get channel balances the /v1/balance/channels endpoint provides a summary of all funds locked within your lightning network channels this is your primary operating balance for sending and receiving lightning payments the response will detail your local balance (funds you can send from your channels), your remote balance (funds you can receive from your channels), and the unsettled balance (funds pending confirmation from a channel update) rest endpoint https //lightning engineering/api docs/api/lnd/lightning/channel balance/ https //lightning engineering/api docs/api/lnd/lightning/channel balance/ const getchannelbalances = async () => { try { const balance = await lnd get("/v1/balance/channels"); return balance data; } catch (error) { console error("failed to get channel balances ", error); throw error; } }; 4\ get all balances (combined) often, you'll need a single, consolidated view of all your funds by combining the three api calls above, you can create a complete balance overview for your application's dashboard this example function calls all three endpoints concurrently to fetch and format the full balance information in one go const getallbalances = async () => { try { // fetch all three pieces of data in parallel const \[ nodeinfo, onchainbalance, channelbalances ] = await promise all(\[ lnd get("/v1/getinfo"), lnd get("/v1/balance/blockchain"), lnd get("/v1/balance/channels") ]); // format the combined data for easy use const totalbalance = parseint(onchainbalance data total balance) + parseint(channelbalances data local balance); return { alias nodeinfo data alias, version nodeinfo data version, syncedtochain nodeinfo data synced to chain, blockheight nodeinfo data block height, onchain { total onchainbalance data total balance, confirmed onchainbalance data confirmed balance, unconfirmed onchainbalance data unconfirmed balance }, channels { local channelbalances data local balance, remote channelbalances data remote balance, pending channelbalances data pending open balance }, totalbalance totalbalance }; } catch (error) { console error("failed to get combined balances ", error); throw error; } }; // example usage // getallbalances() then(data => console log(data));