Bitcoin and Altcoin Wallets 6.2.4

balances.php

Helper functions that calculate balances.

Tags
since
6.0.0

Introduced.

author

Alexandros Georgiou info@dashed-slug.net

Table of Contents

get_balance_for_user_and_currency_id()  : int
get_all_balances_assoc_for_user()  : array<string|int, mixed>
Get all balances for a user or for all users.
get_available_balance_for_user_and_currency_id()  : int
get_all_available_balances_assoc_for_user()  : array<string|int, mixed>
Get all available balances for a user or for all users.
sum_transactions()  : array<string|int, number>
Sums transactions into balances.

Functions

get_balance_for_user_and_currency_id()

get_balance_for_user_and_currency_id(int $user_id, int $currency_id) : int
Parameters
$user_id : int
$currency_id : int
Return values
int

get_all_balances_assoc_for_user()

Get all balances for a user or for all users.

get_all_balances_assoc_for_user(int $user_id) : array<string|int, mixed>

Balances are the sum of all transactions with "done" state. Balances for all enabled currencies are returned.

Parameters
$user_id : int

The ID for the user, or 0 to retrieve balance sums over all users.

Return values
array<string|int, mixed>

Assoc array of currency_ids to balance amounts, in decimal form (float).

get_available_balance_for_user_and_currency_id()

get_available_balance_for_user_and_currency_id(int $user_id, int $currency_id) : int
Parameters
$user_id : int
$currency_id : int
Return values
int

get_all_available_balances_assoc_for_user()

Get all available balances for a user or for all users.

get_all_available_balances_assoc_for_user(int $user_id) : array<string|int, mixed>

Available balances are the sum of all transactions in "done" state and any debiting balances (withdrawals, negative moves) that are in a "pending" state. Balances for all enabled currencies are returned.

Parameters
$user_id : int

The ID for the user. If zero, then return total balances for all users.

Return values
array<string|int, mixed>

Assoc array of currency_ids to balance amounts, in integer form.

sum_transactions()

Sums transactions into balances.

sum_transactions(array<string|int, mixed> $txs) : array<string|int, number>

Gets the transaction objects from the passed array and sums them into an assoc array of currency_id to balance sum. Applies fees to debiting transactions (withdrawals, negative moves).

Parameters
$txs : array<string|int, mixed>

The array of Transaction objects.

Return values
array<string|int, number>

The assoc array of currency_ids to balances.

Search results