sed -i 's/ var / const /', with const->let fixes

This commit is contained in:
Daniel Cousens 2018-06-25 16:37:45 +10:00
parent 91b8823aa8
commit a5db0a4e44
46 changed files with 776 additions and 769 deletions

View file

@ -15,21 +15,21 @@ function toDER (x) {
function fromDER (x) {
if (x[0] === 0x00) x = x.slice(1)
let buffer = Buffer.alloc(32, 0)
let bstart = Math.max(0, 32 - x.length)
const buffer = Buffer.alloc(32, 0)
const bstart = Math.max(0, 32 - x.length)
x.copy(buffer, bstart)
return buffer
}
// BIP62: 1 byte hashType flag (only 0x01, 0x02, 0x03, 0x81, 0x82 and 0x83 are allowed)
function decode (buffer) {
let hashType = buffer.readUInt8(buffer.length - 1)
let hashTypeMod = hashType & ~0x80
const hashType = buffer.readUInt8(buffer.length - 1)
const hashTypeMod = hashType & ~0x80
if (hashTypeMod <= 0 || hashTypeMod >= 4) throw new Error('Invalid hashType ' + hashType)
let decode = bip66.decode(buffer.slice(0, -1))
let r = fromDER(decode.r)
let s = fromDER(decode.s)
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),
@ -43,14 +43,14 @@ function encode (signature, hashType) {
hashType: types.UInt8
}, { signature, hashType })
let hashTypeMod = hashType & ~0x80
const hashTypeMod = hashType & ~0x80
if (hashTypeMod <= 0 || hashTypeMod >= 4) throw new Error('Invalid hashType ' + hashType)
let hashTypeBuffer = Buffer.allocUnsafe(1)
const hashTypeBuffer = Buffer.allocUnsafe(1)
hashTypeBuffer.writeUInt8(hashType, 0)
let r = toDER(signature.slice(0, 32))
let s = toDER(signature.slice(32, 64))
const r = toDER(signature.slice(0, 32))
const s = toDER(signature.slice(32, 64))
return Buffer.concat([
bip66.encode(r, s),