Skip to content

Python-based tools for exploring the block-lattice used by the Nano cryptocurrency

License

Notifications You must be signed in to change notification settings

paulmelis/nano-tools

Repository files navigation

Nano tools

Some Python-based tools for exploring the Nano block-lattice and LMDB-based database that the Nano wallet and node software at [1] use. Nano (https://nano.org) is a cryptocurrency that aims to be feeless, instant and high throughput. Note that this project has no relation to the official Nano project.

Included is a tool to convert (a subset of) stored blocks to a SQLite database for easy querying with SQL. Also includes an explorer similar to the one on nano.org, mostly for testing, but also usable to browse the data.

In case you find this software useful, donations are welcome at xrb_1mycqeczobsiyerohkmeeyt7ehyyfjyz5h4hi53ffb6p5qjrefzfcrpc454t

Paul Melis (paul.melis@gmail.com)

[1] https://github.com/nanocurrency/raiblocks

Files

Platform notes:

  • All Python scripts are developed for Python 3.x. They might work for 2.x as well, but this isn't tested.
  • In similar fashion the main development platform is Linux, although Windows and macOS should work as well. If you find issues on the non-Linux platforms please submit an issue report at https://github.com/paulmelis/nano-tools/issues
  • On 32-bit systems, or when using a 32-bit version of Python on a 64-bit system, it is not possible to read the Nano LMDB database when its size is >2GB. This limitation has to do with the memory-mapping used by LMDB. In practice, a fully synced node/wallet currently uses more than 4GB, so using the tools below isn't possible on these systems.

The interesting scripts are:

  • dump_wallet_db.py
    • Low-level tool to inspect the contents of the LMDB database used by the Nano wallet/node software.
  • conv2sqlite.py
    • Main script to convert the LMDB-based Nano/RaiBlocks database to a SQLite database
    • Usage:
      1. Close the official Nano wallet/node software, so nothing else is accessing the LMDB database (which by default is at ~/RaiBlocks).
      2. $ ./conv2sqlite.py convert
        This will create a SQLite database called nano.db in the current directory. This step will take a couple of minutes for a fully synced Nano wallet/node, also depending on the speed of the disk being written to.
      3. You should now have a SQLite database file nano.db
    • Note: the SQLite database is by default written in the current directory. You can change the output file with the -d option.
    • If you have enough free memory (say 4-8 GBs) you can generate the SQLite database on a ram-disk, such as /dev/shm on Linux, for faster generation and improved query performance. Copy it to a persistent disk later if needed.
  • nanodb.py
    • A Python module that provides an object-oriented API to the SQLite database created by conv2sqlite.py. This allows easy querying and navigation of blocks, accounts and relations between them. The expl