\Dashed_Slug_Wallets

The core of this plugin.

Provides an API for other plugins and themes to perform wallet actions, bound to the current logged in user.

Summary

Methods
Properties
Constants
get_instance()
get_coin_adapters()
add_option()
update_option()
get_option()
delete_option()
get_balance()
get_transactions()
do_withdraw()
do_move()
get_deposit_address()
get_new_address()
No public properties found
ERR_GET_USERS_INFO
ERR_GET_COINS_INFO
ERR_GET_TRANSACTIONS
ERR_DO_WITHDRAW
ERR_DO_MOVE
ERR_NOT_LOGGED_IN
ERR_NOT_ALLOWED
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Constants

ERR_GET_USERS_INFO

ERR_GET_USERS_INFO

error code for exception thrown while getting user info

ERR_GET_COINS_INFO

ERR_GET_COINS_INFO

error code for exception thrown while getting coins info

ERR_GET_TRANSACTIONS

ERR_GET_TRANSACTIONS

error code for exception thrown while getting transactions

ERR_DO_WITHDRAW

ERR_DO_WITHDRAW

error code for exception thrown while performing withdrawals

ERR_DO_MOVE

ERR_DO_MOVE

error code for exception thrown while transferring funds between users

ERR_NOT_LOGGED_IN

ERR_NOT_LOGGED_IN

error code for exception thrown due to user not being logged in

ERR_NOT_ALLOWED

ERR_NOT_ALLOWED

error code for exception thrown due to insufficient capabilities

Methods

get_instance()

get_instance() 

Returns the singleton core of this plugin that provides the application-facing API.

@api

get_coin_adapters()

get_coin_adapters(string  $symbol = null, boolean  $check_capabilities = false) : \Dashed_Slug_Wallets_Coin_Adapter|array

Returns the coin adapter for the symbol specified, or an associative array of all the adapters if the symbol is omitted.

The adapters provide the low-level API for talking to the various wallets.

Parameters

string $symbol

(Usually) three-letter symbol of the wallet's coin.

boolean $check_capabilities

Capabilities are checked if set to true. Default: false.

Throws

\Exception

If the operation fails. Exception code will be one of Dashed_SlugWallets::ERR*.

Returns

\Dashed_Slug_Wallets_Coin_Adapter|array —

The instance of the adapter or array of adapters requested.

add_option()

add_option(string  $option, mixed  $value) : boolean

This helper delegates to add_site_option if the plugin is network activated on a multisite install, or to add_option otherwise.

Parameters

string $option

The option name.

mixed $value

The option value.

Returns

boolean —

The result of the wrapped function.

update_option()

update_option(string  $option, mixed  $value) : boolean

This helper delegates to update_site_option if the plugin is network activated on a multisite install, or to update_option otherwise.

Parameters

string $option

The option name.

mixed $value

The option value.

Returns

boolean —

The result of the wrapped function.

get_option()

get_option(string  $option,   $default = false) : boolean

This helper delegates to get_site_option if the plugin is network activated on a multisite install, or to get_option otherwise.

Parameters

string $option

The option name.

$default

Returns

boolean —

The result of the wrapped function.

delete_option()

delete_option(string  $option) : boolean

This helper delegates to delete_site_option if the plugin is network activated on a multisite install, or to delete_option otherwise.

Parameters

string $option

The option name.

Returns

boolean —

The result of the wrapped function.

get_balance()

get_balance(string  $symbol, null  $minconf = null, boolean  $check_capabilities = false, integer  $account = null) : float

Get user's wallet balance.

Get the current logged in user's total wallet balance for a specific coin. Only transactions with status = 'done' are counted. This replaces the previous filtering based on the $minconf argument.

Parameters

string $symbol

(Usually) three-letter symbol of the wallet's coin.

null $minconf

Ignored.

boolean $check_capabilities

Capabilities are checked if set to true. Default: false.

integer $account

The user_id of the account to check, or null to retrieve logged in account's balance. Default: null.

Throws

\Exception

If the operation fails. Exception code will be one of Dashed_SlugWallets::ERR*.

Returns

float —

The balance.

get_transactions()

get_transactions(string  $symbol, integer  $count = 10, integer  $from, integer  $minconf = null, boolean  $check_capabilities = false) : array

Get transactions of current logged in user.

Returns the deposits, withdrawals and intra-user transfers initiated by the current logged in user for the specified coin.

Parameters

string $symbol

Character symbol of the wallet's coin.

integer $count

Maximal number of transactions to return.

integer $from

Start retrieving transactions from this offset.

integer $minconf

(optional) Minimum number of confirmations for deposits and withdrawals. If left out, the default adapter setting is used.

boolean $check_capabilities

Capabilities are checked if set to true. Default: false.

Throws

\Exception

If the operation fails. Exception code will be one of Dashed_SlugWallets::ERR*.

Returns

array —

The transactions.

do_withdraw()

do_withdraw(string  $symbol, string  $address, float  $amount, string  $comment = '', string  $comment_to = '', boolean  $check_capabilities = false, boolean  $skip_confirm = false) : void

Withdraw from current logged in user's account.

Parameters

string $symbol

Character symbol of the wallet's coin.

string $address

Address to withdraw to.

float $amount

Amount to withdraw to.

string $comment

Optional comment to attach to the transaction.

string $comment_to

Optional comment to attach to the destination address.

boolean $check_capabilities

Capabilities are checked if set to true. Default: false.

boolean $skip_confirm

Set to true if the transaction should not require confirmations. Useful for feature extensions.

Throws

\Exception

If the operation fails. Exception code will be one of Dashed_SlugWallets::ERR*.

do_move()

do_move(string  $symbol, integer  $toaccount, float  $amount, string  $comment, boolean  $check_capabilities = false, string  $tags = '', boolean  $skip_confirm = false, integer|null  $fromaccount = null) : void

Move funds from the current logged in user's balance to the specified user.

Parameters

string $symbol

Character symbol of the wallet's coin.

integer $toaccount

The WordPress user_ID of the recipient.

float $amount

Amount to withdraw to.

string $comment

Optional comment to attach to the transaction.

boolean $check_capabilities

Capabilities are checked if set to true. Default: false.

string $tags

A space separated list of tags, slugs, etc that further describe the type of transaction.

boolean $skip_confirm

Set to true if the transaction should not require confirmations. Useful for feature extensions.

integer|null $fromaccount

The WordPress user_ID of the sender, or null for current user ID.

Throws

\Exception

If move fails. Exception code will be one of Dashed_SlugWallets::ERR*.

get_deposit_address()

get_deposit_address(string  $symbol,   $account = null, boolean  $check_capabilities = false) : string

Get a deposit address for the current logged in user's account.

Parameters

string $symbol

Character symbol of the wallet's coin.

$account
boolean $check_capabilities

Capabilities are checked if set to true. Default: false.

Throws

\Exception

If the operation fails.

Returns

string —

A deposit address associated with the current logged in user.

get_new_address()

get_new_address(string  $symbol, boolean  $check_capabilities = false) : string

Get a deposit address for the current logged in user's account.

Parameters

string $symbol

Character symbol of the wallet's coin.

boolean $check_capabilities

Capabilities are checked if set to true. Default: false.

Throws

\Exception

If the operation fails. Exception code will be one of Dashed_SlugWallets::ERR*.

Returns

string —

A deposit address associated with the current logged in user.