Post
Topic
Board Development & Technical Discussion
Re: Get list of all addresses with a balance over x?
by
Ned Kelly
on 25/12/2017, 00:33:50 UTC

If you are interested to do it in low level.
All data in chainstate files which is leveldb database.
Just iterate over all records in this db and get only records which are below your desirable blockchain hight.

can you share the steps to do this? I would like to try it but i have no idea what leveldb is or what tool you use to get it

As I mentioned, it's low level access. You do not use a tool for it. You need to use some programming language to get access to it.
I myself use C++. Something like that:
Code:
#include "leveldb/db.h"
leveldb::Iterator * it = db->NewIterator(leveldb::ReadOptions());
for (it->SeekToFirst(); it->Valid(); it->Next()) {
size_t keyFieldSize = it->key().size();
size_t valueFieldSize = it->value().size();
vector dbKey( keyFieldSize, 0 );
vector dbValue( valueFieldSize, 0 );
const char * ptrKeyData = it->key().data();
const char * ptrValueData = it->value().data();
memcpy( dbKey.data(), ptrKeyData, keyFieldSize);
memcpy( dbValue.data(), ptrValueData, valueFieldSize);
Also, you need to lock db, otherwise it become corrupt, or just use a copy of it without locking.