Accepting Bitcoin Payments on Your Website
This tutorial will show you how to accept Bitcoin on a website with SSL signed payment requests, according to BIP-70. The docs are updated for Electrum 4.0
Last updated
This tutorial will show you how to accept Bitcoin on a website with SSL signed payment requests, according to BIP-70. The docs are updated for Electrum 4.0
Last updated
For details see How to add SSL
Create a wallet on your protected machine, as you want to keep your cryptocurrency safe. If anybody compromise your merchant server, s/he will be able to access read-only version of your wallet only and won’t be able to spent currency.
Please notice that the potential intruder still will be able to see your addresses, transactions and balance, though. It’s also recommended to use a separate wallet for your merchant purposes (and not your main wallet).
Still being on a protected machine, export your Master Public Key (xpub):
Now you are able to set up your electrum merchant daemon.
On the server machine restore your wallet from previously exported Master Public Key (xpub):
Configure your full hostname and port:
Once your read-only wallet is (re-)created, start Electrum as a daemon:
Note: to stop the daemon
This command returns a json object with two URLs:
bip70_url is the URL of the signed BIP70 request.
view_url is the URL of a webpage displaying the request.
You can view the current list of requests using the ‘list_requests’ command. You can clear the list using ‘clear_requests’.
Let us open view_url in a web browser.
The page shows the payment request. You can open the bitcoin: URI with a wallet, or scan the QR code. The bottom line displays the time remaining until the request expires.
The page will update itself when the payment is received, using websockets.
To use lightning, you need to initialize lightning keys in your wallet. You will need to restart the daemon after that, or to stop it before:
Note that it is possible to add lightning keys to a watching-only wallet. That wallet will not be able to spend coins onchain, but it will be able to perform lightning transactions.
The next thing you will need to do is open a channel:
Wait until it is ready to be used:
You will not immediately be able to receive with that channel, because it does not have inbound capacity. If you need to be able to receive immediately, you may do a submarine swap of your channel funds.
To create a lightning payment request: