Using Armory Secure Wallet With Python

Standard

Armory is an Open-Source wallet with cold storage and multi-signature support Armory was build in Python and parts of the wallet are in C++.  The example code that Armory provides is  outdated, limited needs to be updated to be useful; In this tutorial we show you some examples how to use it.

Installing Armory
If you do not have Armory Secure Bitcoin wallet installed, do this tutorial : https://bitcoinarmory.com/building-from-source/

ArmoryEngine
The main library to use is armoryengine.  This library contains loads of bitcoin related functions. You can use Python 2.7 to communicate with this library. The library has several packages which we will discuss below.

ArmoryEngine  PyBtcWallet
This package is able to interact with wallet files. Create this script:

And save it as example.py inside /BitcoinArmory/.  You can now execute it with:

which should output the address of that wallet. The package has many more functions which you can see in the file /armoryengine/PyBtcWallet.py

ArmoryEngine  PyBtcAddress
This package contains a lot of neat functions for working generating keys.

Generate a bitcoin address from a public key:

Generate a bitcoin address from a private key:

Generate a bitcoin address from a brainwallet key:

this will output the bitcoin address 1CeU9ugjwfsnzrhqjKy1HUBzXCCXVC76m1.

 ArmoryEngine Block
This package is used to interact with the blockchain. Armory is not a lite wallet, it downloads the entire blockchain to the disk.   To print the genisis block use this code:

Remember to put the path to the file correctly. The output should be:

 Get latest block hash from a file

ArmoryEngine  More
There is more stuff inside the library, much more than would fit into a single post. Depending on the interest in this post (feel free to comment), we will add more.

Related Post

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