How to accept Bitcoin on website?
This tutorial will show you how to accept Bitcoin on a website with SSL signed payment requests. It is updated for Electrum 2.6.
Requirements
- A webserver serving static HTML
- A SSL certificate (signed by a CA)
- Electrum version >= 2.6
Create a wallet
Create a wallet on your web server:
You can also use a watching only wallet (restored from xpub), if you want to keep private keys off the server.
Once your wallet is created, start Electrum as a daemon:
Add your SSL certificate to your configuration
You should have a private key and a public certificate for your domain.
Create a file that contains only the private key:
-BEGIN PRIVATE KEY- your private key -BEGIN END KEY-
Set the path to your the private key file with setconfig:
electrum setconfig ssl_privkey /path/to/ssl.key
Create another file, file that contains your certificate, and the list of certificates it depends on, up to the root CA. Your certificate must be at the top of the list, and the root CA at the end.
-BEGIN CERTIFICATE- your cert -END CERTIFICATE- -BEGIN CERTIFICATE- intermediate cert -END CERTIFICATE- -BEGIN CERTIFICATE- root cert -END CERTIFICATE-
Set the ssl_chain path with setconfig:
electrum setconfig ssl_chain /path/to/ssl.chain
Configure a requests directory
This directory must be served by your webserver (eg Apache)
electrum setconfig requests_dir /var/www/r/
electrum setconfig url_rewrite "['file:/var/www/',
Create a signed payment request
electrum addrequest 3.14 -m "this is a test" { "URI":, "address": "1MP49h5fbfLXiFpomsXeqJHGHUfNf3mCo4", "amount": 314000000, "amount (BTC)": "3.14", "exp": 3600, "id": "7c2888541a", "index_url": "memo": "this is a test", "request_url": "status": "Pending", "time": }
This command returns a json object with two URLs:
- request_url is the URL of the signed BIP70 request.
- index_url is the URL of a webpage displaying the request.