diff --git a/Block.js b/Block.js index 47c0a6bea..84be543ce 100644 --- a/Block.js +++ b/Block.js @@ -195,7 +195,7 @@ Block.prototype.checkMerkleRoot = function checkMerkleRoot(txs) { throw new VerificationError('No merkle root'); } - if (buffertools.compare(this.calcMerkleRoot(txs), this.merkle_root) !== 0) { + if (buffertools.compare(this.calcMerkleRoot(txs), new Buffer(this.merkle_root)) !== 0) { throw new VerificationError('Merkle root incorrect'); } diff --git a/Transaction.js b/Transaction.js index cb4e9c544..a91c95ac4 100644 --- a/Transaction.js +++ b/Transaction.js @@ -46,7 +46,9 @@ TransactionIn.prototype.getScript = function getScript() { TransactionIn.prototype.isCoinBase = function isCoinBase() { if (!this.o) return false; - return buffertools.compare(this.o, COINBASE_OP) === 0; + + //The new Buffer is for Firefox compatibility + return buffertools.compare(new Buffer(this.o), COINBASE_OP) === 0; }; TransactionIn.prototype.serialize = function serialize() { diff --git a/test/test.Block.js b/test/test.Block.js index 771c1e608..b29ffff4e 100644 --- a/test/test.Block.js +++ b/test/test.Block.js @@ -84,7 +84,7 @@ describe('Block', function() { var b = getBlock(); b.getMerkleTree(b.txs).length.should.equal(45); - bitcore.buffertools.toHex(b.calcMerkleRoot(b.txs)).should.equal(bitcore.buffertools.toHex(b.merkle_root)); + bitcore.buffertools.toHex(b.calcMerkleRoot(b.txs)).should.equal(bitcore.buffertools.toHex(new Buffer(b.merkle_root))); b.checkMerkleRoot(b.txs); @@ -177,7 +177,6 @@ describe('Block', function() { }); - it('#createCoinbaseTx should create a tx', function() { var b = new Block(); var pubkey = new Buffer('02d20b3fba521dcf88dfaf0eee8c15a8ba692d7eb0cb957d5bcf9f4cc052fb9cc6');