Update TypeScript to use ! instead of casting
This commit is contained in:
parent
bc28949056
commit
1732bafbc1
17 changed files with 99 additions and 97 deletions
ts_src
|
@ -294,8 +294,8 @@ export class Transaction {
|
|||
if (inIndex >= this.ins.length) return ONE
|
||||
|
||||
// ignore OP_CODESEPARATOR
|
||||
const ourScript = bscript.compile((<Array<Buffer | number>>bscript.decompile(prevOutScript)).filter((x) => {
|
||||
return x !== <number>opcodes.OP_CODESEPARATOR
|
||||
const ourScript = bscript.compile(bscript.decompile(prevOutScript)!.filter((x) => {
|
||||
return x !== opcodes.OP_CODESEPARATOR
|
||||
}))
|
||||
|
||||
const txTmp = this.clone()
|
||||
|
@ -471,28 +471,28 @@ export class Transaction {
|
|||
}
|
||||
|
||||
private __toBuffer (buffer?: Buffer, initialOffset?: number, __allowWitness?: boolean): Buffer {
|
||||
if (!buffer) buffer = <Buffer> Buffer.allocUnsafe(this.__byteLength((<boolean>__allowWitness)))
|
||||
if (!buffer) buffer = <Buffer> Buffer.allocUnsafe(this.__byteLength(__allowWitness!))
|
||||
|
||||
let offset = initialOffset || 0
|
||||
|
||||
function writeSlice (slice: Buffer): void {
|
||||
offset += slice.copy(<Buffer>buffer, offset)
|
||||
offset += slice.copy(buffer!, offset)
|
||||
}
|
||||
|
||||
function writeUInt8 (i: number) {
|
||||
offset = (<Buffer>buffer).writeUInt8(i, offset)
|
||||
offset = (buffer!).writeUInt8(i, offset)
|
||||
}
|
||||
|
||||
function writeUInt32 (i: number) {
|
||||
offset = (<Buffer>buffer).writeUInt32LE(i, offset)
|
||||
offset = (buffer!).writeUInt32LE(i, offset)
|
||||
}
|
||||
|
||||
function writeInt32 (i: number) {
|
||||
offset = (<Buffer>buffer).writeInt32LE(i, offset)
|
||||
offset = (buffer!).writeInt32LE(i, offset)
|
||||
}
|
||||
|
||||
function writeUInt64 (i: number) {
|
||||
offset = bufferutils.writeUInt64LE(<Buffer>buffer, i, offset)
|
||||
offset = bufferutils.writeUInt64LE(buffer!, i, offset)
|
||||
}
|
||||
|
||||
function writeVarInt (i: number) {
|
||||
|
@ -548,7 +548,7 @@ export class Transaction {
|
|||
writeUInt32(this.locktime)
|
||||
|
||||
// avoid slicing unless necessary
|
||||
if (initialOffset !== undefined) return buffer.slice((<number>initialOffset), offset)
|
||||
if (initialOffset !== undefined) return buffer.slice(initialOffset, offset)
|
||||
return buffer
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue