Post
Topic
Board Electrum
Merits 156 from 39 users
Topic OP
Electrum Lightning Network walkthrough
by
BitCryptex
on 04/07/2020, 18:39:46 UTC
⭐ Merited by OmegaStarScream (16) ,LoyceV (15) ,Welsh (15) ,pooya87 (10) ,hugeblack (10) ,malevolent (8) ,TryNinja (6) ,Mitchell (5) ,Wind_FURY (5) ,Cyrus (5) ,DdmrDdmr (5) ,NeuroticFish (5) ,bitmover (5) ,o_e_l_e_o (4) ,1miau (4) ,Quickseller (4) ,ETFbitcoin (3) ,Ratimov (3) ,mocacinno (3) ,Husna QA (3) ,igor72 (2) ,Heisenberg_Hunter (2) ,johhnyUA (2) ,hosseinimr93 (1) ,akhjob (1) ,morvillz7z (1) ,Shawshank (1) ,DireWolfM14 (1) ,dkbit98 (1) ,FontSeli (1) ,Pmalek (1) ,JayJuanGee (1) ,d5000 (1) ,digit (1) ,realpseudozach (1)
Table of contents

      1. Introduction
      2. Creating a payment channel
      3. Sending a payment
      4. Receiving a payment
      5. Closing a channel


Introduction

You don't know what the Lightning Network is? Visit "Basics of The Lightning Network" and "The Lightning Network FAQ" first.

The Lightning Network support has been introduced in the recent Electrum update (4.0.1). Lightning Network support is experimental - neither I nor Electrum will be responsible for any loss of funds. There are many hard-coded values which might become configurable in the future. They can be freely edited in the code starting from here. Not all features that are available in other implementations have been included in this update. For instance, multipart payments are not available in this release.

Important things to note:

- a P2WPKH wallet is required; this type of wallet is now the default for standard wallets,
- Lightning funds cannot be restored from seed. You need to perform backups ('File -> Save backup'). You have to make a new backup every time you open a new channel. Backups will forcefully close channels,
- do not copy your wallet file! If you run an old copy of your wallet with active LN channels, some nodes might broadcast a penalty transaction if any of your channels' balance has changed,
- you can export and import individual channels in the 'Channels' tab. This will not trigger a forceful channel closure,
- in a case of an uncooperative channel close, you have limited time to verify if the other node didn't cheat by broadcasting an old state of the channel (see #5),
- Electrum creates private channels which do not route payments.

In order to use the LN, a few things need to be done. First, you need to enable the Lightning Network support. Go to 'Wallet -> Information' and click on 'Enable' next to the 'Lightning:'





Your wallet will be closed. Launch Electrum again, open your wallet and you will see a new icon in the bottom-right corner. The number indicates the progress of obtaining information about all publicly known nodes and channels. Having an up-to-date map of the network might help with finding the best route for your payments.




Creating a payment channel

Payment channels related options are available under 'Channels' tab which is hidden by default. You can enable it by going to 'View -> Show Channels'



In the 'Channels' tab there are two available options. 'Swap' allows to exchange on-chain coins for an LN incoming payment and vice-versa. 'Open Channel' allows you to create a new payment channel. Click on that option.



Now, you need to specify the amount of BTC that you want to lock up in a channel and the node with which you want to open a channel. If you are not sure which node you should choose, select 'Suggest'. If you want to decide on your own then use this Lightning Network explorer to find a suitable node. As for the amount, the minimum funding value is 0.002 BTC. This is an artificial limitation, hard-coded by Electrum developers.



Next, you have to select the funding transaction fee. If the transaction is not confirmed within 24 hours, the channel won't be created. It is another hard-coded value.



You might encounter these two errors when opening a channel, the former was mentioned above. The latter is other node's fault. Choose a different node if it happens.





Your payment channel will become active once your transaction reaches 3 confirmations.


Sending a payment

Invoiceless payments are not standardized yet, so you need to get an invoice from the person your are trying to send your coins to. Lightning Network payments are routed through other nodes if you are not directly connected to the recipient. Such payments might fail from time to time if there is no route available to the destination node or if the payments is too large. The latter problem has been addressed by splitting one large payment into multiple smaller ones, but this feature is not available in this release. Note that each node participating in the routing process might charge a small fee.

Go to the 'Send' tab and paste your invoice. 'Description' field will be automatically filled since this information is usually provided in the invoice. Note that you will not be able to send all of your coins. Each channel must maintain a reserve for its closure fees. You can see how much you can send from each channel by going to the 'Channels' tab, right-clicking on a channel and selecting 'Details...'. You cannot send from multiple channels at once.



Your transaction might be instant or it might take a few seconds. I have sent a transaction worth about $5.59 (0.00065301 BTC) and paid only a 1 satoshi fee. Your transaction will look like this in the 'History' tab:




Receiving a payment

Before you create an invoice, you need to learn how much you can receive. Your inbound capacity depends on if there is any remote balance on any of the channels. You can't receive payments without spending any coins. Switch to 'Channels' tab, right-click on a channel and select "Details...". You will see 'Can Receive' there. Note that an incoming payment will be sent via a single route to one of your channels so you shouldn't add up all of your channels' inbound capacity just like Electrum does in the 'Channels' tab.



To create an invoice, go to 'Receive', fill out 'Description' and 'Requested amount', optionally change when the invoice should expire and press 'Lightning'. Your invoice will be shown on the right side. Copy it and send it to the other person. Keep in mind that you can't receive payments over the Lightning Network if Electrum is turned off.




Closing a channel

Closing a channel is really simple. Go to the 'Channels' tab, right-click on the channel you want to close and select 'Close channel'. You should use 'Force-close channel' only if the other party is offline. In such a case, you will get your funds back after up to two weeks (2016 blocks). Most channels can be force-closed with a 144 block (~1 day) delay. In both cases, you won't be able to specify the closing transaction fee. Other implementations have such a feature.




This thread is self-moderated just like my FAQ thread to avoid any unnecessary discussion.