# Lightning Integration

Trustless atomic swaps between Citrea and Lightning Network are being actively implemented at the moment through third-party applications, such as [Atomiq](https://testnet4.atomiq.exchange). This will allow users of Citrea to pay Lightning invoices directly from the Citrea network or on- and off-ramp from Citrea without needing to leverage the Bitcoin base layer.

For both swap directions, the smart contract on Citrea simply emulates Lightning's HTLC. An LP (Liquidity Provider) behaves as a proxy on Lightning and it is responsible for all cross-network interactions - with liquidity maintained on both sides.

![Lightning Atomic Swap Diagram](https://4199298141-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FtFU3ZD7rSzMi2uz6wz9W%2Fuploads%2Fgit-blob-b6183bbcc524b2ccdfe8101bbf529814cbf9aefb%2Flightning_atomic_swap.png?alt=media)

For the path from Lightning to Citrea, here's a basic explanation:

* The receiver on the LN side creates an invoice and sends it to the sender on Citrea side.
* Sender locks cBTC on the HTLC contract with the invoice.
* LP makes the payment on LN on behalf of the sender.
* The preimage of the invoice gets revealed to the LP upon payment.
* LP uses the preimage to claim the cBTC from the HTLC contract.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.citrea.xyz/future-research/lightning-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
