Skip to main content
Glama

check_wallet_balance

Check the balance of a connected Lightning Network wallet to monitor available funds for autonomous Bitcoin payments and transactions.

Instructions

Check the connected Lightning wallet balance via NWC.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The implementation of the check_wallet_balance tool handler.
    async def check_wallet_balance(
        wallet: "NWCWallet | None" = None,
    ) -> str:
        """
        Check the connected Lightning wallet balance via NWC.
    
        Returns:
            JSON with balance information or error message
        """
        if not wallet:
            return json.dumps(
                {"success": False, "error": "Wallet not initialized. Check NWC connection."}
            )
    
        try:
            # Get balance
            balance_sats = await wallet.get_balance()
    
            result = {
                "success": True,
                "balance_sats": balance_sats,
                "balance_btc": balance_sats / 100_000_000,
                "message": f"Wallet balance: {balance_sats:,} sats",
            }
    
            # Try to get additional info
            try:
                info = await wallet.get_info()
                if info:
                    result["wallet_info"] = {
                        "alias": info.get("alias"),
                        "network": info.get("network"),
                        "block_height": info.get("block_height"),
                    }
            except Exception:
                # get_info might not be supported by all wallets
                pass
    
            return json.dumps(result, indent=2)
    
        except Exception as e:
            logger.exception("Error checking wallet balance")
            return json.dumps({"success": False, "error": sanitize_error(str(e))})

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/refined-element/lightning-enable-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server