Bitcoin Forum
September 25, 2020, 08:26:45 PM *
News: Latest Bitcoin Core release: 0.20.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1] 2 3 4 »  All
  Print  
Author Topic: Electrum Lightning Network walkthrough  (Read 1129 times)
This is a self-moderated topic. If you do not want to be moderated by the person who started this topic, create a new topic. (1 post by 1 user deleted.)
Rath_
aka BitCryptex
Legendary
*
Offline Offline

Activity: 1078
Merit: 1604


Write @Rath or quote my post to notify me


View Profile WWW
July 04, 2020, 06:39:46 PM
Last edit: August 12, 2020, 10:36:44 PM by BitCryptex
Merited by LoyceV (15), malevolent (6), TryNinja (6), Mitchell (5), OmegaStarScream (5), Wind_FURY (5), Quickseller (4), pooya87 (4), o_e_l_e_o (4), 1miau (4), ETFbitcoin (3), Ratimov (3), igor72 (2), d5000 (1), JayJuanGee (1), mocacinno (1), digit (1), Shawshank (1), Pmalek (1), hosseinimr93 (1), Husna QA (1), dkbit98 (1), DireWolfM14 (1), morvillz7z (1), FontSeli (1), akhjob (1), realpseudozach (1)
 #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.

1601065605
Hero Member
*
Offline Offline

Posts: 1601065605

View Profile Personal Message (Offline)

Ignore
1601065605
Reply with quote  #2

1601065605
Report to moderator
1601065605
Hero Member
*
Offline Offline

Posts: 1601065605

View Profile Personal Message (Offline)

Ignore
1601065605
Reply with quote  #2

1601065605
Report to moderator
1601065605
Hero Member
*
Offline Offline

Posts: 1601065605

View Profile Personal Message (Offline)

Ignore
1601065605
Reply with quote  #2

1601065605
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
arorts
Sr. Member
****
Offline Offline

Activity: 408
Merit: 250


View Profile
July 05, 2020, 04:23:00 PM
 #2

Great guide!!

What's the best resolution if stuck with "Reestablishing" channel status for hours and no visible option for a cooperative close?
I already hit the "Freeze (for sending)" option.

Should I just go ahead and force close the channel before taking my computer offline?
Rath_
aka BitCryptex
Legendary
*
Offline Offline

Activity: 1078
Merit: 1604


Write @Rath or quote my post to notify me


View Profile WWW
July 05, 2020, 04:34:25 PM
 #3

What's the best resolution if stuck with "Reestablishing" channel status for hours and no visible option for a cooperative close?

What about the funding transaction? Has it been confirmed yet? As far as I remember, I got the same status when I accidentally closed Electrum before the transaction got confirmed. Electrum might have lost the connection to the node you are trying to open a channel with. In my case, the status changed to 'OPEN' after the transaction has been confirmed.

Should I just go ahead and force close the channel before taking my computer offline?

You should be fine without the force-close for now.

arorts
Sr. Member
****
Offline Offline

Activity: 408
Merit: 250


View Profile
July 05, 2020, 05:31:15 PM
 #4

Thanks. I just discovered I didn't get to sign/broadcast the transaction (but I'm not interested anymore in proceeding with it either).

Is it better to let it expire by itself or force close? Not sure how long it'd take if left alone.
Rath_
aka BitCryptex
Legendary
*
Offline Offline

Activity: 1078
Merit: 1604


Write @Rath or quote my post to notify me


View Profile WWW
July 05, 2020, 05:53:43 PM
 #5

Is it better to let it expire by itself or force close? Not sure how long it'd take if left alone.

Channels time out if the funding transaction is not confirmed within 24 hours so you can leave it be. I am not sure how a force-close would behave in this situation. Theoretically, it shouldn't have any impact on your wallet since you didn't sign the funding transaction.

Ratimov
Hero Member
*****
Offline Offline

Activity: 490
Merit: 2379


Margin enthusiast


View Profile WWW
July 06, 2020, 03:58:07 PM
 #6

Good guide, thanks.  Smiley

Made an adaptation for Russian-speaking users. And user igor72 found an inaccuracy in this paragraph:

Quote
a native SegWit wallet is required (your addresses should start with bc1)


He claims that not all bc1 wallets will work with the Lightning Network.
Only P2WPKH wallets will work, i.e. multi-sig.
2FA and other P2WSHs will not work.





