Introducing Bitcoinista
A minimalist python wallet for iOS
Ever since Apple decided to disallow bitcoin wallets in the App Store, bitcoin users who use iOS devices have done one of two things: either ditched (or even destroyed) their iPhones, or tried to find workarounds. One obvious workaround is to jailbreak the device, but this comes with its own complications since it’s not officially supported by Apple. The non-jailbreak workarounds have been either web-based HTML5 wallets such as CoinPunk or native apps distributed through ways that may or may not violate the Apple Enterprise Licence. Today we introduce a new workaround using Python.
Pythonista & pybitcointools
We love to play around with Python on the go using the excellent app Pythonista for iPhone and iPad. In the process of learning the bitcoin protocol we began exploring the pybitcointools library, written by Vitalik Buterin. It was therefore natural to see if we could make pybitcointools run in Pythonista on the iPad.
This did not quite work out of the box, for the following reason: Bitcoin relies
on a number of cryptographic hash functions, one of which is
RIPEMD-160. The standard Python hashlib library contains all of
the required hash functions, but does not have a native implementation of
RIPEMD-160. Instead the hashlib
library uses a generic function hashlib.new()
to request a hash function that our OpenSSL library may offer.
>>> input = "Nobody inspects the spammish repetition" >>> hashlib.new('ripemd160', input).hexdigest() 'cc4a5ce1b3df48aec5d22d1f16b894a0b894eccc'
This call fails in Pythonista, either because the SSL library on iOS does not have this hash function, or because Pythonista does not have the required permissions. Thus we had to create a fallback in pybitcointools where in the case of failure we use a pure Python implementation of RIPEMD-160. After implementing this fallback mechanism, pybitcointools was up and running on our iPad.
Bitcoinista
Next, we created a bitcoin wallet that can be run in Pythonista. The result is Bitcoinista, a very simple wallet with a text-based UI.
The usage is straightforward: first we set up the wallet by either creating a
random key, importing our own key, or creating a key from a brainwallet
passphrase. We then select an encryption password and the private key is
encrypted using AES and stored in a json
file along with the corresponding
address.
Once the wallet is set up, Bitcoinista can do two things:
- Show your balance and address
- Send coins to another address
Sending to another address can be done manually by pasting in the recipients address and typing in the amount. Alternatively, we can use Pythonista’s clipboard module to create transactions from QR codes: simply scan the QR code in your favorite QR code app (ours is Scan), copy the resulting bitcoin URI, and run Bitcoinista. Bitcoinista will then read the URI from the clipboard and automatically create the transaction for you. All you need to do is verify by entering your password.
Bitcoinista uses pybitcointools for checking the wallet balance and sending transactions. Specifically we use the API of blockchain.info to get balance, and as a fallback we use blockr.io. For sending transactions we use blockchain.info and the fallback in this case is the API for eligius.
The main features are
- Runs on iOS without jailbreak (le raison d’etre)
- Open source and runs directly from source code
- Easily send to bitcoin URI after scanning a QR code
- The private key never leaves the device
- Private key encrypted using AES
Links & Installation
Source on github:
https://github.com/christianlundkvist/bitcoinista
Follow the instructions in README.md
to install Bitcoinista on your iOS
device.
Announce post on bitcointalk:
https://bitcointalk.org/index.php?topic=576895
blog comments powered by Disqus