fix firefox compatibility issue with buffertools#compare

This commit is contained in:
Matias Alejo Garcia 2014-03-21 18:52:49 -03:00
parent 227a95296b
commit 02296d9517
3 changed files with 5 additions and 4 deletions

View File

@ -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');
}

View File

@ -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() {

View File

@ -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');