.
.




░██████████████████░
████████████████████
█████████▀░░░███████
█████████░░▄████████
███████▀▀░░▀▀███████
███████▄▄░░▄▄███████
█████████░░█████████

█████████░░█████████

█████████▄▄█████████

████████████████████

░██████████████████░
░██████████████████░
████████████████████
████████████▀▀▀█▀███
███░▀█████▀░░░░░▀███
███▌░░░▀▀▀░░░░░░████
████▄░░░░░░░░░░░████
█████▀░░░░░░░░░█████

██████▄░░░░░▄▄██████

█████▄▄▄▄███████████

████████████████████

░██████████████████░
░██████████████████░
████████████████████
████████████████████
███████████▀▀░░▐████
███████▀▀░░░░░█████
████▀░░░▄█▀░░░▐█████
█████▄▄█▀░░░░░██████

███████▌▄▄▄▐██████

████████████████████

████████████████████

░██████████████████░
ysangkok
Newbie
*
Offline Offline

Activity: 8
Merit: 2


View Profile
July 06, 2020, 04:46:07 PM
 #7

He claims that not all bc1 wallets will work with the Lightning Network.
Only P2WPKH wallets will work, i.e. multi-sig.
2FA and other P2WSHs will not work.

Using P2WPKH does not imply you are using multi-sig, your 'i.e.' is wrong.

Funds spent to bc1 addresses can either be P2WPKH or P2WSH. The length would determine which of these it is.

I think Electrum will not allow you to enable Lightning if you have the wrong wallet type. So I don't know if it really make sense to warn about this up-front, users will find out.
arorts
Sr. Member
****
Offline Offline

Activity: 408
Merit: 250


View Profile
July 06, 2020, 06:06:24 PM
 #8

Channels time out if the funding transaction is not confirmed within 24 hours so you can leave it be. I am not sure how a force-close would behave in this situation. Theoretically, it shouldn't have any impact on your wallet since you didn't sign the funding transaction.

