I will take the following case as an example: I have BTC that I want to exchange for XSN.
In this case, I will have to open a BTC Lightning channel (to be able to send BTC), and I will have to rent an XSN Lightning channel (to be able to receive XSN).
Disclaimer
Stakenet LW & DEX is still in beta testing, the software may contain known or unknown bugs. If you agree to use it, you do so at your own risk.
Launch Stakenet Light Wallet
Once you’ve started Stakenet LW, click on “Get Started”.
Please read the disclaimer carefully.
If you do not agree, click on “Cancel” (this will close the software).
If you agree with the terms and conditions, click on “I agree”.
Back up your Seed Phrase
The seed phrase is a list of 24 words which store all the information needed to recover your on-chain funds.
Click on “Settings”, “Backup”, then “Show Seed Phrase” to display the 24-word seed phrase. Write down the seed phrase on paper.
Never store the seed phrase digitally because anybody else who discovers the phrase could steal your funds.
Thanks to the seed phrase, in case there is a problem, you can download the Stakenet LW again and use the paper backup to get your on-chain funds back.
The way to backup your Lightning channels (off-chain funds) will be described further on.
Enable a trading pair in the DEX
Click on the DEX tab, then select the trading pair of your choice.
In this example, I chose the XSN/BTC pair because I want to exchange BTC for XSN.
Fund your on-chain wallet
While Stakenet LW synchronizes with the Lightning Network, you can fund the wallet with the asset you want to exchange (in this case BTC).
Click on the “Wallets” tab, then select the asset (Bitcoin — BTC), then click on “Receive”.
Click on the Copy icon to copy your on-chain address for the selected asset, and send funds to that address.
The default address format is native SegWit (Bech32). Bech32 addresses begin with “bc1” for Bitcoin, “ltc1” for Litecoin, and “xc1” for Stakenet.
Some wallets or exchanges may not be compatible with this address format. You may need to use a third party wallet in this case.
Open a Lightning Channel
To be able to open a Lightning channel, you have to wait until:
- The transaction with the received funds is confirmed on the blockchain (status: “Success” in “Transactions” tab).
- The wallet is fully synchronized with the Lightning Network for both assets you’re going to exchange (“L2 active” — L2 meaning Layer 2).
On first startup, this might take some time especially for Bitcoin. This happens only on initial synchronization. On subsequent wallet launches, the synchronization for Bitcoin will take at most a couple of minutes.
At this point, you can open a Lightning channel by moving the cursor of the Lightning channel slider to the right (see screenshot). By moving the slider, you can select the percentage of funds you will send from on-chain to the Lightning Network.
Once you release the slider, a confirmation window will appear in which you can select the on-chain fee rate for the channel funding transaction (the funding transaction is the on-chain transaction that opens a Lightning channel).
Once the channel funding transaction has been broadcast, you will have to wait until it is confirmed on the blockchain (status: “Success” in “Transactions” tab). When the funding transaction is confirmed on the blockchain, the channel is officially open. You can verify that the channel is indeed open and active by clicking on the “Channels” tab. If so, you can move on to the next step (channel rental).
Rent a Lightning Channel
Lightning channels are single-funded bi-directional payment channels.
Bi-directional means that the funds can go both ways (both directions).
Single-funded means that at the beginning, the funds on the channel are on the side of the peer that has opened it, i.e. on their local balance (the balance on your side is the local balance, the balance on the other side is the remote balance).
Now that you have opened a BTC Lightning channel, you can send BTC through the Lightning Network, because the channel you have opened has local balance.
However, you cannot receive XSN via the Lightning Network (yet). For that, you will need another peer to open an XSN Lightning channel to your wallet: this channel will have remote balance (from your point of view), allowing you to receive XSN over the Lightning Network.
To make things easier for the user, Stakenet LW offers a channel rental service. We will use that service to rent an inbound XSN Lightning channel.
This rental will be paid with BTC through a Lightning transaction.
Click on the “Wallets” tab, select “Stakenet — XSN”, click on the “Channels” tab, then on “Channel Rental”. This will open a confirmation window where you can select the asset in which you are going to pay for the rental. In this case, as you have an open BTC channel, you will pay in BTC. Click on “Confirm” to rent the channel.
Check the status of the rented channel in the “Channels” tab. Once the rented channel changes from “pending” to “active” status, you can go to the next step (trading on the DEX).
Trade on the DEX
Now that you have an active BTC channel with local balance, and an active XSN channel with remote balance, you can trade BTC for XSN on the DEX.
To do so, click on the “DEX” tab, select “Buy XSN”, choose either “Limit” or “Market”, enter the amount you want to trade, then click on “Buy”.
There you go! You have made a cross-chain atomic swap through the Lightning Network!
Back up your Lightning Channels
We saw earlier how to save your seed phrase, to be able to recover your on-chain funds (in case of a problem). But how to recover your off-chain funds? With Channel Backups.
Channel Backups are automatically generated each time a channel is created. The backups themselves are encrypted using a key derived from the user’s seed, so you can’t recover the channels if you don’t have the seed phrase that was used to open those channels.
It is recommended to make a copy of the channel backup file for each asset (one backup file per asset), and each time a new channel is created.
Save this copy to a device other than your computer, so that in case of a problem, you will be able to recover both your on-chain and off-chain funds using the combination of the seed phrase and the channel backup files.
In the example presented here (BTC and XSN channels), it is therefore recommended to make a copy of the BTC channel backup file, and a copy of the XSN channel backup file.
To do so, click on “Wallets” tab, select the asset, click on “Channels”, click on the gear icon, then on “Backup”. In the Backup window, click on “Export Backup” then select the path where to export the channel backup file.
Repeat the process for each asset with open Lightning channels.
Join Stakenet’s Discord — https://discord.gg/cyF5yCA — and let us know if you have any questions.