fix firefox compatibility issue with buffertools#compare
This commit is contained in:
parent
227a95296b
commit
02296d9517
2
Block.js
2
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');
|
||||
}
|
||||
|
||||
|
|
|
@ -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() {
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue