Bitcoin and Altcoin Wallets 6.4.0

addresses.php

Helper functions that retrieve addresses.

Tags
since
6.0.0

Introduced.

author

Alexandros Georgiou info@dashed-slug.net

Table of Contents

get_deposit_address_by_strings()  : Address|null
Retrieves a depost address by its address string.
get_withdrawal_address_by_strings()  : Address|null
Retrieves a withdrawal address by its address string.
get_address_by_strings()  : Address|null
Retrieves a depost address by its address string. This can be a deposit or withdrawal address.
get_all_addresses_for_user_id()  : array<string|int, mixed>
Get all the addresses for a user specified by numeric ID.
count_all_addresses_for_user_id()  : int
user_and_currency_have_label()  : bool
get_or_make_address()  : Address
Check an address object to see if it already exists on the db as a post and if not, create it.
get_latest_address_for_user_id_and_currency()  : Address|null
Retrieves the latest saved address for the specified currency and user, if any.
get_latest_address_per_currency_for_user_id()  : array<string|int, mixed>
Get latest address per currency for user specified by numeric ID.
get_all_addresses_for_user_id_and_currency_id()  : array<string|int, Address>
Retrieves all the addresses for the specified currency and user, and possibly type.
count_all_addresses_for_user_id_and_currency_id()  : int
get_address_ids_for_currency_id()  : array<string|int, int>
Get all address IDs for a currency ID.
get_address_ids_by_currency_id_and_type_and_tags()  : array<string|int, int>
Get all the IDs for addresses of a specified wallet and having the specified tags.
get_deposit_address_ids_by_tags()  : array<string|int, mixed>
Get IDs of deposit addresses by tags.

Functions

get_deposit_address_by_strings()

Retrieves a depost address by its address string.

get_deposit_address_by_strings(string $address[, string|null $extra = null ]) : Address|null

Useful for performing deposits. If the extra field is specified, it must also match.

Parameters
$address : string

The address string.

$extra : string|null = null

Optionally a Payment ID, Memo, Destination tag, etc.

return Address|null The address found, or null if no address was found.

Return values
Address|null

get_withdrawal_address_by_strings()

Retrieves a withdrawal address by its address string.

get_withdrawal_address_by_strings(string $address[, string|null $extra = null ]) : Address|null

Useful for editing withdrawals. If the extra field is specified, it must also match.

Parameters
$address : string

The address string.

$extra : string|null = null

Optionally a Payment ID, Memo, Destination tag, etc.

return Address|null The address found, or null if no address was found.

Return values
Address|null

get_address_by_strings()

Retrieves a depost address by its address string. This can be a deposit or withdrawal address.

get_address_by_strings(string $address[, string|null $extra = null ][, string $type = '' ]) : Address|null

Useful for performing deposits. If the extra field is specified, it must also match.

Parameters
$address : string

The address string.

$extra : string|null = null

Optionally a Payment ID, Memo, Destination tag, etc. If not applicable, should be falsy.

$type : string = ''

One of deposit, withdrawal.

return Address|null The address found, or null if no address was found.

Return values
Address|null

get_all_addresses_for_user_id()

Get all the addresses for a user specified by numeric ID.

get_all_addresses_for_user_id(int $user_id[, int|null $page = null ][, int|null $rows = null ][, bool $include_archived = false ]) : array<string|int, mixed>

This function features pagination.

Parameters
$user_id : int

The ID of the user to query.

$page : int|null = null

The page to request.

$rows : int|null = null

The amount of rows per page.

$include_archived : bool = false

Whether to include addresses that have the archived tag in the wallets_address_tags taxonomy.

Tags
since
6.0.0

Introduced.

since
6.1.3

Added argument $include_archived.

Return values
array<string|int, mixed>

count_all_addresses_for_user_id()

count_all_addresses_for_user_id(int $user_id) : int
Parameters
$user_id : int
Return values
int

user_and_currency_have_label()

user_and_currency_have_label(int $user_id, int $currency_id, string $label) : bool
Parameters
$user_id : int
$currency_id : int
$label : string
Return values
bool

get_or_make_address()

Check an address object to see if it already exists on the db as a post and if not, create it.

get_or_make_address(Address $address) : Address

The post_id and label are not compared. Everything else is. Trashed addresses are not counted.

Parameters
$address : Address

An address to look for.

Tags
throws
Exception

If saving the address fails.

Return values
Address

The existing address or newly created address.

get_latest_address_for_user_id_and_currency()

