\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_account_id_for_address()
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
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

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

Throws

\Exception

If the symbol passed does not correspond to a coin adapter

Returns

\stdClass|array —

The adapter or array of adapters requested.

get_account_id_for_address()

get_account_id_for_address(string  $symbol, string  $address) : integer

Account ID corresponding to an address.

Returns the WordPress user ID for the account that has the specified address in the specified coin's wallet.

Parameters

string $symbol

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

string $address

The address

Throws

\Exception

If the address is not associated with an account.

Returns

integer —

The WordPress user ID for the account found.

get_balance()

get_balance(  $symbol) : float

Get user's wallet balance.

Get the current logged in user's total wallet balance for the specified coin.

Internally the balance is calculated by summing all getreceivedbyaddress for all the user's deposit addresses, minus all moves and withdrawals associated with the user. Calls to getreceivedbyaddress are cached for 1 minute.

Parameters

$symbol

Returns

float —

The user's balance.

get_transactions()

get_transactions(string  $symbol, integer  $count = 10, integer  $from, integer  $minconf = null) : 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.

Returns

array —

The transactions.

do_withdraw()

do_withdraw(string  $symbol, string  $address, float  $amount, string  $comment = '', string  $comment_to = '') 

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.

do_move()

do_move(string  $symbol, integer  $toaccount, float  $amount, string  $comment) 

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.

get_new_address()

get_new_address(string  $symbol) : string

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

Parameters

string $symbol

Character symbol of the wallet's coin.

Returns

string —

A deposit address associated with the current logged in user.