Categorygithub.com/lightninglabs/loop
modulepackage
0.29.0-beta.rc2
Repository: https://github.com/lightninglabs/loop.git
Documentation: pkg.go.dev

# README

Lightning Loop

Lightning Loop is a non-custodial service offered by Lightning Labs that makes it easy to move bitcoin into and out of the Lightning Network.

Features

  • Automated channel balancing
  • Privacy-forward non-custodial swaps
  • Opportunistic transaction batching to save on fees
  • Progress monitoring of in-flight swaps

Use Cases

  • Automate channel balancing with AutoLoop (Learn more)
  • Deposit to a Bitcoin address without closing channels with Loop In
  • Convert outbound liquidity into inbound liquidity with Loop Out
  • Refill depleted Lightning channels with Loop In

Installation

Download the latest binaries from the releases page.

Execution

The Loop client needs its own short-lived daemon to facilitate swaps. To start loopd:

loopd

To use Loop in testnet, simply pass the network flag:

loopd --network=testnet

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.

Usage

AutoLoop

AutoLoop makes it easy to keep your channels balanced. Checkout our autoloop documentation for details.

Loop Out

Use Loop Out to move bitcoins on Lightning into an on-chain Bitcoin address.

To execute a Loop Out:

loop out <amt_in_satoshis>

Other notable options:

  • Use the --fast flag to swap immediately (Note: This opts-out of fee savings made possible by transaction batching)
  • Use the --channel flag to loop out on specific channels
  • Use the --addr flag to specify the address the looped out funds should be sent to (Note: By default funds are sent to the lnd wallet)

Run loop monitor to monitor the status of a swap.

Loop In

Use Loop In to convert on-chain bitcoin into spendable Lightning funds.

To execute a Loop In:

loop in <amt_in_satoshis>

More info

For more information about using Loop checkout our Loop FAQs.

Development

Regtest

To get started with local development against a stripped down dummy Loop server running in a local regtest Bitcoin network, take a look at the regtest server environment example documentation.

Testnet

To use Loop in testnet, simply pass the network flag:

loopd --network=testnet

Submit feature requests

The GitHub issue tracker can be used to request specific improvements or report bugs.

Join us on Slack

Join us on the LND Slack and join the #loop channel to ask questions and interact with the community.

LND

Note that Loop requires lnd to be built with all of its subservers. Download the latest official release binary or build lnd from source by following the installation instructions. If you choose to build lnd from source, use the following command to enable all the relevant subservers:

make install tags="signrpc walletrpc chainrpc invoicesrpc"

API

The Loop daemon exposes a gRPC API (defaults to port 11010) and a REST API (defaults to port 8081).

The gRPC and REST connections of loopd are encrypted with TLS and secured with macaroon authentication the same way lnd is.

If no custom loop directory is set then the TLS certificate is stored in ~/.loop/<network>/tls.cert and the base macaroon in ~/.loop/<network>/loop.macaroon.

The loop command will pick up these file automatically on mainnet if no custom loop directory is used. For other networks it should be sufficient to add the --network flag to tell the CLI in what sub directory to look for the files.

For more information on macaroons, see the macaroon documentation of lnd.

NOTE: Loop's macaroons are independent from lnd's. The same macaroon cannot be used for both loopd and lnd.

Build from source

If you’d prefer to build from source:

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

# Packages

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Package liquidity is responsible for monitoring our node's liquidity.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

