Options
All
  • Public
  • Public/Protected
  • All
Menu

banotils

Index

Functions

  • bitsNToBits(bitsn: Uint8Array, bitStride: number): Uint8Array
  • Converts the provided N-d bits into 1-d bits

    Parameters

    • bitsn: Uint8Array

      The N-d bits to convert

    • bitStride: number

      The bit stride to use

    Returns Uint8Array

  • bitsToBitsN(bits: Uint8Array, bitStride: number): Uint8Array
  • Converts the provided 1-d bits into N-d bits

    Parameters

    • bits: Uint8Array
    • bitStride: number

      The bit stride to use

    Returns Uint8Array

  • bitsToNumber(bits: Uint8Array, bitStride?: number): number
  • Converts the provided bits into a number

    Parameters

    • bits: Uint8Array

      The bits to convert

    • bitStride: number = 8

      An optional bit stride

    Returns number

  • bytesToBits(bytes: Uint8Array): Uint8Array
  • Converts the provided bytes into their bit equivalent

    Parameters

    • bytes: Uint8Array

      The bytes to convert

    Returns Uint8Array

  • bytesToHex(bytes: Uint8Array): string
  • Converts the provided bytes into their hexadecimal equivalent

    Parameters

    • bytes: Uint8Array

      The bytes to convert

    Returns string

  • clamp(num: number, min: number, max: number): number
  • Clamps the provided number between the given min/max range

    Parameters

    • num: number

      The number to clamp

    • min: number

      The minimum clamp bound

    • max: number

      The maximum clamp bound

    Returns number

  • decimalToHex(decimal: number, bytes: number): string
  • Converts the provided decimal value into the hexadecimal equivalent

    Parameters

    • decimal: number

      The decimal value to convert

    • bytes: number

      The byte stride of the provided value

    Returns string

  • decodeWasmModule(stub: string): Uint8Array
  • Decodes the provided base64 encoded wasm stub

    Parameters

    • stub: string

      The base64 wasm stub

    Returns Uint8Array

  • decryptHash(hash: Uint8Array, password: string, iv?: Uint8Array): Promise<Uint8Array>
  • Decrypts the provided encrypted hash with the given password

    Parameters

    • hash: Uint8Array

      The hash to decrypt

    • password: string

      The password to decrypt the hash with

    • iv: Uint8Array = null

      An optional initialization vector to decrypt with

    Returns Promise<Uint8Array>

  • encryptHash(hash: Uint8Array, password: string, iv?: Uint8Array): Promise<Uint8Array>
  • Encrypts the provided hash with the given password

    Parameters

    • hash: Uint8Array

      The hash to encrypt

    • password: string

      The password to encrypt the hash with

    • iv: Uint8Array = null

      An optional initialization vector to encrypt with

    Returns Promise<Uint8Array>

  • entropyToMnemonic(entropy: Uint8Array): Promise<string>
  • Converts the provided entropy into an equivalent mnemonic

    Parameters

    • entropy: Uint8Array

      The entropy to convert

    Returns Promise<string>

  • fetchRPC(data: any): Promise<any>
  • Manually send a RPC request

    Parameters

    • data: any

      The request data to send

    Returns Promise<any>

  • Generates proof of work for the provided hash

    Parameters

    • hash: Uint8Array

      The hash to generate work for

    • mode: PROOF_OF_WORK_MODE

      Optional proof of work mode to use

    Returns Promise<Uint8Array>

  • generateQRCodeData(text: string, typeNumber?: number): IQRCodeData
  • Returns a QR code representation of the provided text

    Parameters

    • text: string

      The text to generate the QR code for

    • typeNumber: number = 5

      Optional type number

    Returns IQRCodeData

  • getAPIURL(): string
  • Returns the API URL of the used node

    Returns string

  • getAccountAddress(publicKey: Uint8Array): string
  • Returns the relative address of the public key

    Parameters

    • publicKey: Uint8Array

      The public key to derive the address from

    Returns string

  • getAccountBalance(publicKey: Uint8Array): Promise<IAccountBalanceResponse>
  • Returns the balance of the provided account

    Parameters

    • publicKey: Uint8Array

      The public key of the account to query for

    Returns Promise<IAccountBalanceResponse>

  • getAccountHistory(publicKey: Uint8Array, count?: number, reverse?: boolean, head?: Uint8Array): Promise<IAccountHistoryResponse>
  • Returns the history of the provided account

    Parameters

    • publicKey: Uint8Array

      The public key of the account to query for

    • count: number = -1

      Optional limit of history items to query

    • reverse: boolean = false

      Optionally query history items in reverse order

    • head: Uint8Array = null

      Optional block head to start querying at

    Returns Promise<IAccountHistoryResponse>

  • getAccountInfo(publicKey: Uint8Array): Promise<IAccountInfoResponse>
  • Returns the info of the provided account

    Parameters

    • publicKey: Uint8Array

      The public key of the account to query for

    Returns Promise<IAccountInfoResponse>

  • getAccountPending(publicKey: Uint8Array, count?: number, threshold?: bigint): Promise<IAccountPendingResponse>
  • Returns the pending blocks of the provided account

    Parameters

    • publicKey: Uint8Array

      The public key of the account to query for

    • count: number = -1

      Optional limit of pending blocks to query

    • threshold: bigint = ...

      Optional minimum threshold of the pending blocks to query

    Returns Promise<IAccountPendingResponse>

  • getAccountRepresentative(publicKey: Uint8Array): Promise<IAccountRepresentativeResponse>
  • Returns the representative of the provided account

    Parameters

    • publicKey: Uint8Array

      The public key of the account to query for

    Returns Promise<IAccountRepresentativeResponse>

  • getAmountFromRaw(amountRaw: bigint): any
  • Converts the provided raw amount into amount

    Parameters

    • amountRaw: bigint

      The raw amount to convert

    Returns any

  • getPrivateKey(seed: Uint8Array, seedIx?: number): Uint8Array
  • Returns the private key of the provided seed

    Parameters

    • seed: Uint8Array

      The seed to derive from

    • seedIx: number = 0

      The seed index

    Returns Uint8Array

  • getProofOfWorkDifficulty(): number
  • Returns the used proof of work difficulty

    Returns number

  • getPublicKey(input: string | Uint8Array): Uint8Array
  • Returns the public key of the provided input

    Parameters

    • input: string | Uint8Array

      The private key or address to derive from

    Returns Uint8Array

  • getRawFromAmount(amount: string): bigint
  • Converts the provided amount into raw amount

    Parameters

    • amount: string

      The amount to convert

    Returns bigint

  • getWorkCPU(hash: Uint8Array, difficulty: number): Promise<Uint8Array>
  • Calculates work on the CPU for the provided hash

    Parameters

    • hash: Uint8Array

      The hash to calculate work for

    • difficulty: number

      The difficulty of the work to calculate

    Returns Promise<Uint8Array>

  • getWorkGPU(hash: Uint8Array, difficulty: number, dimension?: number): Promise<Uint8Array>
  • Calculates work on the GPU for the provided hash

    Parameters

    • hash: Uint8Array

      The hash to calculate work for

    • difficulty: number

      The difficulty of the work to calculate

    • dimension: number = 3

      Optional canvas dimension

    Returns Promise<Uint8Array>

  • getWorkNODE(hash: Uint8Array): Promise<IWorkGenerateResponse>
  • Calculates work on the NODE for the provided hash

    Parameters

    • hash: Uint8Array

      The hash to calculate work for

    Returns Promise<IWorkGenerateResponse>

  • hexToBytes(hex: string): Uint8Array
  • Converts the provided hex into the equivalent bytes

    Parameters

    • hex: string

      The hex to convert

    Returns Uint8Array

  • isSeedValid(seed: Uint8Array): boolean
  • Indicates if the provided seed is valid

    Parameters

    • seed: Uint8Array

      The seed to check

    Returns boolean

  • isWorkValid(hash: Uint8Array, work: Uint8Array, workMin: bigint): boolean
  • Indicates if the provided hash and work bytes are valid

    Parameters

    • hash: Uint8Array

      The hash to validate

    • work: Uint8Array

      The work to validate

    • workMin: bigint

      The minimum value of the work

    Returns boolean

  • mnemonicToEntropy(mnemonic: string): Promise<Uint8Array>
  • Converts the provided mnemonic into it's equivalent entropy

    Parameters

    • mnemonic: string

      The mnemonic to convert

    Returns Promise<Uint8Array>

  • numberToBits(number: number, bitStride?: number): Uint8Array
  • Converts the provided number into it's bit equivalent

    Parameters

    • number: number

      The number to convert

    • bitStride: number = 8

      An optional bit stride

    Returns Uint8Array

  • openAccount(privateKey: Uint8Array, representative: Uint8Array, pendingHash: Uint8Array, pendingAmount: bigint): Promise<IBlockProcessResponse>
  • Open an account that is currently unopened

    Parameters

    • privateKey: Uint8Array

      The private key of the account

    • representative: Uint8Array

      The representative to link to the account

    • pendingHash: Uint8Array

      The pending hash to open with

    • pendingAmount: bigint

      The pending amount to open with

    Returns Promise<IBlockProcessResponse>

  • receiveAccount(privateKey: Uint8Array, representative: Uint8Array, pendingHash: Uint8Array, pendingAmount: bigint): Promise<IBlockProcessResponse>
  • Receive a pending deposit for the given account

    Parameters

    • privateKey: Uint8Array

      The private key of the account

    • representative: Uint8Array

      The representative to link to the account

    • pendingHash: Uint8Array

      The pending hash to receive

    • pendingAmount: bigint

      The pending amount to receive

    Returns Promise<IBlockProcessResponse>

  • sendAccount(srcPrivateKey: Uint8Array, dstPublicKey: Uint8Array, representativePublicKey: Uint8Array, amount: bigint): Promise<IBlockProcessResponse>
  • Send amount to the given the account

    Parameters

    • srcPrivateKey: Uint8Array

      The private key of the sender account

    • dstPublicKey: Uint8Array

      The public key of the receiver account

    • representativePublicKey: Uint8Array

      The public key of the representative account to use

    • amount: bigint

      The amount to send

    Returns Promise<IBlockProcessResponse>

  • setAPIURL(url: string): Promise<void>
  • Sets the API URL of the node to perform requests with

    Parameters

    • url: string

    Returns Promise<void>

  • setProofOfWorkDifficulty(difficulty: number): void
  • Sets the provided proof of work difficulty

    Parameters

    • difficulty: number

      The proof of work difficulty to use

    Returns void

Generated using TypeDoc