\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()
get_balance()
get_transactions()
do_withdraw()
do_move()
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.

get_balance()

get_balance(string  $symbol, null  $minconf = null, boolean  $check_capabilities = false) : 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.

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) : 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.

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 = '') : 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.

Throws

\Exception

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

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.