Bitcoin App: PeerSwap

Bitcoin App PeerSwap

Share this article

The Lightning Network (also referred to as Lightning or LN) is a scalability solution built on top of the bitcoin main chain that allows users to send and receive BTC with virtually no fees instantly. Lightning is considered to be an off-chain Layer 2 solution, meaning that transfers are done via a new network of payment channels anchored in bitcoin’s blockchain. 

These payment channels first lock up funds on the bitcoin base chain and unlock them in the Lightning network; this takes care of funds being double spent. As long as a channel is open, the funds backing that channel on the base chain cannot be moved. Only once a new channel state is broadcast with the updated balance broadcast back to the base chain can the updated balance be moved or spent on-chain.

The second use of a payment channel is to connect your Lightning balance with other nodes willing to accept payments from you, send payments to you and route payments to and from you. As a Lightning Node, you not only move and spend your funds.

By allowing Lightning channels to connect with one another, the network can find the most effective payment routes. As the Lightning network expands, these routing nodes are moving more payments between them and depending on your connections, your inbound or outbound Liquidity can be drained.

If a Lightning channel becomes unbalanced, it won’t have funds to either send or receive effectively and requires manual intervention to move fund capacity to the side of the channel where it is lacking.

Channels are constantly updating balances.

If your Lightning channel starts to get out of wack, and you’re in danger of not being able to route payments, you could rebalance using one of the following strategies.

  1. Rebalance with splicing
  2. Rebalance using Loops
  3. Rebalance using liquidity markets like Pool and Magma
  4. Rebalance by opening a new channel
  5. Rebalance between your existing channels
  6. Rebalance with a submarine swap

Each rebalancing strategy comes with its own pros and cons when executing, and more importantly, each method will carry a different cost to you as the Lightning Node runner. Any node would want to run a profitable operation, and each time you rebalance, those costs could set you back, which will require you to route even more payments or larger volumes to get back into the black.

Expanding liquidity availability

Despite all the current methods of rebalancing available, it still hasn’t been enough to get Lightning nodes of all sizes to use their liquidity in an optimum fashion. In today’s Lightning network landscape, many nodes suffer from issues like:

  • Most capital tied up in LN channels is stuck forever in unbalanced channels.
  • Unbalanced channels are significantly less productive. Routing algorithms remember failures and try them less often.
  • Most people want channels to be balanced at 50%.
  • Most people would rebalance more often if it were economically viable.
  • Most existing guides encourage opening more channels as the “solution”.
  • Most existing solutions utilise multi-hop routes.

Now that you’re aware of the various issues with Lightning and the current methods of channel rebalancing lets take a look at how PeerSwap compares to the current methods.

PeerSwap versus liquidity markets for submarine swaps

  • More Reliable – PeerSwap is significantly more reliable because you are not reliant on unknown channel balances, random network degradation, 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 can record details like who swapped.

PeerSwap versus splicing

Splicing will take a long time to become code ready and widely available. Meanwhile, PeerSwap is very simple and already works today without changes to existing LN nodes.

PeerSwap versus liquidity ads

  • Liquidity Ads are 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.

PeerSwap versus opening a new channel

  • PeerSwap can be more tolerant of on-chain confirmation delay than LN channel open/close, so BTC on-chain 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 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.

What is PeerSwap?

PeerSwap enables Lightning Network nodes to balance their channels by facilitating atomic swaps with direct peers offering liquidity. PeerSwap aims to enhance the decentralisation of the Lightning Network by enabling all nodes to be their own swap provider.

Instead of posting ads or sourcing liquidity via a centralised coordinator, no 3rd party marketplace, you could, in theory, have access to thousands of offers for liquidity. More nodes providing PeerSwaps would allow for a competitive market for idle liquidity and encourage better use of the entire bitcoin network.

PeerSwap would open up the market to smaller or novice Lightning nodes so that they can source the lowest cost channel balancing means allowing small nodes can better compete with large nodes.

PeerSwap currently has a working implementation for both CLN and LND nodes, while an interoperable implementation for Eclair is in progress, along with protocol improvement discussions. Once the various implementations of Lightning can source liquidity from one another, the bitcoin network or Liquid side chain, it will open up a new market for liquidity to move to where it’s needed most and valued most and thus a new income stream.

What does PeerSwap do?

