Value-for-Value – Lightning ⚡ makes it possible
1. What is the BTCPayWall
The BTCPayWall is a WordPress plugin that you can integrate into your website. With it, anyone can monetize their website quite easily. It is suitable for both large payment amounts and small micropayments. It’s also great for getting donations or grants for a good article, pdf, music, video, et cetera. Many people bring good content to their website, but have no real opportunity to monetize it easily and it is inexpensively with classic systems such as Visa, Mastercard or Paypal. The effort and costs are immense and it is often not worth it. This is now possible thanks to Bitcoin and above all its Lightning ⚡ Network. This is an opportunity for value-for-value and a big step towards disintermediation. This saves unnecessary intermediaries and thus costs. Now it is possible for good values in the form of content to also get good values in the form of satoshis. Everything without permission, P2P, 24/7, immediately, worldwide, independent of intermediaries and with Lightning almost free of charge.
The BTCPayWall currently offers four functions:
- Tipping – Receiving donations and tips – for the free Value for Value model
- Pay-per-post – Selling individual blog posts and articles
- Pay-per-view – Sale of videos that are played directly
- Download Store – Sell digital goods that can be downloaded
2. How does the BTCPayWall work?
The visitor to the website sees a small window box with which he can operate the application. He can either enter and confirm an amount (e.g. in satoshis, euros, etc.). Or he immediately gets suggestions for values and can simply select them by pressing a button. Once he has done that, the BTCPayWall calls a BTCPay Server that contains an [Invoice](https://medium.com/suredbits/lightning-101-what-is- a-lightning-invoice-d527db1a77e6). Of course, this BTCPay server needs a wallet that is connected to the Bitcoin or Lightning network. This can be a Raspiblitz Lightning Fullnode, for example. This full node is your gateway to the Bitcoin and Lightning ⚡ Network.
The BTCPay server can be located on the Raspiblitz. The BTCPay Server creates an invoice, which is then displayed on the website for the user as a QR code. The user can then pay the invoice with his wallet. The node behind the payer’s wallet then seeks a route over the Lightning network to the recipient’s node. Once the satoshis have arrived in the recipient’s wallet, the BTCPay server registers this and transmits this to the website’s BTCPayWall. This can then, for example, call up a "Thank you! 🧡" page or perform another action, such as playing a video or releasing a file for download. If desired, the BTCPay server can also send emails as soon as a payment has been received. The BTCPay server also supports on-chain Bitcoin. Both the BTCPayWall and the BTCPay Server can be individually configured.
Below you can see two variants of the tipping module. The simple tipping box and the wide banners with predefined buttons. The Wide Banner even offers the possibility to leave a message. And please be patient. 🙏 It can take 30-60 seconds ⏳ the first time until the BTCPay server is displayed. The connection via the Tor network must first be established.
With this you can now easily receive donations. The SATS unit is preset and can be changed by the user. Of course you can also set the default to a different unit, e.g. euro. If you then click on "TIPPING NOW", the window for the BTCPay server will open (be patient.. ⏳), where you will then be shown the Lightning invoice or Bitcoin destination address.
The delay comes from connecting through the Tor network. Since the communication runs via several relay stations, it takes time. With a BTCPay server with clearnet, this would be much faster. Here the BTCPay server runs on the Raspiblitz and for my privacy everything runs over Tor. Otherwise it would be very easy to associate the Lightning Node with the IP address of the connection and thus also with the person’s data. This delay time is just a trade-off that you always have to make when using Tor.
With the wide banner version you can also leave a message and request further data such as name, email, address and telephone number. The input can also be requested as mandatory. However, this makes little sense for donations. But just give it a try.
Oh yes.. And don’t despair if a transaction doesn’t work right away. Be happy – you are so early! 😉 The Lightning Node, behind your wallet, probably just didn’t find a suitable route on the first try. Just try it once or twice, it usually works.
Unfortunately, we currently have to open a separate window for the other PayWalls, otherwise they won’t work properly. Here are a few simple examples:
Pay-per-post – A Quot
Pay-per-view – Play Videos
Unfortunately, the download in the Download Store did not work properly when I tried it. But so that you can see how it is structured, here is an example:
Download Store – All pictures of the BTCPayWall tutorial
You can also build a simple download store yourself:
Pay-per-post – Download Store – selfe-made
3. What do I need for the BTCPayWall
The requirements for a BTCPayWall are manageable. You need a well-connected Raspiblitz with active Lightning Channels that also have inbound liquidity. In addition, of course, there is their own website with WordPress, so that you can install the BTCPayWall plugin.
Everything else comes with the installation and is freely available and free of charge. Only the service for the IP2Tor Bridge costs a small fee, which is calculated daily in Lightning Satoshis and immediately transferred from your Lightning Node as a "standing order". That’s 18 sats per 24 hours. This currently corresponds to less than 1 cent (as of 04/22). Which then does not even correspond to 3.50 euros per year. You can also cancel the subscription on a daily basis.
4. What is the technical background of the BTCPayWall?
Many technologies come together here, which makes the whole thing quite complex. But that doesn’t mean that you have to have a lot of experience. You don’t have to be a programmer or have any special skills. One should only roughly understand what the systems do and how they are connected. I’ll explain each and every point, but it helps to get a little overview beforehand so you understand what’s actually happening. For this I have drawn the complete network structure once schematically.
Let’s start with the Raspiblitz. The Raspiblitz is a do-it-yourself lightning node. It is a small single-board computer on which the Raspiblitz software is installed. It comes standard with the Bitcoin and Lightning Fullnode software. He has the complete blockchain stored on his hard drive, manages the Bitcoin and Lightning Wallets for us and provides the tools needed to manage it. But the Raspiblitz can do a lot more, optionally you can also install a block explorer, an Electrum server, LNbits or a BTCPay server.
LND is one of several Lightning implementations. For example, there is also C-Lightning and Eclair. But all are gradually syncing to the same Lightning protocol. That’s what makes it so flexible and incredibly fast-growing.
BTCPay Server is a self-hosted open source cryptocurrency payment processor. It’s secure, private, censorship-resistant, and free. The BTCPay server can be installed on the Raspiblitz. He is responsible for the payment processes of the BTCPayWall.
Everything communicates encrypted via the Tor network with the Bitcoin and the Lightning network. Communication runs through our router and since we use the Tor protocol, we don’t even need to open a port on our router. The Tor network is used to anonymize the connection data. The connection runs through several stations, each of which only knows those upstream and downstream. So it is not possible for the transmitter to follow the whole route. This technically enforces our right to privacy.
The Tor network is also known as the so-called "Darknet". But from there we have to go to the "Clearnet", i.e. to the classic WWW, because our web server is hosted there. An IP2Tor Server does that for us. So a server that lifts the data from the Tor network to the Clearnet and vice versa. This costs a small fee. But thanks to the Lightning ⚡ network, we can now carry out micropayments without any problems. 😁
The IP2Tor server has a fixed IP and also gives us a port number through which we can then be reached. Nowadays, however, every Internet browser requires encryption for the server, otherwise it issues a warning message. This is complex and expensive because you need a certificate (CERT) from a certification authority (CA). That’s why we need a domain through which we can be reached and which can offer us this TLS certificate. Only then does our website start with HTTPS and our browser does not complain because the connection to the site is not secure.
DuckDNS provides a public DNS server from which we receive a freely selectable subdomain. Thanks to the DNS server, we can now forward this domain to an IP address of our choice. The request is therefore forwarded to the IP address of the IP2Tor server via our fixed my.duckdns.org domain. DuckDNS is also a DDNS (Dynamic DNS) service provider. And so our domain always stays the same, even if the IP address of the IP2Tor server should change. The DuckDNS service is free and financed by donations.
LetsEncrypt is a non-profit organization funded by sponsors and donations. It provides the TLS certificate for SSL encryption for our website. The activation and integration of the certificate for our DuckDNS domain is done via the Raspiblitz.
Finally, the Web Server manages our homepage. We create the content of our website with the content management system WordPress, which is an open source project. In WordPress we have the option to install the BTCPayWall plugin. Like almost all projects here, this is also free and open source software on Github. The BTCPayWall plugin offers ready-made blocks that we can integrate into our homepage and that we can then customize. The plugin communicates with the BTCPay server and thus enables the payment process. To do this, the BTCPay server generates a QR code on request, which is displayed on the website and can be scanned by the user with their mobile phone wallet. The QR Code is an (off-chain) Lightning Invoice or an on-chain Bitcoin address. You can determine what should be displayed first and the user can change it later.
If this QR code was scanned with a cell phone wallet like the Bluewallet, then the wallet or the server behind the wallet communicates with our BTCPay server via the Lightning network in order to pay this invoice. Communication takes place via the Lightning network, more precisely via the payment channels (channels) of the network. Since the participants usually do not have a direct channel to each other, you will have to route via additional Lightning Nodes. The wallet or server needs some time to find this route. It can also happen that no route is found right away, so you just have to try once or twice. If the connection is possible, it should also be found. The prerequisite is, of course, that there is enough liquidity in the channels of the route. Instead of the BlueWallet, you can of course use any other Lightning wallet.
If the payment has now been routed and settled, the BTCPay server will display this on the website and the BTCPayWall will carry out the desired action. The BTCPay server also offers the possibility to send an email when receiving a payment.
The same works similarly when paying via the BTCPay server with on-chain Bitcoin. Here the BTCPay server only provides a Bitcoin address. It scans the user’s cell phone wallet. If he confirms the payment, his wallet transmits the signed transaction to his server or to a Bitcoin full node with blockchain. This full node then verifies and shares the new transaction data with other full nodes. The other full nodes then check the validity of this transaction and forward it. Eventually, they arrive at one of the miners, who eventually record the transaction on the blockchain. This in turn registers our BTCPay server and can then report the payment as settled and the BTCPayWall carries out its action again.
5. What do I have to do to set up a BTCPayWall?
I have listed the points below. There’s a lot involved, but every step is explained and provided with a screenshot. So anyone who has a Raspiblitz and a WordPress website should be able to do this.
- Install BTCPay server on the Raspiblitz
- Set up a store with wallets on the BTCPay server
- Set up IP2Tor Bridge
- Call LetsEncrypt service
- Set up DuckDNS
- Set up LetsEncrypt
- Check the data of the service and test the connection
- Install and set up the BTCPayWallet plugin on WordPress
- Get BTCPay Server API Keys
- Adopt and activate API Keys in the BTCPayWall
- Set up the BTCPayWall on the WordPress website
- Finally, you made it. Test the BTCPayWallet
5.1 Install BTCPay Server on the Raspiblitz
- Log in to the Raspiblitz
- Select and install the BTCPay Server app
- Display and remember the BTCPay server information
5.2 Set up a store with wallets on the BTCPay server
- Sign in with the BTCPay server via the browser
- Create a store
- Set up a bitcoin wallet
- Set up a Lightning wallet
5.3 Setup IP2Tor Bridge
- Book the IP2Tor service via the Raspiblitz
- View and remember the access data
- Test the connection to the BTCPay server
5.4 Call LetsEncrypt service
- Call the LetsEncrypt service on the Raspiblitz
- Follow the instructions
5.5 Set up DuckDNS
- Call up the DuckDNS page, preferably via a Tor browser, so that your IP cannot be associated with the domain
- Create an account
- Create a subdomain
- Remember the domain and token
5.6 Set up LetsEncrypt
- Enter the data from DuckDNS on the Raspiblitz
- Select and confirm the service for the IP2Tor Bridge
- Then you have a secure connection from Browser -> Domain -> Bridge -> Node
5.7 Check the data of the service and test the connection
- Check and remember the data of the services
- Test connection to BTCPay server
5.8 Install and set up the BTCPayWallet plugin on WordPress
- Install the BTCPayWall plugin on WordPress
- Provide the BTCPay Server URL in the BTCPayWall
- Follow the link that is then displayed
5.9 Get BTCPay Server API Keys
- Create an API key for "View invoice".
- Create an API key for "Create an invoice".
- View and copy the API keys
5.10 Transfer and activate API Keys to the BTCPayWall
- Adopt the API keys in the BTCPayWall plugin
- Activate the "Payment gateway" for the BTCPay server
5.11 Set up the BTCPayWall on the WordPress website
- Create a block with the BTCPayWall on one side
- Configure the block with the BTCPayWall
5.12 Finally, you made it. Test the BTCPayWallet
- Enter the page, enter an amount and confirm
- A BTCPay Server window with the QR code will appear
- Scan the invoice with a wallet (here BlueWallet)
- Payment successfull
- Call a thank you page as an action
6. Additional comments and notes
If you want more information about the BTCPayWall, I can recommend the coincharge.io pages. And of course the official btcpaywall.com page. Here you will also find detailed descriptions of how you can use and configure the individual functions of the BTCPayWall under Documentation. By the way, coincharge.io has good instructions on how to connect the BTCPay server via the Raspiblitz. The site also has very good content about Bitcoin and Lightning, highly recommended.
A note about the BTCPay Server stores. The server offers the possibility to create several stores for different use cases. Make sure that you create a separate store for the BTCPayWall, accept the API keys individually and select the store explicitly. Otherwise the interface may not work.
If there are several stores that should use the same Lightning financing source, i.e. the same node, you have to work with LNbanks. This is a lightning account system for the BTCPay server. While you can assign a separate wallet for each store with on-chain wallets, with Lightning you have to share the LND wallet with the channels. To arrange this and give out different Lightning accounts, one can install the LNbanks plugin on the BTCPay server.
Here are a few more tips with screenshots:
- Optimization of the wallet setting. The BTCPay server always shows the Lightning Wallet first and pre-assigns the language.
- You can check your SSL status on the website sslshopper.com. You must enter the link to your BTCPay server on the page under "Check the SSL Certificate On Your Site".
7. All free and open source projects
- Bitcoin https://github.com/bitcoin/bitcoin
- LND https://github.com/lightningnetwork/lnd
- Raspiblitz https://github.com/rootzoll/raspiblitz
- Tor Network https://github.com/TheTorProject
- BTCPay Server https://github.com/btcpayserver/btcpayserver
- IP2Tor https://github.com/frennkie/django-ip2tor
- WordPress https://github.com/WordPress
- BTCPayWall https://github.com/coincharge-io/BTCPayWall
- BlueWallet https://github.com/BlueWallet/BlueWallet
And certainly many many more who work quietly in the background. 💛
8. One final thought
And now I ask you, who should stop something like that? Virtually anyone with a little technical understanding can set this up. All components are standard hardware or free and open source software (FOSS). I can store everything myself, accept payments 24/7 worldwide and do not need an intermediary for the financial transaction. As long as the internet is free, nothing in the world will stop people from using Bitcoin. And as long as Bitcoin solves a problem for them, or adds value, they will use it. Bitcoin and Lightning ⚡ are a great revolution that can free us humans from the yoke of centralization.
Be your own bank and stay humble
Thanks to everyone who works tirelessly and free of charge on FOSS projects and supports them. As you can see, you can create incredible things with it and shape the future. Free from centralized hegemony and censorship – for the people – that gives hope. 💚
And finally, a special thanks to Onleines for the BTCPayWall and his spontaneous help setting it up on a Saturday evening. 💙
This bitcoin and open source space is just amazing! ⚡🧡🔥
Created with love 🧡 Block 732111 / updated 767695