# lightning invoice decode preflight

> Read a Lightning invoice with the agent-bitcoin SDK before any payment.

lightning invoice decode preflight is a paid AI agent skill on Agensi by agent-bitcoin, in Web3 & Crypto. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $9 (one-time purchase)
- Creator: [agent-bitcoin](https://www.agensi.io/creators/agent-bitcoin)
- Category: [Web3 & Crypto](https://www.agensi.io/skills/web3-crypto)
- Version: 1.0
- Last updated: 2026-11-23
- Security: scan passed (2026-11-23); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/lightning-invoice-decode-preflight
- Tags: web3, bitcoin, lightning-network, python, payments

## About this skill

Manual verification of BOLT11 invoices often leads to failed payment attempts or stuck HTLCs due to malformed hashes. This skill provides a specialized preflight check using the `agent-bitcoin` SDK to validate an invoice's structure before initiating a transaction.

### What it does
- **Invoice Inspection** uses the `agent-bitcoin` SDK to walk the internal structure of a BOLT11 invoice.
- **Hash Validation** ensures the invoice contains exactly one payment hash to prevent routing errors.
- **Preflight Termination** stops the agent execution immediately if the invoice is unwalkable or invalid.
- **Privacy Enforcement** prevents the leakage of sensitive data like BOLT11 strings or hashes in the agent logs.

### How it works
1. The agent receives a BOLT11 invoice string for inspection.
2. It invokes `inspect_payment_hashes` from the `agent_bitcoin.bolt11_invoice` module.
3. The skill evaluates the `seen` object to confirm the invoice can be walked.
4. It verifies the payment hash count equals one.
5. If checks fail, the process terminates to prevent unsafe payment attempts.

### Frameworks & tools
This skill requires Python 3.10+ and the `agent-bitcoin` library. It operates without requiring an LND unlock or mainnet environment variables.

### Why this beats prompting it yourself
Generic prompts often try to parse invoices with regex or basic string splitting, missing internal structure errors. This skill uses the official SDK logic to verify the underlying payment hash integrity, ensuring the agent fails fast before touching any wallet balance.

### Use cases
- Verify a Lightning invoice before passing it to a payment executor.
- Sanitize user-provided BOLT11 strings in automated payment workflows.
- Identify malformed invoices that lack a single, unique payment hash.

### Known limitations
Does not check amount, expiry, network, or L402 specific logic. Requires `agent-bitcoin` installed via pip.

## Requires

- Python

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the lightning invoice decode preflight skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### How does this skill prevent failed Lightning payments?

This skill performs a structural check on BOLT11 invoices using the agent-bitcoin SDK to ensure they are valid and contain exactly one payment hash before you initiate a transaction, preventing failed payments or stuck HTLCs.

### Which AI agent frameworks are compatible with this preflight skill?

This skill is designed for any AI agent framework running Python 3.10 or higher that has the `agent-bitcoin` library installed; it does not require a live LND connection to perform the validation.

### Does the skill check the invoice amount or expiration date?

No, this skill is focused strictly on structural and payment hash integrity; it does not verify invoice amounts, expiration timestamps, or network-specific (mainnet/testnet) metadata.

### Are my BOLT11 invoice details logged during the inspection process?

This skill is specifically optimized to prevent the leakage of sensitive BOLT11 strings or hashes within your agent's execution logs, ensuring your payment data remains private during the validation process.

### What exactly is included in the purchase of this skill?

The purchase includes the production-ready skill code, integration documentation for the `agent-bitcoin` SDK, and the pre-configured logic for handling 'fail-fast' termination scenarios.

### How are updates handled if the agent-bitcoin library changes?

Updates are provided to ensure continued compatibility with the `agent-bitcoin` SDK; users can download the latest version of the skill directly from their marketplace library when a new version is released.

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
