Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
Fix lint for script_number.ts script_signature.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
junderw committed Mar 7, 2019
1 parent c2c6508 commit 94f3348
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 25 deletions.
10 changes: 5 additions & 5 deletions src/script_number.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ function decode(buffer, maxLength, minimal) {
}
// 32-bit / 24-bit / 16-bit / 8-bit
let result = 0;
for (var i = 0; i < length; ++i) {
for (let i = 0; i < length; ++i) {
result |= buffer[i] << (8 * i);
}
if (buffer[length - 1] & 0x80)
Expand All @@ -45,12 +45,12 @@ function scriptNumSize(i) {
? 1
: 0;
}
function encode(number) {
let value = Math.abs(number);
function encode(_number) {
let value = Math.abs(_number);
const size = scriptNumSize(value);
const buffer = Buffer.allocUnsafe(size);
const negative = number < 0;
for (var i = 0; i < size; ++i) {
const negative = _number < 0;
for (let i = 0; i < size; ++i) {
buffer.writeUInt8(value & 0xff, i);
value >>= 8;
}
Expand Down
12 changes: 5 additions & 7 deletions src/script_signature.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,11 @@ function decode(buffer) {
const hashTypeMod = hashType & ~0x80;
if (hashTypeMod <= 0 || hashTypeMod >= 4)
throw new Error('Invalid hashType ' + hashType);
const decode = bip66.decode(buffer.slice(0, -1));
const r = fromDER(decode.r);
const s = fromDER(decode.s);
return {
signature: Buffer.concat([r, s], 64),
hashType: hashType,
};
const decoded = bip66.decode(buffer.slice(0, -1));
const r = fromDER(decoded.r);
const s = fromDER(decoded.s);
const signature = Buffer.concat([r, s], 64);
return { signature, hashType };
}
exports.decode = decode;
function encode(signature, hashType) {
Expand Down
10 changes: 5 additions & 5 deletions ts_src/script_number.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function decode(

// 32-bit / 24-bit / 16-bit / 8-bit
let result = 0;
for (var i = 0; i < length; ++i) {
for (let i = 0; i < length; ++i) {
result |= buffer[i] << (8 * i);
}

Expand All @@ -50,13 +50,13 @@ function scriptNumSize(i: number): number {
: 0;
}

export function encode(number: number): Buffer {
let value = Math.abs(number);
export function encode(_number: number): Buffer {
let value = Math.abs(_number);
const size = scriptNumSize(value);
const buffer = Buffer.allocUnsafe(size);
const negative = number < 0;
const negative = _number < 0;

for (var i = 0; i < size; ++i) {
for (let i = 0; i < size; ++i) {
buffer.writeUInt8(value & 0xff, i);
value >>= 8;
}
Expand Down
12 changes: 5 additions & 7 deletions ts_src/script_signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ export function decode(buffer: Buffer): ScriptSignature {
if (hashTypeMod <= 0 || hashTypeMod >= 4)
throw new Error('Invalid hashType ' + hashType);

const decode = bip66.decode(buffer.slice(0, -1));
const r = fromDER(decode.r);
const s = fromDER(decode.s);
const decoded = bip66.decode(buffer.slice(0, -1));
const r = fromDER(decoded.r);
const s = fromDER(decoded.s);
const signature = Buffer.concat([r, s], 64);

return {
signature: Buffer.concat([r, s], 64),
hashType: hashType,
};
return { signature, hashType };
}

export function encode(signature: Buffer, hashType: number): Buffer {
Expand Down
2 changes: 1 addition & 1 deletion types/script_number.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
/// <reference types="node" />
export declare function decode(buffer: Buffer, maxLength?: number, minimal?: boolean): number;
export declare function encode(number: number): Buffer;
export declare function encode(_number: number): Buffer;

0 comments on commit 94f3348

Please sign in to comment.