Skip to content

CURRENCY_D

object CURRENCY_D adm/daemons/currency.c

Currency daemon. Loads the configured denominations and their relative values from the CURRENCY config key, exposes ordered lookups, and converts amounts between denominations. All values are relative to the lowest (base) denomination.

inherits STD_DAEMON std/daemon/daemon.c
variable currency_map mapping
variable currency_order string *
# public valid_currency_type

Reports whether a name is a recognised denomination.

param currency string The denomination name to check
returns int 1 if valid, 0 otherwise
# public convert_currency

Converts an amount from one denomination to another, rounded to the nearest whole unit.

param amount int The amount in the source denomination
param from_currency string The source denomination name
param to_currency string The target denomination name
returns int The converted amount, or -1 if either denomination is invalid
# public fconvert_currency

Converts an amount between denominations, returning the unrounded floating-point result for fractional values.

param amount int The amount in the source denomination
param from_currency string The source denomination name
param to_currency string The target denomination name
returns float The converted amount, or -1 if either denomination is invalid
# public lowest_currency

Returns the name of the lowest-valued (base) denomination.

returns string The lowest-valued denomination name
# public highest_currency

Returns the name of the highest-valued denomination.

returns string The highest-valued denomination name
# public currency_list

Returns all denomination names ordered from lowest to highest value.

returns string * The ordered list of denomination names
# public currency_value

Returns the relative value of a denomination, in base units.

param currency string The denomination name
returns int The denomination’s relative value
# public get_currency_map

Returns a copy of the denomination-to-value mapping.

returns mapping A copy of the currency map