Tutorial: Creating an Electrum bitcoin wallet plugin

Standard

Electrum is a well known bitcoin wallet.  In this post we will teach you how to create a plugin for the Electrum bitcoin wallet. At the end of the tutorial you should have a reddit tab in your Electrum wallet. (screenshot on bottom of this post)

Installing Electrum from source:
Check out the code from Github

If everything went correct, Electrum should pop up meaning you installed it correctly. Press Tools->Network and disable auto-connect. We can now use several scripts.

Creating an Electrum plugin.
Electrum supports plugins. We will create a simple “news” plugin. Enter these commands:

Create a new file called hello.py and paste this code in it:

Once you restart Electrum. Open Tools->Plugins.  You should then see a new plugin:

If you enable it and press on the tiny  question mark next to it, you should see a nice message.

Neat eh? When developing, you may need to restart Electrum every change or so, which can be a bit annoying but you’ll get used to it. Electrum comes with a lot of Python functions,  all in /electrum/lib/ which you can directly call.

Building a simple plugin
Now that you know ‘the basics’, we will demonstrate how to create a plugin which manipulates the gui.  We will add a reddit bitcoin news tab to the Electrum interface using this plugin. A tab can be added using the command:

The function to add a tab is:

Finally, we should have something to display the website in. We added a webbrowser component, which is part of PyQT.

Putting it all together. Here is the full code that adds a reddit tab to your Electrum wallet:

For those who skipped until here:  copy the above file as reddit.py into /plugins/, restart Electrum, tools->plugins, check Reddit   Finally, you should have this:

Related Post