Fix lint for script_number.ts script_signature.ts
This commit is contained in:
parent
c2c650812e
commit
94f3348519
5 changed files with 21 additions and 25 deletions
|
@ -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)
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
2
types/script_number.d.ts
vendored
2
types/script_number.d.ts
vendored
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue