Get value from leveldb bitcoin using node.js?

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

Дима Марков

Posted 2018-06-07T13:24:33.563

Reputation: 314

looks like it's outputting binary, you need to change the output format? Maybe change encoding?JBaczuk 2018-06-07T13:43:36.560

Are there any assumptions?Дима Марков 2018-06-07T13:59:49.413

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 2018-06-08T03:41:32.393

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.Дима Марков 2018-06-08T08:48:59.370

1If 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 2018-06-10T04:27:20.067

No answers