bitpay / bitcore-p2p

Interface to the bitcoin P2P network for bitcore
MIT License
81 stars 275 forks source link

message.toBuffer is not a function #91

Open benzmuircroft opened 7 years ago

benzmuircroft commented 7 years ago

Why can't I send messages?

peer.on('ready', function() {
  var message = new Messages({GetBlocks:'GetBlocks'});
  peer.sendMessage(message);
});

/var/sentora/hostdata/zadmin/node_modules/bitcore-p2p/lib/peer.js:194 this.socket.write(message.toBuffer()); ^

TypeError: message.toBuffer is not a function at Peer.sendMessage (/var/sentora/hostdata/zadmin/node_modules/bitcore-p2p/lib/peer.js:194:29) at Peer. (/var/sentora/hostdata/zadmin/private_js/node.js:23:8) at emitNone (events.js:67:13) at Peer.emit (events.js:166:7) at Peer. (/var/sentora/hostdata/zadmin/node_modules/bitcore-p2p/lib/peer.js:85:10) at emitOne (events.js:77:13) at Peer.emit (events.js:169:7) at Peer._readMessage (/var/sentora/hostdata/zadmin/node_modules/bitcore-p2p/lib/peer.js:221:10) at Peer._readMessage (/var/sentora/hostdata/zadmin/node_modules/bitcore-p2p/lib/peer.js:222:10) at Socket. (/var/sentora/hostdata/zadmin/node_modules/bitcore-p2p/lib/peer.js:167:10)