Options
All
  • Public
  • Public/Protected
  • All
Menu

External module "utils"

Index

Functions

ab2hexstring

  • ab2hexstring(arr: any): string
  • Turn array buffer into hex string

    Parameters

    • arr: any

      Array like value

    Returns string

ab2str

  • ab2str(buf: ArrayBuffer | number[]): string
  • Turn ArrayBuffer or array-like oject into normal string

    Parameters

    • buf: ArrayBuffer | number[]

    Returns string

Const axiosPost

  • axiosPost(url: string, params: any): Promise<any>
  • Parameters

    • url: string
    • params: any

    Returns Promise<any>

bool2VarByte

  • bool2VarByte(v: boolean): "01" | "00"
  • return the byte of boolean value

    Parameters

    • v: boolean

    Returns "01" | "00"

generateMnemonic

  • generateMnemonic(size?: number): string
  • Parameters

    • Default value size: number = 16

    Returns string

generateRandomArray

  • generateRandomArray(len: number): ArrayBuffer
  • Generates random ArrayBuffer of specified length.

    Parameters

    • len: number

      Length of the array to generate

    Returns ArrayBuffer

hash160

  • hash160(SignatureScript: string): string
  • Computes ripemd-160 hash of sha-256 hash from hex encoded data.

    Parameters

    • SignatureScript: string

    Returns string

hex2VarBytes

  • hex2VarBytes(hex: string): string
  • return the (length of bytes) + bytes

    Parameters

    • hex: string

      Hex string

    Returns string

hexXor

  • hexXor(str1: string, str2: string): string
  • Do xor operation with two strings

    Parameters

    • str1: string

      Hex string

    • str2: string

      Hex string

    Returns string

hexstr2str

  • hexstr2str(str: string): string
  • Turn hex string into normal string

    Parameters

    • str: string

      Hex string

    Returns string

hexstring2ab

  • hexstring2ab(str: string): number[]
  • Turn hex string into array buffer

    Parameters

    • str: string

      hex string

    Returns number[]

isBase64

  • isBase64(str: string): boolean
  • Parameters

    • str: string

    Returns boolean

now

  • now(): number
  • Gets current time in unix timestamp format.

    Returns number

Const num2VarInt

  • num2VarInt(num: number): string
  • Converts a number to a hex

    Parameters

    • num: number

      The number

    Returns string

    hexstring of the variable Int.

Const num2hexstring

  • num2hexstring(num: number, size?: number, littleEndian?: boolean): string
  • Converts a number to a big endian hexstring of a suitable size, optionally little endian

    Parameters

    • num: number
    • Default value size: number = 1

      The required size in bytes, eg 1 for Uint8, 2 for Uint16. Defaults to 1.

    • Default value littleEndian: boolean = false

      Encode the hex in little endian form

    Returns string

parseMnemonic

  • parseMnemonic(str: string): any
  • Parameters

    • str: string

    Returns any

randomBytes

  • randomBytes(len: number): string
  • Generates random ArrayBuffer of specified length encoded as hex string

    Parameters

    • len: number

      Length of the array to generate

    Returns string

Const reverseHex

  • reverseHex(hex: string): string
  • Reverses a hex string, 2 chars as 1 byte

    Parameters

    • hex: string

      HEX string

    Returns string

    reversed hex string.

ripemd160

  • ripemd160(data: string): string
  • Computes ripemd-160 hash from hex encoded data.

    Parameters

    • data: string

      Hex encoded data

    Returns string

Const sendBackResult2Native

  • sendBackResult2Native(result: string, callback: string): void
  • Parameters

    • result: string
    • callback: string

    Returns void

sha256

  • sha256(data: string): string
  • Computes sha-256 hash from hex encoded data.

    Parameters

    • data: string

      Hex encoded data

    Returns string

str2VarBytes

  • str2VarBytes(str: string): string
  • return the length of string(bytes) + string(bytes)

    Parameters

    • str: string

      Normal string

    Returns string

str2ab

  • str2ab(str: string): ArrayBuffer
  • Turn normal string into ArrayBuffer

    Parameters

    • str: string

      Normal string

    Returns ArrayBuffer

str2hexstr

  • str2hexstr(str: string): string
  • Turn normal string into hex string

    Parameters

    • str: string

      Normal string

    Returns string

varifyPositiveInt

  • varifyPositiveInt(v: number): void

Generated using TypeDoc