Please login or register.

Comprehensive Python module for handling Monero

> What - describe the idea and how you plan to develop it

The idea is to develop a comprehensive Python module for handling Monero. First of all, it will abstract the increasingly complex set of wallet commands into high-level Python classes and types. It will also perform operations on addresses, keys, payment IDs. Most important — but not the only — targets of the software would be:

  • provide layer of abstraction with classes for Wallet, Account, Address, Transaction, etc.
  • provide a loosely-coupled JSON RPC backend to handle communication with the wallet,
  • establish interface for further backends that use channels which exist or may emerge soon (libwallet, 0MQ)
  • encode/decode keys, addresses and mnemonics,
  • use human-friendly Decimal type in all operations, instead of low-level piconero notation,
  • use pythonic data types where possible,
  • signal errors by hierarchical exception types.

> Why - Why do you want to develop this?

There are already two interesting Python projects on GitHub, although both of them I found dead:

pymonerowallet — This project is a result of community funding. It is a thin wrapper around the RPC interface. It was abandoned some time ago and I've forked it to bring it up to date. On the subaddr branch I also have started an adaptation to handle subaddresses and accounts which are already in testing phase of Monero. During that work I submitted a couple of patches to Monero project itself, in order to standarize error signaling or fix minor issues. My general conclusion, however, is that with subaddresses, accounts and upcoming multisig, the operations on JSON primitive types become too complex and error prone. A higher abstraction level interface is necessary.

MoneroPy — This is a small but interesting toolbox that operates on Monero addresses, mnemonics and keys. It is a good inspiration on what the classes for Address and Account should implement in my solution. Unfortunately, the work there has stopped even before the first release. I will very likely reuse parts of that code.

> Who am I?

You'll find me as emes here, emesik on GitHub, e-mess on Reddit and Michał IRL. I'm a software developer with 15 years of professional experience. My main area of expertise is full-stack web development in Python and Javascript, but I don't limit myself to those. I hope my GitHub profile tells a story about my skills.

In the course of my work I designed and coded several complex websites with different payment gateways (PayPal, Stripe, proprietary bank interfaces). This experience with good and bad interfaces, and countless conversations with developers using them, allow me to see what kind of interface would make Python integrations easier to build.

Monero, and cryptocurrencies in general, are quite new experience for me. I learned about Monero about two months ago but my technical skills made me realize instantly that this particular currency has superb technology and great team behind it. I'm all in!

As other community projects I've set up the mempool graphs https://pooldata.xmrlab.com/ and a TOR Monero node http://xmrag4hf5xlabmob.onion/.

> The Proposal and Milestones

Because of my professional commitments I'll be able to work for Monero approximately half-time (20h/w) in the foreseeable future. With such arrangement I predict it would take me about 100h over 5 weeks to complete.

With very fluctuating ~$135/XMR average over the last month, I think a 0.25XMR/h rate would be fair.

The total amount of requested funding is therefore 25 XMR. The project has no milestones but will consist of:

  1. The Python module release 0.1 — it will provide set of classes mentioned above and will communicate with the wallet using JSON RPC. The module itself will be enough to perform the most important operations on multiple wallets: send and receive transactions, retrieve balance and history, create and label accounts and subaddresses, retrieve keys and operate on integrated addresses. It will also include all necessary changes to the Monero code, which I will submit as pull requests and use on my side only when approved.
  2. Unit tests for the code above.
  3. Documentation — a full API docs plus a step-by-step tutorial on how to interact with the wallet. Should any concept become too complex to be clearly explained by words, a picture will be used.

This is the minimal set. There are further ideas (integrate multisig, additional backends, daemon interface, Django integration etc.) but I haven't done enough research to break them down into tasks. Should the time estimate above be excessive I will start an additional task within the funded hours, probably choosing multisig as first.

All code will be released under BSD 3-clause license, one of the most liberal, allowing integration in virtually every environment. The code will be published on GitHub from day 0.

> Expiration

Although the project should have been completed within 5 weeks, I ask for 10 weeks deadline because of my other tasks that may interfere with the development.

— emes

Replies: 11
solartune posted 6 years ago Weight: 0 | Link [ - ]

