fix reverse buffertools use
This commit is contained in:
parent
bf0010b8ac
commit
966b8988e1
4
Block.js
4
Block.js
|
@ -94,14 +94,14 @@ function spec(b) {
|
|||
|
||||
// TODO: Create a compare method in node-buffertools that uses the correct
|
||||
// endian so we don't have to reverse both buffers before comparing.
|
||||
this.hash.reverse();
|
||||
buffertools.reverse(this.hash);
|
||||
|
||||
if (buffertools.compare(this.hash, target) > 0) {
|
||||
throw new VerificationError('Difficulty target not met');
|
||||
}
|
||||
|
||||
// Return the hash to its normal order
|
||||
this.hash.reverse();
|
||||
buffertools.reverse(this.hash);
|
||||
|
||||
return true;
|
||||
};
|
||||
|
|
|
@ -836,7 +836,7 @@ function spec(b) {
|
|||
|
||||
var w = new Buffer(v.length);
|
||||
v.copy(w);
|
||||
w.reverse();
|
||||
w = buffertools.reverse(w);
|
||||
if (w[0] & 0x80) {
|
||||
w[0] &= 0x7f;
|
||||
return bignum.fromBuffer(w).neg();
|
||||
|
@ -859,9 +859,9 @@ function spec(b) {
|
|||
c = new Buffer(b.length + 1);
|
||||
b.copy(c, 1);
|
||||
c[0] = 0;
|
||||
return c.reverse();
|
||||
return buffertools.reverse(c);
|
||||
} else {
|
||||
return b.reverse();
|
||||
return buffertools.reverse(b);
|
||||
}
|
||||
} else if (cmp == 0) {
|
||||
return new Buffer([]);
|
||||
|
@ -871,10 +871,10 @@ function spec(b) {
|
|||
c = new Buffer(b.length + 1);
|
||||
b.copy(c, 1);
|
||||
c[0] = 0x80;
|
||||
return c.reverse();
|
||||
return buffertools.reverse(c);
|
||||
} else {
|
||||
b[0] |= 0x80;
|
||||
return b.reverse();
|
||||
return buffertools.reverse(b);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -557,7 +557,7 @@ function spec(b) {
|
|||
var ins = this.ins.map(function (txin) {
|
||||
var txinObj = {
|
||||
prev_out: {
|
||||
hash: new Buffer(txin.getOutpointHash()).reverse().toString('hex'),
|
||||
hash: buffertools.reverse(new Buffer(txin.getOutpointHash())).toString('hex'),
|
||||
n: txin.getOutpointIndex()
|
||||
}
|
||||
};
|
||||
|
@ -607,7 +607,7 @@ function spec(b) {
|
|||
txin.q = 0xffffffff;
|
||||
|
||||
var hash = new Buffer(inputobj.txid, 'hex');
|
||||
hash.reverse();
|
||||
hash = buffertools.reverse(hash);
|
||||
var vout = parseInt(inputobj.vout);
|
||||
var voutBuf = new Buffer(4);
|
||||
voutBuf.writeUInt32LE(vout, 0);
|
||||
|
|
|
@ -32,7 +32,7 @@ var formatHash = exports.formatHash = function (hash) {
|
|||
// Make a copy, because reverse() and toHex() are destructive.
|
||||
var hashEnd = new Buffer(10);
|
||||
hash.copy(hashEnd, 0, 22, 32);
|
||||
return hashEnd.reverse().toString('hex');
|
||||
return buffertools.reverse(hashEnd).toString('hex');
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -42,7 +42,7 @@ var formatHashFull = exports.formatHashFull = function (hash) {
|
|||
// Make a copy, because reverse() and toHex() are destructive.
|
||||
var copy = new Buffer(hash.length);
|
||||
hash.copy(copy);
|
||||
var hex = copy.reverse().toHex();
|
||||
var hex = buffertools.reverse(copy).toHex();
|
||||
return hex;
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue