Skip to content

ElementsProject/peerswap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

peerswap logo

PeerSwap

Disclaimer: PeerSwap is beta-grade software.

We currently only recommend using PeerSwap with small balances or on signet/testnet

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

The PeerSwap project is not responsible for how you deploy, distribute, or integrate Peerswap. Please refer to your local system administrator, PaaS provider, or appliance distributor. A few community Docker examples can be found here and here. PeerSwap cannot provide official Docker containers for these reasons:

  • PeerSwap CLN plugin must be in the same Docker container as CLN due to how plugins work.
  • PeerSwap LND daemon currently has an issue with Docker's internal networking, therefore the daemon needs to be run inside the same container as LND. Read more.

PeerSwap enables Lightning Network nodes to balance their channels by facilitating atomic swaps with direct peers. PeerSwap enhances decentralization of the Lightning Network by enabling all nodes to be their own swap provider. No centralized coordinator, no 3rd party rent collector, and lowest cost channel balancing means small nodes can better compete with large nodes.

Project Status

PeerSwap is beta-grade software that can be run as a Core Lightning plugin or as a standalone daemon/CLI with LND

As we don't have a proven fee model for swaps yet, we only allow swaps with allowlisted peers.

PeerSwap allows two different types of swaps:

  • Swap-in: trading an onchain-asset for Lightning outbound liquidity
  • Swap-out: trading an onchain-asset for Lightning inbound liquidity

We have a detailed Spec-draft available for review and reimplementation. An interoperable second implementation and discussions toward the next protocol upgrade are currently underway.

Get Involved

Join our Discord to meet other PeerSwap node operators, for support, or to get involved with development as we work toward adding more features and usability improvements.

Peerswap Discord

Follow @PeerSwapLN on Twitter to keep up with project announcements.

Getting Started

Setup

PeerSwap is usable with both Core Lightning and LND implementations:

To run PeerSwap as a Core Lightning plugin, see the CLN setup guide.

To run PeerSwap as a standalone daemon with LND, see the LND setup guide.

To run Elements for L-BTC swaps, see the Elements setup guide.

To run LWK for L-BTC swaps, see the LWK setup guide.

Note
Most of the benefits of PeerSwap come from using L-BTC. Swaps using L-BTC are more private, faster, and avoid the mainchain blockchain during high fee environments that can make swaps uneconomical.

Usage

See the Usage guide for instructions on how to use PeerSwap.

Upgrading

See the Upgrade guide for instructions to safely upgrade your PeerSwap binary.

Further Information

FAQ

  • What is the difference between BTC and L-BTC Swaps?
    • btc vs l-btc
  • Why should use PeerSwap instead of centralized markets for submarine swaps?
    • More Reliable - PeerSwap is significantly more reliable because you are not reliant on unknown channel balances, random network degredation, and slow routing attempts as often occur with multi-hop routes.
    • Lower Cost - PeerSwap is the lowest cost because there is no 3rd party coordinator or intermediary nodes to collect rent.
    • More Private - Swaps are entirely between two consenting nodes. Nobody else is able to record details like who swapped.
  • What is the difference between splicing and PeerSwap?
    • Both PeerSwap and splicing (through Phoenix Wallet) are now usable on mainnet. Splicing is in general better, though PeerSwap can be attractive more for L-BTC swaps that don't touch the mainnet blockchain at all. Splicing and PeerSwap L-BTC swaps are both good for mainnet efficiency.
  • What is the difference between liquidity-ads and PeerSwap?
    • Liquidity Ads is a great way to lease new channels to be opened toward you for the purpose of gaining incoming capacity. New channels add new capacity in a desired direction but only once.
    • PeerSwap lets you repeatedly refill your existing channels at a cost lower than opening, closing, and maintaining additional channels.
  • Why PeerSwap instead of opening more channels?
    • PeerSwap can be more tolerant of onchain confirmation delay than LN channel open/close so BTC onchain fee rates could be lower. Large service providers like stores often close channels when they are depleted because it is capital inefficient to leave them open while unbalanced. Channel closing is often unexpectedly expensive so it is beneficial to reduce the frequency of channel closures.
    • It is more capital efficient to refill channels that already exist rather than open yet more channels with the same peer in order to improve your routing capacity.
    • PeerSwap nodes have the option of alternate swap assets. For example Liquid L-BTC can be faster and with greater transaction privacy (with some trade offs). Additional optional swap methods can be added to PeerSwap for users who want them without affecting users who don't.
  • Why test with Signet instead of Testnet?
    • PeerSwap supports Bitcoin testnet3 but we strongly recommend instead testing with Bitcoin Signet. Testnet has significant reliability problems like often no blocks, or too many blocks, or sometimes 10,000 block reorgs. If your goal is to test software integrations dealing with chaotic situations like reorgs or for race conditions you should be using regtest where you have control of that chaos.

Signet Testing

Core Lightning

For a Core Lightning Bitcoin signet / Liquid testnet setup guide see this guide.

LND

For a LND Bitcoin signet / Liquid testnet setup guide see this guide.

Development

PeerSwap uses the nix package manager for a simple development environment. In order to start hacking, install nix, golang and run nix-shell. This will fetch all dependencies (except golang).