PeerSwap is not meant to replace the current methods used for channel rebalancing but to compete with them and provide additional options for bitcoiners who run their own node or wallet providers who run nodes on behalf of their users.

  • On-chain atomic swap negotiated over a custom message with direct peers.
  • The opposite approach to most existing balancing methods.
    • If you balance a channel only with direct peers, it is very reliable.
    • Rather than opening more and bigger channels, you can cheaply refill channels you already have to the desired balance.
    • Fixes balance without harming other nodes.
  • Opening new channels is recommended not for the purpose of balancing but if you want a more direct connection with a frequent source/destination node.
  • Multiple optional swap types.
    • Currently, BTC & L-BTC on-chain swaps.
    • Additional wallet options can be implemented.

Benefits of PeerSwap

  • Simple – works with existing LN nodes of today.
  • Lowest cost balancing and rebalancing.
  • Reliable because it only uses a single hop.
  • Fully P2P and decentralized. No coordinator. No 3rd party data collection.
  • There is no need to open yet more channels for balancing
    • Reduces Hot Wallet Risk.
    • Reduces Cost of Capital.
      • More channels == More unproductive
    • Reduces need to pay for incoming capacity.
  • End-users don’t need to open new channels if they don’t want to!

Main chain vs Liquid Swaps

Bitcoin ChainLiquid Network
Native assetBTCL-BTC
Time until swap3 confirmations (+/- 30 mins)2 confirmations (+/- 2 mins)
PrivacyPublicBlinded
ProsTotally trustlessPredictable time to complete
ConsVariable time until the swapFederated custody
Bitcoin vs Liquid Bitcoin submarine swaps

What you need to run PeerSwap

  • You can use PeerSwap with either LND and core-lightning
  • To run PeerSwap as a core-lightning plugin, see the core-lightning setup guide
  • To run PeerSwap as a standalone daemon with LND, see the LND setup guide

Try out PeerSwap on testnet

It’s always important to remember that when trying out new bitcoin software, you are choosing to take on additional risk. While it might be exciting to experiment with new protocols, tools and services, there is always a possibility that this early-stage software could contain vulnerabilities or cause unforeseen issues.

With this in mind, if you are going to test services like PeerSwap, make sure you’re only using funds that you could afford to say goodbye to without it setting you back a few years or months to re-stack.

Alternatively, you could try a safer approach and use one of the public test environments available. PeerSwap supports Bitcoin testnet3, but it is strongly recommended that users test using the Bitcoin Signet instead.

Testnet tends to have reliability problems such as not seeing blocks mined, too many blocks, or sometimes 10,000 block reorgs, which will throw your testing for a loop. If your goal is to test software integrations dealing with chaotic situations like reorgs.

Currently, PeerSwap is suitable for developers and expert node operators with Linux command line skills. Implementations of control panel GUI interfaces are currently underway, which will make PeerSwap easier to use for ordinary end users.


Get the app

There you have it, another application you can try out using bitcoin and its second-layer networks. Interested users can leverage PeerSwap to optimise their overall bitcoin experience when conducting payments or use it as a method to earn some satoshis by supporting swaps.

If you’re new to the Liquid Network or Lightning Network and you’re only getting started with a more advanced wallet and all the things you can and should do, it can be overwhelming but take your time to learn more about each app and why you would want it added to your bitcoin stack.

If you’d like to try out PeerSwap or want to learn more about it, we recommend checking out the following resources for your research.

Are you a bitcoin and lightning fan?

Have you been using Lightning or Liquid to make payments? Stream sats or engage with apps? Which app is your favourite? Have you tried all the forms of bitcoin payments? Which one do you prefer?

Let us know in the comments down below.

Disclaimer: This article should not be taken as, and is not intended to provide any investment advice. It is for educational and entertainment purposes only. As of the time posting, the writers may or may not have holdings in some of the coins or tokens they cover. Please conduct your own thorough research before investing in any cryptocurrency, as all investments contain risk. All opinions expressed in these articles are my own and are in no way a reflection of the opinions of The Bitcoin Manual

Leave a Reply

Related articles

You may also be interested in

FTX repayment plan

How FTX Repayments Will Work

The collapse of FTX in November 2022 marked one of crypto’s largest failures, leaving millions of customers wondering about their funds and a plethora of

Bitcoin ATM bad rap

Bitcoin ATMs Get A Bad Rap

So you want to get some Bitcoin, but you don’t have a bank account or credit card, or you do and don’t want to tie

Cookie policy
We use our own and third party cookies to allow us to understand how the site is used and to support our marketing campaigns.