diff --git a/lib/messages/commands/block.js b/lib/messages/commands/block.js index 6efc257..c4a15aa 100644 --- a/lib/messages/commands/block.js +++ b/lib/messages/commands/block.js @@ -26,11 +26,18 @@ function BlockMessage(arg, options) { inherits(BlockMessage, Message); BlockMessage.prototype.setPayload = function(payload) { - this.block = this.Block.fromRaw(payload); + if (this.Block.prototype.fromRaw) { + this.block = this.Block.fromRaw(payload); + } else { + this.block = this.Block.fromBuffer(payload); + } }; BlockMessage.prototype.getPayload = function() { - return this.block.toRaw(); + if (this.Block.prototype.toRaw) { + return this.block.toRaw(); + } + return this.block.toBuffer(); }; module.exports = BlockMessage; diff --git a/lib/messages/commands/tx.js b/lib/messages/commands/tx.js index 6d57999..836193a 100644 --- a/lib/messages/commands/tx.js +++ b/lib/messages/commands/tx.js @@ -3,6 +3,7 @@ var Message = require('../message'); var inherits = require('util').inherits; var bitcore = require('bitcore-lib'); +var bcoin = require('bcoin'); var $ = bitcore.util.preconditions; var _ = bitcore.deps._; @@ -29,14 +30,19 @@ inherits(TransactionMessage, Message); TransactionMessage.prototype.setPayload = function(payload) { if (this.Transaction.prototype.fromRaw) { - this.transaction = new this.Transaction().fromRaw(payload); + this.transaction = bcoin.tx.fromRaw(payload); + } else if (this.Transaction.prototype.fromBuffer) { + this.transaction = new this.Transaction().fromBuffer(payload); } else { - this.transaction = this.Transaction.fromRaw(payload); + this.transaction = this.Transaction.fromBuffer(payload); } }; TransactionMessage.prototype.getPayload = function() { - return this.transaction.toRaw(); + if (this.Transaction.prototype.toRaw) { + return this.transaction.toRaw(); + } + return this.transaction.toBuffer(); }; module.exports = TransactionMessage; diff --git a/package-lock.json b/package-lock.json index 66b48ad..9dba856 100644 --- a/package-lock.json +++ b/package-lock.json @@ -620,6 +620,16 @@ "resolved": "https://registry.npmjs.org/bn.js/-/bn.js-2.0.4.tgz", "integrity": "sha1-Igp81nf38b+pNif/QZN3b+eBlIA=" }, + "bs58": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/bs58/-/bs58-2.0.0.tgz", + "integrity": "sha1-crcTvtIjoKxRi72g484/SBfznrU=" + }, + "buffer-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/buffer-compare/-/buffer-compare-1.0.0.tgz", + "integrity": "sha1-rKp6lm6Y7un64Usxw5pfFY+zxKI=" + }, "elliptic": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/elliptic/-/elliptic-3.0.3.tgz", @@ -635,6 +645,11 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.1.tgz", "integrity": "sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE=" + }, + "lodash": { + "version": "3.10.1", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=" } } }, @@ -1151,11 +1166,6 @@ "pako": "0.2.9" } }, - "bs58": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/bs58/-/bs58-2.0.0.tgz", - "integrity": "sha1-crcTvtIjoKxRi72g484/SBfznrU=" - }, "buffer": { "version": "4.9.1", "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.1.tgz", @@ -1167,11 +1177,6 @@ "isarray": "1.0.0" } }, - "buffer-compare": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/buffer-compare/-/buffer-compare-1.0.0.tgz", - "integrity": "sha1-rKp6lm6Y7un64Usxw5pfFY+zxKI=" - }, "buffer-crc32": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.1.tgz", @@ -7327,7 +7332,8 @@ "lodash": { "version": "3.10.1", "resolved": "https://registry.npmjs.org/lodash/-/lodash-3.10.1.tgz", - "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=" + "integrity": "sha1-W/Rejkm6QYnhfUgnid/RW9FAt7Y=", + "dev": true }, "lodash._baseassign": { "version": "3.2.0",