Leading Bitcoin Wallet

JSON-RPC Interface for Electrum Daemon

The Electrum daemon accepts commands via JSON-RPC, enabling integration with scripts, such as those written in PHP. By default, the daemon uses a random port. To set a fixed port, use the rpcport configuration variable:

electrum setconfig rpcport 7777

Remember to restart the daemon after changing this setting.

From Electrum 3.0.5 onwards, the JSON-RPC interface uses HTTP Basic Authentication. The system automatically sets a username and generates a random password at first launch. You can view or modify these credentials using these commands:

electrum getconfig rpcuser
electrum getconfig rpcpassword

Be aware that HTTP basic auth sends credentials unencrypted. While safe for localhost use, it’s not secure over untrusted networks or the Internet. For connections beyond localhost, implement additional security measures like encrypted tunnels. Refer this for more details.

Once you’ve set a static port and configured authentication, you can interact with the Electrum daemon using tools like curl or programming languages such as PHP. Here are some examples:

Basic Query

To check your wallet balance, use this curl command:

curl --data-binary '{"jsonrpc":"2.0","id":"curltext","method":"getbalance","params":[]}' http://username:[email protected]:7777

Query with Named Parameters

To list addresses with a positive balance:

curl --data-binary '{"jsonrpc":"2.0","id":"curltext","method":"listaddresses","params":{"funded":true}}' http://username:[email protected]:7777

Creating a Payment Request

To generate a payment request for 3.14 BTC with a memo:

curl --data-binary '{"jsonrpc":"2.0","id":"curltext","method":"add_request","params":{"amount":"3.14","memo":"test"}}' http://username:[email protected]:7777

Table of Contents