This is a very simple python program that will simulate a few conditions. For the ground work lets set up an Alice and Bob story.
Bob's friend Alice sets up a coffee shop. She is going to start taking cryptocurrency at the coffee shop, so she is set up to accept Bitcoin Cash (BCH) and Bitcoin Core via Lightning (BTCLN). Bob has a substantial holding in both BTC and BCH, though it is all in cold storage in a HW wallet. He does have a Coinbase account but is always very careful to calculate trading fees. So now Bob wants to determine what would be the best way to get ready to move his daily coffee patronage to Alice's shop.
Looking over his past expenses on morning coffee, he decides that 20,000 satoshis (BTC) should be a nice round number for lattes and perhaps 19,000 for coffee. Since BTC is trading at $10,600, his budget in terms of fiat comes out to just about $2 a day. With his budget in hand, he goes about reviewing the BCH and BTCLN payment options. He suspects BTC (mainnet) is too costly since he doesn't want to leave Alice with low priority economical transactions to chase.
His simplest solution of course is just to move BCH from his HW wallet (cold) to his mobile wallet (hot), but he wants to keep his BTC and BCH accounts fairly balanced and doesn't want to deplete his BCH funds entirely. He also wants to pay Alice in both BCH and BTCLN since she seemed excited about her new Point Of Sale system. He had thought about converting some of his BCH to BTC, though he realizes that there is always a cost for this on Coinbase (usually 0.15%).
The next wallet Bob looked at was the Eclair mobile LN wallet. This would be simplest to fund with BTC which of course would have costs in moving funds from his HW wallet to Eclair, and then even more costs opening and closing a channel. He also noted on the github for the project that many LN wallets do not allow fees to be set on channel close operations. This might get costly as market fee rates rise.
Another popular LN solution is Wallet of Satoshi (WoS). WoS seems like a simple solution since it doesn't have the same constraints on incoming and outgoing capacity like Eclair does. There is also no need to do any complicated channel setup since it is custodial and that is all just handled. Bob does realize that WoS funding options might be costly. He researches to ways to load and unload WoS using the FixedFloat exchange as well as the bitrefill Thor channel services.
As noted before with WoS, LN transactions are seamless enough, but WoS has no way to convert funds back to BTC. For this we have to use a LN exchange. FixedFloat is a fairly reasonable exchange offering competitive exchange rates and a 0.5% fee. To convert funds from BTC, WoS has offers a comptitive rate of 0.3%, so obviously this is the simplest way to fund the wallet.
Although not a verify competitive option, the Bitrefill funding option is included here just to see how it stacks up to the others.
I've included two runs of the simluator in LibreOffice format. They should be viewable in Google Sheets, Excel or LibreOffice
This simulated buying lattes (20k) and compared the cost of using various wallets. Important inflection points that were found:
- 17 cups / 3.6 mBTC - If spending less than 3.6 mBTC, it is cheaper to convert the BTC to BCH and just use a BCH wallet. At 17 cups however, using the WoS LN wallet is the cheapest way to spend BTC.
- 39 cups / 8.0 mBTC - If spending less than 8.0 mBTC, it is cheaper to fund your WoS LN using BCH. At 39 cups it becomes less expensive to use BTC to fund your WoS LN wallet.
This simulated buying coffees (10k) and compared the cost of using various wallets. Important inflection points that were found. This simulation did assume that the expensive channel close bug in Eclair was fixed:
- 4 cups / 1.9 mBTC - If spending less than 1.9 mBTC, it is cheaper to convert the BTC to BCH and just use a BCH wallet. At 4 cups however, using the WoS LN wallet is the cheapest way to spend BTC.
- 41 cups / 8.0 mBTC - If spending less than 8.0 mBTC, it is cheaper to fund your WoS LN using BCH. At 41 cups it becomes less expensive to use BTC to fund your WoS LN wallet.
- 853 cups / 163 mBTC - If spending less than 163 mBTC, the average TXN cost of using BCH is cheaper than using BTCLN. At 853 cups (yikes) however, it is cheaper to use BTCLN for coffee than to use BCH.
+README.md
- This file (named for sorting)lnsim.py
- The python file to run the sims, produces CSV to stdoutlatte.ods
- LibreOffice file of sim run for latte prices (no bugfix applied). Selectview-raw
to download.coffee-bugfix.ods
- LibreOffice file of sim run for coffee prices (w/bugfix). Selectview-raw
to download.bch.json
- BCH fee file to use as an argument to compare to LN walletsltc.json
- LTC fee file to use as an argument to compare to LN wallets.gitignore
- A git artifact, as it suggests... please ignore.
To run this, do the following:
git clone https://gist.github.com/brianddk/1f339832a677aa941c7c16a7aeac8735 lnsim
to get files.- Edit
lnsim.py
and update the defines at top of the file to your liking python3 lnsim.py coin.json > results.csv
orpython.exe
in windows- Open
results.csv
in LibreOffice
Coin | Address / QR |
---|---|
BTCLN | https://tippin.me/@dkbriand |
LTC | MKcAge42cX6WZnnPfFGJAxReUYZUbsi6t3 |
LTC-b32 | ltc1q5uucgx9f8n70nq7jmjy03rpg84cm4tm70z5rz6 |
BCH-b32 | qqz77k4rqar3uppj8k28de06narwkqaamcf624p8zl |
ETH / BAT | 0xBc72A79357Ff7A59265725ECB1A9bFa59330DB4b |
Please leave a comment if you have any questions or corrections.