From 68f3ef599d3801871f49b7cd6734ac3f9db2fa12 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Tue, 23 Feb 2016 00:21:24 -0800 Subject: [PATCH] fixes. --- lib/bcoin/block.js | 7 ++----- lib/bcoin/miner.js | 7 ++----- lib/bcoin/protocol/framer.js | 2 +- lib/bcoin/protocol/parser.js | 2 +- lib/bcoin/tx.js | 2 +- 5 files changed, 7 insertions(+), 13 deletions(-) diff --git a/lib/bcoin/block.js b/lib/bcoin/block.js index 00638d3d..72bbb17a 100644 --- a/lib/bcoin/block.js +++ b/lib/bcoin/block.js @@ -127,7 +127,7 @@ Block.verify = function verify(data, subtype) { }; Block.prototype.render = function render() { - if (this.network && this._raw && this._raw.length > 80) + if (this.network && this._raw) return this._raw; return bcoin.protocol.framer.block(this, this.subtype); }; @@ -561,10 +561,7 @@ Block.prototype.toRaw = function toRaw(enc) { assert(this.subtype === 'block'); - if (this.network && this._raw && this._raw.length > 80) - data = this._raw; - else - data = new Buffer(this.render()); + data = new Buffer(this.render()); if (enc === 'hex') data = utils.toHex(data); diff --git a/lib/bcoin/miner.js b/lib/bcoin/miner.js index cd329dec..676efb36 100644 --- a/lib/bcoin/miner.js +++ b/lib/bcoin/miner.js @@ -231,12 +231,9 @@ Miner.prototype.createBlock = function createBlock(tx) { // miner succeeded. new Buffer(this.msg || 'mined by bcoin', 'ascii') ], - seq: 0xffffffff + sequence: 0xffffffff }); - if (bcoin.script.getSize(coinbase.inputs[0].script) > 100) - throw new Error('Coinbase script is too large'); - coinbase.addOutput({ address: this.address, value: new bn(0) @@ -246,7 +243,7 @@ Miner.prototype.createBlock = function createBlock(tx) { headers = { version: 4, prevBlock: this.last.hash, - merkleRoot: utils.toHex(constants.zeroHash.slice()), + merkleRoot: utils.toHex(constants.zeroHash), ts: ts, bits: target, nonce: 0 diff --git a/lib/bcoin/protocol/framer.js b/lib/bcoin/protocol/framer.js index f92a6e3a..9d9e509a 100644 --- a/lib/bcoin/protocol/framer.js +++ b/lib/bcoin/protocol/framer.js @@ -262,7 +262,7 @@ Framer.prototype._getBlocks = function _getBlocks(cmd, hashes, stop) { } if (stop) { - if (typeof hash === 'string') + if (typeof stop === 'string') stop = new Buffer(stop, 'hex'); len = utils.copy(stop, p, off); } else { diff --git a/lib/bcoin/protocol/parser.js b/lib/bcoin/protocol/parser.js index 9e7884e9..d9c09802 100644 --- a/lib/bcoin/protocol/parser.js +++ b/lib/bcoin/protocol/parser.js @@ -440,7 +440,7 @@ Parser.prototype.parseCoin = function parseCoin(p, extended) { spent = utils.readU8(p, off) === 1; off += 1; } else { - hash = constants.zeroHash; + hash = new Buffer(constants.zeroHash); index = 0xffffffff; spent = false; } diff --git a/lib/bcoin/tx.js b/lib/bcoin/tx.js index 6df99985..2c184927 100644 --- a/lib/bcoin/tx.js +++ b/lib/bcoin/tx.js @@ -832,7 +832,7 @@ TX.prototype.signatureHash = function signatureHash(index, s, type) { // Bitcoind used to return 1 as an error code: // it ended up being treated like a hash. if (index >= copy.outputs.length) - return constants.oneHash.slice(); + return new Buffer(constants.oneHash); // Drop all the outputs after the input index. copy.outputs.length = index + 1;