use write64 for output values.
This commit is contained in:
parent
10bd983899
commit
37803d178d
@ -300,14 +300,7 @@ Framer.tx = function tx(tx) {
|
||||
for (i = 0; i < tx.outputs.length; i++) {
|
||||
output = tx.outputs[i];
|
||||
|
||||
// Put LE value
|
||||
value = output.value.toArray().slice().reverse();
|
||||
assert(value.length <= 8);
|
||||
|
||||
off += utils.copy(value, p, off, true);
|
||||
|
||||
for (j = value.length; j < 8; j++, off++)
|
||||
p[off] = 0;
|
||||
off += utils.write64(p, output.value, off);
|
||||
|
||||
s = bcoin.script.encode(output.script);
|
||||
off += utils.writeIntv(p, s.length, off);
|
||||
|
||||
@ -1025,14 +1025,14 @@ utils.writeU64 = function writeU64(dst, num, off) {
|
||||
|
||||
off = off >>> 0;
|
||||
|
||||
num = num.maskn(64).toArray();
|
||||
|
||||
while (num.length < 8)
|
||||
num.unshift(0);
|
||||
num = num.toArray().slice(-8);
|
||||
|
||||
for (i = num.length - 1; i >= 0; i--)
|
||||
dst[off++] = num[i] & 0xff;
|
||||
|
||||
for (i = 8 - num.length; i > 0; i--)
|
||||
dst[off++] = 0;
|
||||
|
||||
return 8;
|
||||
};
|
||||
|
||||
@ -1041,15 +1041,15 @@ utils.writeU64BE = function writeU64BE(dst, num, off) {
|
||||
|
||||
if (!(num instanceof bn)) {
|
||||
num = +num;
|
||||
bn = new bn(num);
|
||||
num = new bn(num);
|
||||
}
|
||||
|
||||
off = off >>> 0;
|
||||
|
||||
num = num.maskn(64).toArray();
|
||||
num = num.toArray().slice(-8);
|
||||
|
||||
while (num.length < 8)
|
||||
num.unshift(0);
|
||||
for (i = 8 - num.length; i > 0; i--)
|
||||
dst[off++] = 0;
|
||||
|
||||
for (i = 0; i < num.length; i++)
|
||||
dst[off++] = num[i] & 0xff;
|
||||
@ -1116,10 +1116,7 @@ utils.write64 = function write64(dst, num, off) {
|
||||
|
||||
off = off >>> 0;
|
||||
|
||||
bytes = num.maskn(64).toArray();
|
||||
|
||||
while (bytes.length < 8)
|
||||
bytes.unshift(0);
|
||||
bytes = num.toArray().slice(-8);
|
||||
|
||||
if (num.isNeg())
|
||||
bytes[0] |= 0x80;
|
||||
@ -1127,6 +1124,12 @@ utils.write64 = function write64(dst, num, off) {
|
||||
for (i = bytes.length - 1; i >= 0; i--)
|
||||
dst[off++] = bytes[i] & 0xff;
|
||||
|
||||
for (i = 8 - bytes.length; i > 0; i--)
|
||||
dst[off++] = 0;
|
||||
|
||||
if (num.isNeg())
|
||||
dst[off - 1] |= 0x80;
|
||||
|
||||
return 8;
|
||||
};
|
||||
|
||||
@ -1146,17 +1149,17 @@ utils.write64BE = function write64BE(dst, num, off) {
|
||||
|
||||
off = off >>> 0;
|
||||
|
||||
bytes = num.maskn(64).toArray();
|
||||
bytes = num.toArray().slice(-8);
|
||||
|
||||
while (bytes.length < 8)
|
||||
bytes.unshift(0);
|
||||
|
||||
if (num.isNeg())
|
||||
bytes[0] |= 0x80;
|
||||
for (i = 8 - bytes.length; i > 0; i--)
|
||||
dst[off++] = 0;
|
||||
|
||||
for (i = 0; i < bytes.length; i++)
|
||||
dst[off++] = bytes[i] & 0xff;
|
||||
|
||||
if (num.isNeg())
|
||||
dst[off - 8] |= 0x80;
|
||||
|
||||
return 8;
|
||||
};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user