AcquireRoutingPlugin will return a RoutingPlugin instance (or nil).
CalculateLoopOutCost calculates the total cost of a loop out swap.
IsTaproot returns true if the swap referenced by the passed swap contract uses the v3 (taproot) htlc.
MigrateLoopOutCosts will calculate the correct cost for all loop out swaps and override the cost values of the last update in the database.
NewClient returns a new instance to initiate swaps with.
ReleaseRoutingPlugin will release the RoutingPlugin, allowing other requestors to acquire the instance.
SelectHopHints calls into LND's exposed SelectHopHints prefiltered to the includeNodes map (unless it's empty).
UseLogger uses a specified Logger to output package logging info.
UserAgent returns the full user agent string that identifies the software that is submitting swaps to the loop server.
ValidateLoopInContract validates the contract parameters against our configured maximum values.
Version returns the application version as a properly formed string per the semantic versioning 2.0.0 spec (http://semver.org/) and the commit it was built on.

# Constants

DefaultHtlcConfTarget is the default confirmation target we'll use for on-chain htlcs published by the swap client for Loop In.
DefaultSweepConfTarget is the default confirmation target we'll use when sweeping on-chain HTLCs.
DefaultSweepConfTargetDelta is the delta of blocks from a Loop Out swap's expiration height at which we begin to cap the sweep confirmation target with urgentSweepConfTarget and multiply feerate by factor urgentSweepConfTargetFactor.
MinLoopOutPreimageRevealDelta configures the minimum number of remaining blocks before htlc expiry required to reveal preimage.
RoutingPluginLowHigh is recommended when the client should use low-high routing method.
RoutingPluginNone is recommended when the client shouldn't use any routing plugin.

# Variables

AgentName stores the name of the software that is added as the first part of the user agent string.
Commit stores the current commit hash of this build, this should be set using the -ldflags during compilation.
DefaultMaxHopHints is set to 20 as that is the default set in LND.
ErrExpiryTooFar is returned when the server proposes an expiry that is too far in the future.
ErrExpiryTooSoon is returned when the server proposes an expiry that is too soon.
ErrInsufficientBalance indicates insufficient confirmed balance to publish a swap.
ErrPrepayAmountTooHigh is returned when the prepay invoice amount is too high.
ErrRoutingPluginNoMoreRetries means that the routing plugin can't effectively help the payment with more retries.
ErrRoutingPluginNotApplicable means that the selected routing plugin is not able to enhance routing given the current conditions and therefore shouldn't be used.
ErrSwapAmountTooHigh is returned when the requested swap amount is more than the server maximum.
ErrSwapAmountTooLow is returned when the requested swap amount is less than the server minimum.
ErrSwapFeeTooHigh is returned when the swap invoice amount is too high.
ErrSwapFinalized is returned when a to be executed swap is already in a final state.
MaxLoopInAcceptDelta configures the maximum acceptable number of remaining blocks until the on-chain htlc expires.
MinerFeeEstimationFailed is a magic number that is returned in a quote call as the miner fee if the fee estimation in lnd's wallet failed because of insufficient funds.
MinLoopInExpiryDelta defines the minimum number of remaining blocks that we accept until htlc expiry path that opens up for us to sweep.
MinLoopInPublishDelta defines the minimum number of remaining blocks until on-chain htlc expiry required to proceed to publishing the htlc tx.
TimeoutTxConfTarget defines the confirmation target for the loop in timeout tx.

# Structs

AbandonSwapRequest specifies the swap to abandon.
Client performs the client side part of swaps.
ClientConfig is the exported configuration structure that is required to instantiate the loop client.
HopHintInfo contains the channel information required to create a hop hint.
In contains status information for a loop in swap.
LoopInQuote contains estimates for the fees making up the total swap cost for the client.
LoopInQuoteRequest specifies the swap parameters for which a quote is requested.
LoopInRequest contains the required parameters for the swap.
LoopInSwapInfo contains essential information of a loop-in swap after the swap is initiated.
LoopInTerms are the server terms on which it executes loop in swaps.
LoopOutQuote contains estimates for the fees making up the total swap cost for the client.
LoopOutQuoteRequest specifies the swap parameters for which a quote is requested.
LoopOutSwapInfo contains essential information of a loop-out swap after the swap is initiated.
LoopOutTerms are the server terms on which it executes swaps.
Out contains the full details of a loop out request.
OutRequest contains the required parameters for a loop out swap.
ProbeRequest specifies probe parameters for the server probe.
SelectHopHintsCfg contains the dependencies required to obtain hop hints for an invoice.
ServerUpdate summarizes an update from the swap server.
StaticAddressLoopInRequest contains the required parameters for the swap.
SwapInfo exposes common info fields for loop in and loop out swaps.
SwapInfoKit contains common swap info fields.

# Interfaces

RoutingPlugin is a generic interface for off-chain payment helpers.

# Type aliases

RoutingPluginType represents the routing plugin type directly.