Skip to content

Commit

Permalink
Loinify README (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
DanGould committed Aug 10, 2022
1 parent e9626bd commit d66880f
Showing 1 changed file with 38 additions and 33 deletions.
71 changes: 38 additions & 33 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
# Lightning Optimizing Opening Server
# L[ightningPayJ]oin: Automated External Lightning Channel Funding

(loptoš ~ naughty boy/brat/hooligan/..., not to be confused with lopta == ball)
This server leverages Pay-to-Endpoint to negotiate channel funding on your lightning node from an external wallet supporting BIP78. Previously, external funding could only be done by [signing PSBTs manually](https://github.com/lightningnetwork/lnd/blob/master/docs/psbt.md). A node running this software can open a new scheduled lightning channel upon payment receipt from e.g. BTCPayServer with a normal QR scan transfer flow.

## WARNING: ULTRA-EXPERIMENTAL SOFTWARE!!!
## ⚠️ WARNING: ULTRA-EXPERIMENTAL SOFTWARE

**This project is very early and lacks basic checks (that means it's NOT fully BIP78-compliant)!
For the love of god, do NOT use it on mainnet just yet!
If you don't want to wait long, help with reviews and PRs.**
❗️ **This project is pre-alpha quality and lacks basic checks. It is NOT fully BIP78-compliant** ❗️

Any unexpecected node setup or message will likely cause permanent loss of funds.

## About
For the love of god, do NOT use it on mainnet just yet!
If you don't want to wait long, help with reviews and PRs

This server optimizes your channel opening from a remote wallet which supports PayJoin.
It enables you to open one or more channels from a remote LND with an empty wallet using sats in PayJoin-compliant wallet.
This way you save one chain transaction when opening from Wasabi (untested), Blue Wallet (untested), BTCPayServer (tested, works), or other PayJoin-supporting wallet.
It's basically a user-friendly way to do PSBT funding flow.
## Benefits

And yes, in the future you could give the URI/QR code to someone else, so you receive a PayJoin transaction and simultaneously open Lightning channel with the received money.
Read the article about [Lightning Powered PayJoin](https://chaincase.app/words/lightning-payjoin?ref=github).

### Expected fee savings

The classic scenario of sending to LND wallet and then opening a channel involves two transactions.
With PayJoin it involves just one transaction, saving 106 vB (68 vB input + 22 vB script pubkey + 8 vB output amount + 4 vB version + 4vB timelock)
With this software's PayJoin it involves just one transaction, saving 106 vB (68 vB input + 22 vB script pubkey + 8 vB output amount + 4 vB version + 4vB timelock).
Sending to a node and then opening 10 channels can turn 11 transactions into one, saving 1060 vB.
Same if someone else pays you and you already decided to use the received money to open channel(s).
You will also save shitton of time not having to wait for confirmations.
(There's `--spend-unconfirmed`, but maybe not a good idea for long chains?)
If someone were to pay you and you already scheduled to open channel openings, you would save too.
You will also save a shedload of time you would otherwise spend waiting for confirmations.
(There's `--spend-unconfirmed`, but that has its own drawbacks)

### Expected privacy implications

If you open a channel with a ususal LN wallet, it's pretty much certain that the change belongs to the funder.
This tool makes it uncertain because it could've been a payer.
This tool may produce two changes - it's still unclear whether both or only one belongs to the funder and it may be hard to find which one.
(But there's a good chance it'll be revealed eventually.)
If you open a channel with a usual LN wallet, common input heuristic makes a good assumption that the change belongs to the funder.
This tool breaks that assumption. It could now be a payer's change.
This tool may produce many changes. Because it breaks analytic assumptions regarding bitcoin transactions in general, many transactions on the network have a larger set of possible interpretations.

Just as with any other PayJoin, it's unclear whether all inputs belong to the funder or some of them don't.

Expand All @@ -44,8 +41,8 @@ Good luck analyzing that!

### UX implications

All this is possible without loptos by manually exchanging PSBTs.
BIP78 just turns that tedious back and forth into scanning/clicking one link followed by confirmation in the wallet.
All this is possible without loptos by [manually exchanging PSBTs](https://github.com/lightningnetwork/lnd/blob/master/docs/psbt.md).
BIP78 turns that tedious back and forth into scanning/clicking one link followed by confirmation in the wallet.
In other words, your grandmother will be able to somewhat privately open a bunch of channels for you, if she has a BIP78-capable wallet.

## Limitations and future plans
Expand All @@ -64,18 +61,26 @@ In other words, your grandmother will be able to somewhat privately open a bunch
## Usage

0. You need Rust version 1.48 or higher to compile this.
1. Assuming you already have LND 0.14, ideally 0.14.2
2. `cargo build`
1. You need LND v14.2 or higher
2. `cargo build [--features=test_paths]`. The test_paths feature will serve the `static/index.html` ui contained in this folder rather than one in `/usr/share/loptos/static` in production.
3. Setup reverse HTTP proxy with HTTPS forwarding to some port - e.g. 3000.
You can do this in a few lines using [selfhost in Cryptoanarchy Debian Repository](https://github.com/debian-cryptoanarchy/cryptoanarchy-deb-repo-builder/blob/master/docs/user-level.md#selfhost).
4. `./target/debug/loptos HTTP_BIND_PORT https://LND_GRPC_ADDRESS /path/to/cert/file /path/to/admin.macaroon FEE_RATE_SAT_PER_VB DEST_NODE_URI AMOUNS_IN_SATS [DEST_NODE_URI AMOUNS_IN_SATS ...] [CHAIN_WALLET_AMOUNT_SATS]`
5. Copy BIP21 from command line output and paste it into one of the supported wallets
6. Confirm the transaction and pray it works

Note: if `CHAIN_WALLET_AMOUNT_SATS` is present another output will be added to send the amount to the internal wallet.
This may be required in case the wallet is empty as in such case LND can not reserve sats for anchor commitments.
However, to truly work, you need LND 0.14.2.

You can do this in a few lines using [selfhost in Cryptoanarchy Debian Repository](https://github.com/debian-cryptoanarchy/cryptoanarchy-deb-repo-builder/blob/master/docs/user-level.md#selfhost). or [on MacOS](https://www.storyblok.com/faq/setup-dev-server-https-proxy)
4. create a configuration file based on `config_spec.toml`. This is mine based on a [polar](https://lightningpolar.com/) lightning network simulator setup. `CONFIGURATION_FILE=loptos.conf`:
```configuration
# loptos.conf
bind_port=3000
lnd_address="https://localhost:10004"
lnd_cert_path="/Users/dan/.polar/networks/1/volumes/lnd/dave/tls.cert"
lnd_macaroon_path="/Users/dan/.polar/networks/1/volumes/lnd/dave/data/chain/bitcoin/regtest/admin.macaroon"
```
5. `./target/debug/loptos --conf CONFIGURATION_FILE_PATH DEST_NODE_URI AMOUNS_IN_SATS [DEST_NODE_URI AMOUNS_IN_SATS ...] [CHAIN_WALLET_AMOUNT_SATS]`
6. Copy BIP21 from command line output and paste it into one of the supported wallets. I use [the payjoin crate client](https://github.com/Kixunil/payjoin/tree/master/payjoin-client) to make a payjoin right from regtest bitcoind.
7. Confirm the transaction and move some sats over the new channel


Note: if `CHAIN_WALLET_AMOUNT_SATS` is present a single-sig output will be added to LND's internal wallet.
A minimum internal wallet balance of 10,000 reserve sats per channel up to 100,000 sats is required for anchor commitments. This [can be automated](https://github.com/Kixunil/loptos/issues/11) in the future.
## License

The license is MIT, with one restriction and one warning:
Expand Down

0 comments on commit d66880f

Please sign in to comment.