transactions.php
Helper functions that retrieve transactions.
Tags
Table of Contents
- load_transactions() : array<string|int, mixed>
- Takes an array of transaction post_ids and instantiates them into an array of Transaction objects.
- get_transaction_by_txid() : Transaction|null
- Retrieves a transaction by its blockchain TXID.
- get_deposit_transaction_by_txid_and_address() : Transaction|null
- Retrieves a deposit transaction by its TXID and address string.
- get_pending_transactions_by_currency_and_category() : array<string|int, mixed>|null
- get_transactions() : array<string|int, mixed>|null
- Get transactions.
- get_transactions_for_address() : array<string|int, mixed>|null
- get_executable_withdrawals() : array<string|int, mixed>
- get_executable_moves() : mixed
- get_transactions_older_than() : array<string|int, mixed>
- Gets transactions from the before times.
- get_transactions_newer_than() : array<string|int, mixed>
- Gets latest transactions.
- get_transactions_by_time() : array<string|int, mixed>
- Gets transactions from the before times.
- do_validate_pending_transactions() : void
- get_tx_with_parent() : Transaction|null
- get_latest_fiat_withdrawal_by_user() : Transaction|null
- fiat_deposit_exists_by_txid_currency() : bool
- get_or_make_transaction() : Transaction
- Check a transaction object to see if it already exists on the db as a post and if not, create it.
- get_todays_withdrawal_counters() : array<string|int, mixed>
- increment_todays_withdrawal_counters() : void
- get_next_currency_with_pending_withdrawals() : Currency|null
- Get next currency with pending withdrawals
- get_possible_transaction_counterparts() : array<string|int, mixed>
- Get possible counterpart transactions to specified transaction.
Functions
load_transactions()
Takes an array of transaction post_ids and instantiates them into an array of Transaction objects.
load_transactions(array<string|int, mixed> $post_ids) : array<string|int, mixed>
If a transaction cannot be loaded due to Transaction::load() throwing (i.e. bad DB data), then it is skipped and the rest of the transactions will be loaded.
Parameters
- $post_ids : array<string|int, mixed>
-
The array of integer post_ids
Tags
Return values
array<string|int, mixed> —The array of Transaction objects.
get_transaction_by_txid()
Retrieves a transaction by its blockchain TXID.
get_transaction_by_txid(string $txid) : Transaction|null
Useful for checking for existing transactions on the plugin's ledger.
Parameters
- $txid : string
-
The blockchain TXID for the transaction we're looking for.
return Transaction|null The transaction found, or null if no transaction was found.
Return values
Transaction|null —get_deposit_transaction_by_txid_and_address()
Retrieves a deposit transaction by its TXID and address string.
get_deposit_transaction_by_txid_and_address(string $txid, string $address[, string|null $extra = null ]) : Transaction|null
Useful for checking for existing transactions on the plugin's ledger. Deposit transactions should be unique by TXID and address.
If the extra field is specified, it must also match.
Parameters
- $txid : string
-
The blockchain TXID for the transaction we're looking for.
- $address : string
-
The address string for the transaction we're looking for.
- $extra : string|null = null
-
Optionally a Payment ID, Memo, Destination tag, etc.
return Transaction|null The transaction found, or null if no transaction was found.
Return values
Transaction|null —get_pending_transactions_by_currency_and_category()
get_pending_transactions_by_currency_and_category(Currency $currency, string $category[, int $limit = -1 ]) : array<string|int, mixed>|null
Parameters
- $currency : Currency
- $category : string
- $limit : int = -1
Return values
array<string|int, mixed>|null —get_transactions()
Get transactions.
get_transactions([int|null $user_id = null ][, Currency|null $currency = null ][, array<string|int, mixed> $categories = ['all'] ][, array<string|int, mixed> $tags = [] ][, int|null $page = null ][, int|null $rows = null ][, int|null $offset = null ]) : array<string|int, mixed>|null
Parameters
- $user_id : int|null = null
-
Get txs of this user only.
- $currency : Currency|null = null
-
Look for transactions of this currency. If null, txs of all currencies are returned.
- $categories : array<string|int, mixed> = ['all']
-
Array can contain: 'deposit', 'withdrawal', 'move', 'all'.
- $tags : array<string|int, mixed> = []
-
Transactions found must have all these tags (this is an array of taxonomy slugs)
- $page : int|null = null
-
Used in conjunction with $rows for pagination.
- $rows : int|null = null
-
Number of txs to return. Can be used with $page, but if $offset is set it overrides $page.
- $offset : int|null = null
-
How many txs to skip for pagination. If set, $page is ignored.
Return values
array<string|int, mixed>|null —get_transactions_for_address()
get_transactions_for_address(Address $address) : array<string|int, mixed>|null
Parameters
- $address : Address
Return values
array<string|int, mixed>|null —get_executable_withdrawals()
get_executable_withdrawals(Currency $currency[, int $limit = -1 ]) : array<string|int, mixed>
Parameters
- $currency : Currency
- $limit : int = -1
Return values
array<string|int, mixed> —get_executable_moves()
get_executable_moves(mixed $currency[, mixed $limit = -1 ]) : mixed
Parameters
- $currency : mixed
- $limit : mixed = -1
Return values
mixed —get_transactions_older_than()
Gets transactions from the before times.
get_transactions_older_than(int $interval_days[, mixed $post_status = ['pending'] ]) : array<string|int, mixed>
Useful for the autocancel cron task. For time intervals over a month, it rounds to nearest month. Same for years.
Parameters
- $interval_days : int
-
How many days old the transaction should be at least.
- $post_status : mixed = ['pending']
Tags
Return values
array<string|int, mixed> —An array of Transaction objects.
get_transactions_newer_than()
Gets latest transactions.
get_transactions_newer_than(int $interval_days[, mixed $post_status = ['draft', 'pending', 'publish'] ]) : array<string|int, mixed>
Useful for the admin dashboard summaries For time intervals over a month, it rounds to nearest month. Same for years.
Parameters
- $interval_days : int
-
Up to how many days old the transaction should be.
- $post_status : mixed = ['draft', 'pending', 'publish']
Tags
Return values
array<string|int, mixed> —An array of Transaction objects.
get_transactions_by_time()
Gets transactions from the before times.
get_transactions_by_time(int $interval_days[, bool $before = true ][, array<string|int, mixed>|string $post_status = ['draft', 'pending', 'publish'] ]) : array<string|int, mixed>
Useful for the autocancel cron task. For time intervals over a month, it rounds to nearest month. Same for years.
Parameters
- $interval_days : int
-
How many days before now to set the pivot for comparing dates.
- $before : bool = true
-
True retrieves txs before the $interval_days, false retrieves txs after it.
- $post_status : array<string|int, mixed>|string = ['draft', 'pending', 'publish']
-
The post status or statuses to allow in query.
Tags
Return values
array<string|int, mixed> —An array of Transaction objects.
do_validate_pending_transactions()
do_validate_pending_transactions(string $nonce) : void
Parameters
- $nonce : string
Return values
void —get_tx_with_parent()
get_tx_with_parent(int $post_id) : Transaction|null
Parameters
- $post_id : int
Return values
Transaction|null —get_latest_fiat_withdrawal_by_user()
get_latest_fiat_withdrawal_by_user([int|null $user_id = null ]) : Transaction|null
Parameters
- $user_id : int|null = null
Return values
Transaction|null —fiat_deposit_exists_by_txid_currency()
fiat_deposit_exists_by_txid_currency(string $txid, Currency $currency) : bool
Parameters
- $txid : string
- $currency : Currency
Return values
bool —get_or_make_transaction()
Check a transaction object to see if it already exists on the db as a post and if not, create it.
get_or_make_transaction(Transaction $tx[, bool $notify = true ]) : Transaction
The post_id and status are not compared. Everything else is. Trashed transactions are not counted.
Parameters
- $tx : Transaction
-
An address to look for.
- $notify : bool = true
-
Whether to notify the user by email. Default true.
Tags
Return values
Transaction —The existing transaction or newly created transaction.
get_todays_withdrawal_counters()
get_todays_withdrawal_counters(int $user_id[, mixed $current_day = '' ]) : array<string|int, mixed>
Parameters
- $user_id : int
- $current_day : mixed = ''
Return values
array<string|int, mixed> —increment_todays_withdrawal_counters()
increment_todays_withdrawal_counters(Transaction $wd[, string|null $current_day = null ]) : void
Parameters
- $wd : Transaction
- $current_day : string|null = null
Return values
void —get_next_currency_with_pending_withdrawals()
Get next currency with pending withdrawals
get_next_currency_with_pending_withdrawals() : Currency|null
All currencies with enabled unlocked wallets are processed, one currency per cron run, with no starvation. Currencies with no pending withdrawals are skipped. If no eligible currencies have pending withdrawals, the loop ends.
Return values
Currency|null —get_possible_transaction_counterparts()
Get possible counterpart transactions to specified transaction.
get_possible_transaction_counterparts(Transaction $tx) : array<string|int, mixed>
Retrieve all transactions that can possibly be set to be the counterpart to the sepcified transaction. These must be move transactions. The amounts between counterpart transactions must have opposing signs (+/-) and they must be of the same currency.
Will not retrieve more than 1000 transactions since it doesn't make sense to display this many transactions as a dropdown.
Parameters
- $tx : Transaction
Return values
array<string|int, mixed> —(id,Title) touples