From dae4c318c210a1fcedc6f3586b0f793a4e5af2bd Mon Sep 17 00:00:00 2001 From: Sky Young Date: Wed, 24 Jul 2019 12:56:36 -0600 Subject: [PATCH] Properly deserialize Block using fcoin --- lib/messages/builder.js | 5 +++-- lib/messages/commands/block.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/messages/builder.js b/lib/messages/builder.js index d56366e..12b5faf 100644 --- a/lib/messages/builder.js +++ b/lib/messages/builder.js @@ -1,6 +1,7 @@ 'use strict'; var bitcore = require('flocore-lib'); +var fcoin = require('fcoin'); var Inventory = require('../inventory'); function builder(options) { @@ -15,9 +16,9 @@ function builder(options) { options.network = bitcore.Networks.defaultNetwork; } - options.Block = options.Block || bitcore.Block; + options.Block = options.Block || fcoin.Block; options.BlockHeader = options.BlockHeader || bitcore.BlockHeader; - options.Transaction = options.Transaction || bitcore.Transaction; + options.Transaction = options.Transaction || fcoin.Transaction; options.MerkleBlock = options.MerkleBlock || bitcore.MerkleBlock; options.protocolVersion = options.protocolVersion || 70001; diff --git a/lib/messages/commands/block.js b/lib/messages/commands/block.js index 4f82fde..eed2b09 100644 --- a/lib/messages/commands/block.js +++ b/lib/messages/commands/block.js @@ -26,7 +26,7 @@ function BlockMessage(arg, options) { inherits(BlockMessage, Message); BlockMessage.prototype.setPayload = function(payload) { - if (this.Block.prototype.fromRaw) { + if (typeof this.Block.fromRaw === 'function') { this.block = this.Block.fromRaw(payload); } else { this.block = this.Block.fromBuffer(payload); @@ -34,7 +34,7 @@ BlockMessage.prototype.setPayload = function(payload) { }; BlockMessage.prototype.getPayload = function() { - if (this.Block.prototype.toRaw) { + if (typeof this.Block.fromRaw === 'function') { return this.block.toRaw(); } return this.block.toBuffer();