0

I request information about the block 100001 using leveldb and node js. Below is my code example.

var level = require('level');
var db = level('E:/download/blockchain/block');
var str = '630010ec274a07f88f9b407da4753f91e15ee6bdf52f0bbc0dfc0dadb6815a6c24';
db.get(new Buffer(str, 'hex'), {
    encoding: 'binary'
}, function (err, value) {
    if (err) {
        console.log(err);
    } else {
        console.log(value);
    }
});

And i get this answer:

���Zl$]
    at E:\Work\Crypto\node_modules\levelup\lib\levelup.js:164:15
    at E:\Work\Crypto\node_modules\encoding-down\index.js:51:21

Why is this code throwing an exception, I can't understand. A little help will be appreciated, Thanks

  • looks like it's outputting binary, you need to change the output format? Maybe change encoding? – JBaczuk Jun 7 '18 at 13:43
  • Are there any assumptions? – Дима Марков Jun 7 '18 at 13:59
  • Bitcoin's leveldb is serialized, why not use RPC to parse each block, then each transaction? I don't believe the structure of leveldb is in a format that would allow you to get any useful information just by reading the raw bytes. – m1xolyd1an Jun 8 '18 at 3:41
  • Thanks for the answer. Do you think that this will not take much time? I just need to scan a lot of addresses for the transactions that come to them. – Дима Марков Jun 8 '18 at 8:48
  • 1
    If you want to learn about transactions affecting certain addresses, make the wallet watch for those addresses. There is no information per address available in Bitcoin Core's LevelDB database, plus if you do this kind of thing while Bitcoin Core is running you may corrupt the database. It is not designed to be usable or useful for any other applications, or any purpose besides validating transactions. – Pieter Wuille Jun 10 '18 at 4:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.