I am trying to decode the bitcoin block, but when I am trying to read magic number which are first four bytes , it is showing me some different result then 0xD9B4BEF9. can anyone help me with this issue? My code is as follows:
fs = require('fs');
bitcore = require('bitcoinjs-lib');
BlockStream = require('blkdat-stream');
glob =require('glob');
combinedstream = require('Combined-stream');
pipe = require('pipe-functions');
var cs = combinedstream.create(); var buf = [],json = [];
datafile = 'File path/blocks/blk00350.dat';
cs.append(fs.createReadStream(datafile))
var bds = new BlockStream()
bds.on('data', function (data) { var key = "data";
console.log(data);
console.log(data.readInt32LE(0,4));
})
cs.pipe(bds);