At the moment, the channel status remains unchanged as "reestablishing" so I tried to force close (it warned me it'd take up to 600 blocks to get funds back) but it ultimately failed as it threw this error:

https://imgur.com/a/1HghOwk

It seems as if unsigned Txs have a longer time lock than signed Txs so I guess I shouldn't have to wait longer than 600 blocks to report back my findings.
zx9r_
Newbie
*
Offline Offline

Activity: 17
Merit: 0


View Profile
July 06, 2020, 07:30:17 PM
 #9

Nice tutorial.

Just a typo: When you say "To create an invoice, go to 'Send', fill out 'Description' and 'Requested amount', optionally change when the invoice should expire and press 'Lightning'."

just replace "go to 'Send'" with "go to 'Receive'"
pooya87
Legendary
*
Offline Offline

Activity: 2128
Merit: 3112


Remember tonight for it's the beginning of forever


View Profile
July 07, 2020, 04:17:17 AM
 #10

Quote
a native SegWit wallet is required (your addresses should start with bc1)
He claims that not all bc1 wallets will work with the Lightning Network.
Only P2WPKH wallets will work, i.e. multi-sig.
2FA and other P2WSHs will not work.

for reference: https://github.com/spesmilo/electrum/blob/01a2d127878642c8bcb123e5e7f3de744aeb071c/electrum/wallet.py#L314-L316

by the way P2WPKH is a simple single signature script similar to P2PKH (addresses starting with 1) and has nothing to do with multi-sig. similarly P2WSH is simply a pay to "script hash" scripts which can be multi-sig or any other script.

igor72
Hero Member
*****
Offline Offline

Activity: 896
Merit: 1023


View Profile
July 07, 2020, 05:05:25 AM
Merited by nc50lc (1)
 #11

He claims that not all bc1 wallets will work with the Lightning Network.
Only P2WPKH wallets will work, i.e. multi-sig.
2FA and other P2WSHs will not work.
You made a little typo here, but it changed what I said  Wink.

Here's the corrected text:
Quote
He claims that not all bc1 wallets will work with the Lightning Network.
Only P2WPKH wallets will work. It means that bc1 multi-sig, 2FA and other P2WSHs will not work.
Rath_
aka BitCryptex
Legendary
*
Offline Offline

Activity: 1078
Merit: 1604


Write @Rath or quote my post to notify me


View Profile WWW
July 07, 2020, 09:46:50 AM
 #12

Does "- a P2WPKH wallet is required; this type of wallet is now the default for standard wallets" or "- P2WPKH addresses are required; this kind of addresses are now the default for standard wallets" sound better? Either should be more understandable for most people.

So I don't know if it really make sense to warn about this up-front, users will find out.

SegWit has been the default wallet kind for some time now, but I wanted to mention it in case someone tried to send some coins to an old legacy wallet to test out the LN support. Transaction fees are relatively low right now, but they tend to change rapidly. It could help someone save some money on the fees and there is no harm in mentioning it.

just replace "go to 'Send'" with "go to 'Receive'"

Thanks, fixed.

nc50lc
Legendary
*
Offline Offline

Activity: 1092
Merit: 1456


Self-proclaimed Genius ㊙️


View Profile WWW
July 07, 2020, 12:07:39 PM
 #13

Does "- a P2WPKH wallet is required; this type of wallet is now the default for standard wallets" or "- P2WPKH addresses are required; this kind of addresses are now the default for standard wallets" sound better? Either should be more understandable for most people.
The former sounds right, the latter suggests that a wallet with imported P2WPKH addresses can be used for LN.

Tried it and the "enable" button is disabled for imported wallet with a single native SegWit address.
But it might change in the future because of this message when I clicked help:
Quote from: Electrum 4.0.1
Lightning is currently restricted to HD wallets with p2wpkh addresses.

wchancao
Newbie
*
Offline Offline

Activity: 9
Merit: 1


View Profile
July 19, 2020, 01:45:52 PM
Merited by JayJuanGee (1)
 #14

Hello, i have enable Lightning on Electrum following your steps, channel is Open, but i cant send using Lightning, i have tried sending to 3 different wallets (BLW, Phoenix and Wallet of  Satoshi) and all 3 give me the "Payment Failed. No path found" error. What could it be? How can I solve this issue?
DroomieChikito
Legendary
*
Offline Offline

Activity: 1078
Merit: 1190


Lisan Senjang


View Profile WWW
July 19, 2020, 02:16:16 PM
Merited by JayJuanGee (1), Rath_ (1)
 #15

Hello, i have enable Lightning on Electrum following your steps, channel is Open, but i cant send using Lightning, i have tried sending to 3 different wallets (BLW, Phoenix and Wallet of  Satoshi) and all 3 give me the "Payment Failed. No path found" error. What could it be? How can I solve this issue?

Maybe you have change amount/base unit btc into sat at preference.

 





▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄    ▄▄▄▄                  ▄▄▄   ▄▄▄▄▄        ▄▄▄▄▄   ▄▄▄▄▄▄▄▄▄▄▄▄    ▄▄▄▄▄▄▄▄▄▄▄▄▄▄   ▄▄▄▄▄▄▄▄▄▄▄▄▄▄   ▄▄▄▄▄▄▄▄▄▄▄
 ▀████████████████▄  ████                 █████   ▀████▄    ▄████▀  ▄██████████████   ████████████▀  ▄█████████████▀  ▄█████████████▄
              ▀████  ████               ▄███▀███▄   ▀████▄▄████▀               ████   ████                ████                   ▀████
   ▄▄▄▄▄▄▄▄▄▄▄█████  ████              ████   ████    ▀██████▀      ██████████████▄   ████████████▀       ████       ▄▄▄▄▄▄▄▄▄▄▄▄████▀
   ██████████████▀   ████            ▄███▀     ▀███▄    ████        ████        ████  ████                ████       ██████████████▀
   ████              ████████████▀  ████   ██████████   ████        ████████████████  █████████████▀      ████       ████      ▀████▄
   ▀▀▀▀              ▀▀▀▀▀▀▀▀▀▀▀   ▀▀▀▀   ▀▀▀▀▀▀▀▀▀▀▀▀  ▀▀▀▀        ▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀   ▀▀▀▀▀▀▀▀▀▀▀▀        ▀▀▀▀       ▀▀▀▀        ▀▀▀▀▀

#1 CRYPTO CASINO & SPORTSBOOK
  WELCOME
BONUS
.INSTANT & FAST.
.TRANSACTION.....
.PROVABLY FAIR.
......& SECURE......
.24/7 CUSTOMER.
............SUPPORT.
BTC      |      ETH      |      LTC      |      XRP      |      XMR      |      BNB      |     more
Rath_
aka BitCryptex
Legendary
*
Offline Offline

Activity: 1078
Merit: 1604


Write @Rath or quote my post to notify me


View Profile WWW
July 19, 2020, 02:48:31 PM
Last edit: July 19, 2020, 03:12:39 PM by BitCryptex
Merited by JayJuanGee (1)
 #16

i have tried sending to 3 different wallets (BLW, Phoenix and Wallet of  Satoshi) and all 3 give me the "Payment Failed. No path found" error. What could it be? How can I solve this issue?

Either the node with which you opened a channel is badly connected or there aren't any nodes with enough liquidity to route your payment. You might have made a mistake from the post above. If you didn't specify the node manually when opening the channel then Electrum should have suggested a well-connected node. I am not sure about BlueWallet and Wallet of Satoshi since they are custodial wallets, but channels created using the Phoenix wallet definitely do not have any inbound capacity by default. You will have to spend some of your coins before attempting to receive to it. That's also the case for Eclair Mobile.

wchancao
Newbie
*
Offline Offline

Activity: 9
Merit: 1


View Profile
July 19, 2020, 10:59:33 PM
 #17

i have tried sending to 3 different wallets (BLW, Phoenix and Wallet of  Satoshi) and all 3 give me the "Payment Failed. No path found" error. What could it be? How can I solve this issue?

Either the node with which you opened a channel is badly connected or there aren't any nodes with enough liquidity to route your payment. You might have made a mistake from the post above. If you didn't specify the node manually when opening the channel then Electrum should have suggested a well-connected node. I am not sure about BlueWallet and Wallet of Satoshi since they are custodial wallets, but channels created using the Phoenix wallet definitely do not have any inbound capacity by default. You will have to spend some of your coins before attempting to receive to it. That's also the case for Eclair Mobile.

Yes, I used a suggested node from Electrum, so im asumming that node has enough liquidity... I think i din not make  a mistake following the post above, i read twice before starting, and followed it when i was doing it Electrum... One of the channels I already had in Phoenix has enough inbound capacity...
wchancao
Newbie
*
Offline Offline

Activity: 9
Merit: 1


View Profile
July 19, 2020, 11:14:54 PM
 #18

Hello, i have enable Lightning on Electrum following your steps, channel is Open, but i cant send using Lightning, i have tried sending to 3 different wallets (BLW, Phoenix and Wallet of  Satoshi) and all 3 give me the "Payment Failed. No path found" error. What could it be? How can I solve this issue?

Maybe you have change amount/base unit btc into sat at preference.


I'll switch to sats and let you know if it was that silly detail...  Cheesy
nc50lc
Legendary
*
Offline Offline

Activity: 1092
Merit: 1456


Self-proclaimed Genius ㊙️


View Profile WWW
July 20, 2020, 04:41:40 AM
 #19

-snip-
Yes, I used a suggested node from Electrum, so im asumming that node has enough liquidity... I think i din not make  a mistake following the post above, i read twice before starting, and followed it when i was doing it Electrum... One of the channels I already had in Phoenix has enough inbound capacity...
I'm getting a different error when the receiver's inbound capacity isn't enough, so it can't be the other party's inbound capacity:


I second BitCryptex's first guess, "Payment Failed. No path found" is most likely an issue with your channel's remote node's liquidity.
And I've been getting that error in testnet before when I have only one channel, probably because not all of the suggested nodes are reliable.

wchancao
Newbie
*
Offline Offline

Activity: 9
Merit: 1


View Profile
July 20, 2020, 11:51:10 AM
 #20

-snip-
Yes, I used a suggested node from Electrum, so im asumming that node has enough liquidity... I think i din not make  a mistake following the post above, i read twice before starting, and followed it when i was doing it Electrum... One of the channels I already had in Phoenix has enough inbound capacity...
I'm getting a different error when the receiver's inbound capacity isn't enough, so it can't be the other party's inbound capacity:
https://i.imgur.com/rJNQZAR.png

I second BitCryptex's first guess, "Payment Failed. No path found" is most likely an issue with your channel's remote node's liquidity.
And I've been getting that error in testnet before when I have only one channel, probably because not all of the suggested nodes are reliable.

Yes, im thinking its the remote node problem, i'll try opening another channel with one of ACINQ's node... i'll let you know how that goes... Which other nodes do you recommend? Thanks for your time and answers!
Pages: [1] 2 3 4 »  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!