# Class HavenoUtils

Collection of utilities for working with Haveno.

#### Hierarchy

- HavenoUtils

- Defined in src/utils/HavenoUtils.ts:26

#####
Index

### Constructors

constructor

### Properties

AU_PER_XMR
lastLogTimeMs
logLevel
months

### Methods

abs
atomicUnitsToXmr
divide
formToString
formatTimestamp
getFormValue
getLogLevel
getPaymentMethodId
hasFormField
kill
log
max
multiply
percentageDiff
setFormValue
setLogLevel
waitFor
xmrToAtomicUnits

## Constructors

### constructor

- new HavenoUtils(): HavenoUtils

- #### Returns HavenoUtils

## Properties

### `Static` AU_PER_XMR

AU_PER_XMR: bigint = ...

- Defined in src/utils/HavenoUtils.ts:31

### `Static` lastLogTimeMs

lastLogTimeMs: number = 0

- Defined in src/utils/HavenoUtils.ts:30

### `Static` logLevel

logLevel: number = 0

- Defined in src/utils/HavenoUtils.ts:28

### `Static` months

months: string[] = ...

- Defined in src/utils/HavenoUtils.ts:29

## Methods

### `Static` abs

- abs(a: bigint): bigint

- Return the absolute value of the given bigint.

  ### Returns

  the absolute value of the given bigint

  #### Parameters

  - ##### a: bigint

    the bigint to get the absolute value of

  #### Returns bigint

  - Defined in src/utils/HavenoUtils.ts:163

### `Static` atomicUnitsToXmr

- atomicUnitsToXmr(amountAtomicUnits: string | bigint): number

- Convert atomic units to XMR.

  ### Returns

  amount in XMR

  #### Parameters

  - ##### amountAtomicUnits: string | bigint

    amount in atomic units to convert to XMR

  #### Returns number

  - Defined in src/utils/HavenoUtils.ts:120

### `Static` divide

- divide(au1: bigint, au2: bigint): number

- Divide one atomic units by another.

  ### Returns

  the result

  #### Parameters

  - ##### au1: bigint

    dividend

  - ##### au2: bigint

    divisor

  #### Returns number

  - Defined in src/utils/HavenoUtils.ts:131

### `Static` formToString

- formToString(form: PaymentAccountForm): string

- Stringify a payment account form.

  ### Returns

  the stringified form

  #### Parameters

  - ##### form: PaymentAccountForm

    form to stringify

  #### Returns string

  - Defined in src/utils/HavenoUtils.ts:204

### `Static` formatTimestamp

- formatTimestamp(timestamp: number): string

- Format a timestamp as e.g. Jul-07 hh:mm:ss:ms. // TODO: move to GenUtils?

  ### Returns

  the formatted timestamp

  #### Parameters

  - ##### timestamp: number

    the timestamp in milliseconds to format

  #### Returns string

  - Defined in src/utils/HavenoUtils.ts:74

### `Static` getFormValue

- getFormValue(form: PaymentAccountForm, fieldId: FieldId): string

- Get a form field value.

  ### Returns

  the form field value

  #### Parameters

  - ##### form: PaymentAccountForm

    form to get the field value from

  - ##### fieldId: FieldId

    id of the field to get the value from

  #### Returns string

  - Defined in src/utils/HavenoUtils.ts:234

### `Static` getLogLevel

- getLogLevel(): number

- Get the log level.

  ### Returns

  the current log level

  #### Returns number

  - Defined in src/utils/HavenoUtils.ts:48

### `Static` getPaymentMethodId

- getPaymentMethodId(id: string | FormId): string

- Get a validated payment method id from a string or form id.

  ### Returns

  the payment method id

  #### Parameters

  - ##### id: string | FormId

    identifies the payment method

  #### Returns string

  - Defined in src/utils/HavenoUtils.ts:186

### `Static` hasFormField

- hasFormField(form: PaymentAccountForm, fieldId: FieldId): boolean

- Determine if a form has a field.

  ### Returns

  true if the form has the field, false otherwise

  #### Parameters

  - ##### form: PaymentAccountForm

    form to check

  - ##### fieldId: FieldId

    id of the field to check for

  #### Returns boolean

  - Defined in src/utils/HavenoUtils.ts:219

### `Static` kill

- kill(process: any, signal?: string): Promise<void>

- Kill the given process.

  TODO (woodser): move this to monero-ts GenUtils.ts as common utility

  #### Parameters

  - ##### process: any

    the nodejs child process to child

  - ##### `Optional` signal: string

    the kill signal, e.g. SIGTERM, SIGKILL, SIGINT (default)

  #### Returns Promise<void>

  - Defined in src/utils/HavenoUtils.ts:87

### `Static` log

- log(level: number, msg: string): void

- Log a message. // TODO (woodser): switch to log library?

  #### Parameters

  - ##### level: number

    log level of the message

  - ##### msg: string

    message to log

  #### Returns void

  - Defined in src/utils/HavenoUtils.ts:58

### `Static` max

- max(bi1: bigint, bi2: bigint): bigint

- Return the maximum of two bigints.

  ### Returns

  the maximum of the two bigints

  #### Parameters

  - ##### bi1: bigint

    first bigint

  - ##### bi2: bigint

    second bigint

  #### Returns bigint

  - Defined in src/utils/HavenoUtils.ts:174

### `Static` multiply

- multiply(a: bigint, b: number | bigint): bigint

- Multiply a bigint by a number or bigint.

  ### Returns

  the product as a bigint

  #### Parameters

  - ##### a: bigint

    bigint to multiply

  - ##### b: number | bigint

    bigint or number to multiply by

  #### Returns bigint

  - Defined in src/utils/HavenoUtils.ts:142

### `Static` percentageDiff

- percentageDiff(a: bigint, b: bigint): number

- Calculate the difference from a first bigint to a second, as a percentage (float).

  ### Returns

  the percentage difference as a float

  #### Parameters

  - ##### a: bigint

    first bigint to get the difference from

  - ##### b: bigint

    second bigint to get the difference from

  #### Returns number

  - Defined in src/utils/HavenoUtils.ts:153

### `Static` setFormValue

- setFormValue(form: PaymentAccountForm, fieldId: FieldId, value: string): void

- Set a form field value.

  ### Returns

  the form field value

  #### Parameters

  - ##### form: PaymentAccountForm

    form to get the field from

  - ##### fieldId: FieldId

    id of the field to set the value of

  - ##### value: string

    field value to set

  #### Returns void

  - Defined in src/utils/HavenoUtils.ts:249

### `Static` setLogLevel

- setLogLevel(level: number): Promise<void>

- Set the log level with 0 being least verbose.

  #### Parameters

  - ##### level: number

    the log level

  #### Returns Promise<void>

  - Defined in src/utils/HavenoUtils.ts:38

### `Static` waitFor

- waitFor(durationMs: number): Promise<unknown>

- Wait for the duration.

  #### Parameters

  - ##### durationMs: number

    the duration to wait for in milliseconds

  #### Returns Promise<unknown>

  - Defined in src/utils/HavenoUtils.ts:100

### `Static` xmrToAtomicUnits

- xmrToAtomicUnits(amountXmr: string | number): bigint

- Convert XMR to atomic units.

  ### Returns

  amount in atomic units

  #### Parameters

  - ##### amountXmr: string | number

    amount in XMR to convert to atomic units

  #### Returns bigint

  - Defined in src/utils/HavenoUtils.ts:110

Generated using TypeDoc