HI - Looking to receive the latest block as published and confirmed by the node. Review the specific Block for transactions hashes included with in that block?
Thanks
1 Like
Hi Daniel,
To receive the blocks from the network, use the bitcore-p2p
module. http://bitcore.io/guide/module/p2p/index.html
Code will look something like:
var p2p = require('bitcore-p2p');
var Peer = p2p.Peer;
var messages = new p2p.Messages();
peer.on('ready', function() {
console.log('bitcoin p2p connection established');
});
peer.on('inv', function(m) {
peer.sendMessage(messages.GetData(m.inventory));
});
peer.on('block', function(m) {
// new block arrived from the network
console.log(m.block.id);
// iterate over block's transactions
m.block.transactions.forEach(function(tx) {
// do something with the tx
});
});
peer.on('error', function(err) {
console.log(err);
});
peer.connect();
1 Like