2
0
mirror of https://github.com/lightninglabs/loop synced 2024-11-04 06:00:21 +00:00
Go to file
Olaoluwa Osuntokun ba6994e3d3
Merge pull request #29 from grunch/change-global-option-param-name
Change loopd global option parameter to rpcserver
2019-03-22 16:00:53 -07:00
cmd Change loopd global option parameter to rpcserver 2019-03-22 14:53:37 -03:00
docs docs: move out architecture diagram 2019-03-13 16:11:04 -07:00
lndclient build: build against latest version of lnd 2019-03-15 17:22:07 -07:00
loopdb multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
looprpc looprpc: generate client REST definitions 2019-03-12 15:34:45 -07:00
swap utils: remove utils package in favor of new swap package 2019-03-06 20:34:00 -08:00
sweep multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
test loop: extract code from client package into new loop primary package 2019-03-06 20:34:01 -08:00
.gitignore git: update gitignore to include new loop related binaries 2019-03-06 15:57:55 -08:00
.travis.yml build: add travis config 2019-03-07 10:19:27 +01:00
client_test.go multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
client.go multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
config.go multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
executor.go multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
go.mod build: build against latest version of lnd 2019-03-15 17:22:07 -07:00
go.sum build: build against latest version of lnd 2019-03-15 17:22:07 -07:00
interface.go multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
LICENSE Initial commit 2019-02-15 17:57:58 -08:00
log.go loop: extract code from client package into new loop primary package 2019-03-06 20:34:01 -08:00
loopout_test.go multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
loopout.go multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
Makefile build: add travis config 2019-03-07 10:19:27 +01:00
README.md Bold text lnd install instruction for dummies 2019-03-21 16:16:59 +00:00
release.sh release: add release script 2019-03-07 21:49:59 -08:00
server_mock_test.go multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
store_mock_test.go multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
swap_server_client.go multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
swap.go multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
testcontext_test.go multi: finalize rename from uncharge to loop out 2019-03-06 20:34:04 -08:00
uncharge_state.go loop: extract code from client package into new loop primary package 2019-03-06 20:34:01 -08:00
version.go loop: add new version file, pin at 0.1-alpha 2019-03-20 17:15:14 -07:00

Lightning Loop

Lightning Loop is a non-custodial service offered by Lightning Labs to bridge on-chain and off-chain Bitcoin using submarine swaps. This repository is home to the Loop client and depends on the Lightning Network daemon lnd. All of lnds supported chain backends are fully supported when using the Loop client: Neutrino, Bitcoin Core, and btcd.

In the current iteration of the Loop software, only off-chain to on-chain swaps are supported, where the Loop client sends funds off-chain in exchange for the funds back on-chain. This is called a Loop Out.

The service can be used in various situations:

  • Acquiring inbound channel liquidity from arbitrary nodes on the Lightning network
  • Depositing funds to a Bitcoin on-chain address without closing active channels
  • Paying to on-chain fallback addresses in the case of insufficient route liquidity

Future iterations of the Loop software will also allow on-chain to off-chain swaps. These swaps can be useful for additional use-cases:

  • Refilling depleted channels with funds from cold-wallets or exchange withdrawals
  • Servicing off-chain Lightning withdrawals using on-chain payments, with no funds in channels required
  • As a failsafe payment method that can be used when channel liquidity along a route is insufficient

Development and Support

The Loop client is current in an early beta state, and offers a simple command line application. Future APIs will be added to support implementation or use of the Loop service.

The GitHub issue tracker can be used to request specific improvements or register and get help with any problems. Community support is also available in the LND Slack .

Setup and Install

LND and the loop client are using Go modules. Make sure that the GO111MODULE env variable is set to on.

In order to execute a swap, LND will need to be rebuilt on master with sub servers enabled.

LND

Make sure that you are using the master branch of lnd. You can get this by git cloning the repository

git clone https://github.com/lightningnetwork/lnd.git

Once the lnd repository is cloned, it will need to be built with special build tags that enable the swap. This enables the required lnd rpc services.

cd lnd
make install tags="signrpc walletrpc chainrpc"

Check to see if you have already installed lnd. If you have, you will need to delete the .macaroon files from your lnd directory.

Do not delete any other files other than the .macaroon files

// Example on Linux to see macaroons in the default directory:
ls ~/.lnd/data/chain/bitcoin/mainnet

This should show no .macaroon files. If it does? Stop lnd, delete macaroons, restart lnd.

lncli stop

Now delete the .macaroon files and restart lnd. (don't delete any other files)

Loopd

After lnd is installed, you will need to clone the Lightning Loop repo and install the command line interface and swap client service.

git clone https://github.com/lightninglabs/loop.git
cd loop/cmd
go install ./...

Execute a Swap

After you have lnd and the Loop client installed, you can execute a Loop swap.

The Loop client needs its own short-lived daemon which will deal with the swaps in progress.

To run this:

`loopd`

// Or if you want to do everything in the same terminal and background loopd
`loopd &`

By default loopd attempts to connect to the lnd instance running on localhost:10009 and reads the macaroon and tls certificate from ~/.lnd. This can be altered using command line flags. See loopd --help.

loopd only listens on localhost and uses an unencrypted and unauthenticated connection.

Now that loopd is running, you can initiate a simple Loop Out. This will pay out Lightning off-chain funds and you will receive Bitcoin on-chain funds in return. There will be some chain and routing fees associated with this swap.

loop out <amt_in_satoshis>

This will take some time, as it requires an on-chain confirmation. When the swap is initiated successfully, loopd will see the process through.

To query in-flight swap statuses, run loop monitor.

Resume

When loopd is terminated (or killed) for whatever reason, it will pickup pending swaps after a restart.

Information about pending swaps is stored persistently in the swap database. Its location is ~/.loopd/<network>/loop.db.

Multiple Simultaneous Swaps

It is possible to execute multiple swaps simultaneously. Just keep loopd running.