Hi emes! I'm a software engineer at Cryptosphere Systems AG. The company would like to contribute to Monero community and we're looking for projects where we can be helpful. Please let me know if you need any help with development, I'll be happy to collaborate with you :)

drfred edited 7 years ago Weight: 0 | Link [ - ]

donated

emes posted 7 years ago Weight: 0 | Link [ - ]

I'd like to inform everyone that work has already started. You may check it out here: https://github.com/emesik/monero-python

emes posted 7 years ago Weight: 0 | Link [ - ]

And thanks drfred for your donation!

ibuyltc edited 7 years ago Replies: 1 | Weight: 0 | Link [ - ]

Serhack has created a PHP library with JSON found here: https://github.com/monero-integrations/monerophp, perhaps it will function as a guide to ensure this gets done in under 10 weeks.

Donated.

Reply to: ibuyltc
emes posted 7 years ago Weight: 0 | Link [ - ]

Will check that out. Great thanks!

emes posted 7 years ago Weight: 0 | Link [ - ]

Thank you all for your donations! It sounds lovely to have the funding finished for Christmas :) Please check https://github.com/emesik/monero-python for updates on progress.

cryptobadger edited 7 years ago Replies: 1 | Weight: 0 | Link [ - ]

Hey! The library referenced by you is developed furthere here (simple RPC-Wrapper): https://github.com/cryptobadger/pymonerowallet (shameless plug) Maybe you find code to reuse there..

Reply to: cryptobadger
emes edited 7 years ago Weight: 0 | Link [ - ]

I forked you some time ago and even started implementing subaddresses: https://github.com/emesik/pymonerowallet/tree/subaddr

Then I decided it's time to move on to higher level approach.

emes edited 6 years ago Replies: 1 | Weight: 0 | Link [ - ]

Project report

It took me a little bit more time than expected, but now I can happily announce that we have a working Python module for Monero. With release 0.1.2 all the important features are documented, both as API docs and tutorial-style.

To sum up what the module offers:

  • works with Monero 0.11.x but already handles accounts and sub-addresses which are supposed to land here with the March release,
  • handles communication with the wallet via JSON RPC but new backends can be added easily,
  • allows retrieving balances, history of payments, sending transfers, creating accounts and sub-addresses,
  • provides high level abstraction in nice Pythonic way:
    • amounts are Decimal (Python's precise numeric format)
    • payments lists can be filtered by parameters, like block height or subaddress or payment ID
    • addresses have their own classes that do automatic validation and support extra operations (get spend/view keys, integrate payment ID),
    • throws exceptions on errors.
  • allows for 2-step transaction sending (prepare with wallet, then broadcast via daemon), which is useful for fee verification but can also serve as a tool for wallet separation from the network,
  • supports Python 2.x and 3.x

The development is not over. I'd rather say it's just a beginning. It has already attracted the attention of some developers and I have ideas coming, as well as first code contributions that I received just today. I hope it gets traction, because there are some features I'm not sure about how to implement myself.

The rough roadmap for future development looks as follows:

  • handle payment proofs,
  • add libwallet backend (Python to C++ bindings) that would allow an alternative to JSON RPC and hopefully increase performance on busy wallets,
  • wrap multisig in the code somehow (and yes, I'm also looking here),
  • add tools for generating offline wallets (AKA cold wallets), hopefully with an option to generate sub-addresses.

Please download the code and test mercilessly. Pass this news to fellow Pythonists, to the Django and Flask developer communities. Report the bugs, ask questions and request features!

I'd like to thank all generous donors for their contributions, and the entire community for answering my questions and showing the great spirit of cooperation I've never seen before in another project. Working with you has been a pleasure and I'm sure it remains so in the future.

Thank you!


PS: The development of this project also involved submitting fixes and improvements for the Monero code itself, namely PR# 3010, 3114, 3197 and 3235.

PS2: The module is also available at PyPi under a bit unexpected name, because the service is suffering from a spam attack and has some problems with resulting mess.

Reply to: emes
lza posted 6 years ago Weight: 0 | Link [ - ]

Nice going, dude. Can't wait to get it plugged in and working with Flask!