Retrieves the latest saved address for the specified currency and user, if any.

get_latest_address_for_user_id_and_currency(int $user_id, Currency $currency[, string $type = 'deposit' ][, bool $include_archived = true ]) : Address|null
Parameters
$user_id : int

The user id.

$currency : Currency

The currency.

$type : string = 'deposit'

One of 'deposit', 'withdrawal'.

$include_archived : bool = true

Whether to include addresses that have the archived tag in the wallets_address_tags taxonomy.

Tags
since
6.0.0

Introduced.

since
6.1.3

Added argument $include_archived.

Return values
Address|null

The address found, or null.

get_latest_address_per_currency_for_user_id()

Get latest address per currency for user specified by numeric ID.

get_latest_address_per_currency_for_user_id(int $user_id[, string $type = 'deposit' ][, bool $include_archived = false ]) : array<string|int, mixed>
Parameters
$user_id : int

The ID of the user to query.

$type : string = 'deposit'

One of deposit or withdrawal.

$include_archived : bool = false

Whether to include addresses that have the archived tag in the wallets_address_tags taxonomy.

Tags
since
6.0.0

Introduced.

since
6.1.3

Added argument $include_archived.

Return values
array<string|int, mixed>

The Addresses found, one per currency maximum.

get_all_addresses_for_user_id_and_currency_id()

Retrieves all the addresses for the specified currency and user, and possibly type.

get_all_addresses_for_user_id_and_currency_id(int $user_id, int $currency_id[, string $type = 'deposit' ][, bool $include_archived = false ]) : array<string|int, Address>
Parameters
$user_id : int

The user id.

$currency_id : int

The currency_id.

$type : string = 'deposit'

One of 'deposit', 'withdrawal'.

$include_archived : bool = false

Whether to include addresses that have the archived tag in the wallets_address_tags taxonomy.

Tags
since
6.0.0

Introduced.

since
6.1.3

Added argument $include_archived.

Return values
array<string|int, Address>

The addresses found.

count_all_addresses_for_user_id_and_currency_id()

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

get_address_ids_for_currency_id()

Get all address IDs for a currency ID.

get_address_ids_for_currency_id(int $currency_id[, string $type = 'deposit' ][, bool $include_archived = false ]) : array<string|int, int>

Retrieves all the ids of the deposit (or withdrawal) addresses for the specified currency and type.

Parameters
$currency_id : int

The ID of the currency whose addresses to retrieve..

$type : string = 'deposit'

Type of addresses to retrieve. One of 'deposit', 'withdrawal'. Default is deposit addresses.

$include_archived : bool = false

Whether to include addresses that have the archived tag in the wallets_address_tags taxonomy.

Tags
since
6.0.0

Introduced.

since
6.1.3

Added argument $include_archived.

Return values
array<string|int, int>

The IDs of the addresses found.

get_address_ids_by_currency_id_and_type_and_tags()

Get all the IDs for addresses of a specified wallet and having the specified tags.

get_address_ids_by_currency_id_and_type_and_tags(int $currency_id[, string $type = 'deposit' ][, array<string|int, string> $tags = [] ][, bool $include_archived = false ]) : array<string|int, int>

Retrieves all the ids of the deposit (or withdrawal) addresses for the specified wallet and tags.

Parameters
$currency_id : int

The ID of the currency whose addresses to retrieve.

$type : string = 'deposit'

Type of addresses to retrieve. One of 'deposit', 'withdrawal'. Default is deposit addresses.

$tags : array<string|int, string> = []

The addresses found must have all the specified tags.

$include_archived : bool = false

Whether to include addresses that have the archived tag in the wallets_address_tags taxonomy.

Tags
since
6.0.0

Introduced.

since
6.1.3

Added argument $include_archived.

Return values
array<string|int, int>

The IDs of the addresses found.

get_deposit_address_ids_by_tags()

Get IDs of deposit addresses by tags.

get_deposit_address_ids_by_tags([array<string|int, mixed> $tags = [] ][, bool $include_archived = false ]) : array<string|int, mixed>

Get the IDs of deposit addresses with the specified tags.

Parameters
$tags : array<string|int, mixed> = []

The addresses found must have all these tags.

$include_archived : bool = false

Whether to include addresses that have the archived tag in the wallets_address_tags taxonomy.

Tags
since
6.0.0

Introduced.

since
6.1.3

Added argument $include_archived.

Return values
array<string|int, mixed>

The IDs of the matching addresses.

Search results