Bank_Fiat_Adapter
extends Fiat_Adapter
in package
The bank fiat currency adapter defines fiat currencies that are deposited/withdrawn via bank transfers.
This adapter does not communicate with any wallets. It emails the admins who then process bank transfers manually.
Tags
Table of Contents
- $settings : mixed
- $settings_schema : mixed
- $wallet : mixed
- __construct() : mixed
- __get() : mixed|null
- Get a setting automagically
- __set() : mixed
- do_cron() : void
- Do periodic tasks related to this adapter.
- do_description_text() : void
- do_move() : bool
- Perform additional tasks before an internal debit transaction.
- do_withdrawals() : void
- Perform a batch of withdrawals, possibly in one transaction.
- get_block_height() : int
- get_extra_field_name() : null|string
- Return the extra field for addresses associated with this currency, if any.
- get_hot_available_balance() : int
- Retrieve the hot wallet balance that is available for immediate use.
- get_hot_balance() : int
- get_hot_locked_balance() : int
- get_new_address() : Address
- get_settings_schema() : array<string|int, array<string|int, mixed>>
- Return the settings schema for this adapter.
- get_wallet_version() : string
- is_locked() : bool
- register() : mixed
- do_deposit() : int|null
- Process a potential deposit transaction.
- validate_tcp_ip_address() : bool
- Validate an IP address.
Properties
$settings
protected
mixed
$settings
= []
$settings_schema
protected
mixed
$settings_schema
= []
$wallet
protected
mixed
$wallet
Methods
__construct()
public
__construct(Wallet $wallet) : mixed
Parameters
- $wallet : Wallet
Return values
mixed —__get()
Get a setting automagically
public
__get(string $id) : mixed|null
Parameters
- $id : string
-
The ID of the setting.
Return values
mixed|null —The setting's value, or the setting's default value, or NULL if the setting was not found.
__set()
public
__set(mixed $id, mixed $value) : mixed
Parameters
- $id : mixed
- $value : mixed
Return values
mixed —do_cron()
Do periodic tasks related to this adapter.
public
do_cron([callable|null $log = null ]) : void
The plugin will call this periodically. Adapters can optionally perform arbitrary periodic tasks, as needed. Add here any housekeeping tasks specific to the type of wallet that this adapter connects to.
Parameters
- $log : callable|null = null
-
The log function.
Tags
Return values
void —do_description_text()
public
do_description_text() : void
Return values
void —do_move()
Perform additional tasks before an internal debit transaction.
public
do_move(Transaction $debit) : bool
Most adapters will NOT need to override this.
Every time an internal transfer is executed, the corresponding adapter is notified first. If the adapter returns false, then the transaction will be marked with "failed" status. The adapter can also set an error message in the transaction:
$debit->error = 'I do not like this tranasction!';
The adapter can get the corresponding credit transaction with:
$credit = $debit->get_other_tx();
Parameters
- $debit : Transaction
-
The debit transaction (the one that removes balance from the sender).
Return values
bool —Whether the internal transfer should proceed.
do_withdrawals()
Perform a batch of withdrawals, possibly in one transaction.
public
do_withdrawals(array<string|int, Transaction> $withdrawals) : void
The method takes an array of Transactions and executes them. The method sets the following data into the transactions before returning them:
- actual fees paid
- TXID
- block height
The Transactions passed must all be of the same currency. The adapter does not have to be able to cater to different currencies in one call. Subclasses can call this parent implementation to perform these checks, before proceeding to withdraw a batch of transactions.
Parameters
- $withdrawals : array<string|int, Transaction>
-
Array of transactions to process. The transactions may be modified.
Tags
Return values
void —get_block_height()
public
get_block_height([Currency|null $currency = null ]) : int
Parameters
- $currency : Currency|null = null
Return values
int —get_extra_field_name()
Return the extra field for addresses associated with this currency, if any.
public
get_extra_field_name([Currency|null $currency = null ]) : null|string
For example: Destination Tag, Payment ID, Memo, etc.
Parameters
- $currency : Currency|null = null
-
The currency to query for. Useful only for adapters to multi-currency wallets.
Tags
Return values
null|string —The name of the field, or null if the field is not used.
get_hot_available_balance()
Retrieve the hot wallet balance that is available for immediate use.
public
get_hot_available_balance([Currency|null $currency = null ]) : int
Available balance excludes any funds that are not mature. Immature funds are those that originate from transaction that have a low confimation count, or any funds that are mined too recently, or locked in other pending withdrawals in the wallet.
Parameters
- $currency : Currency|null = null
-
If the wallet supports multiple currencies, pass the desired currency here.
Tags
Return values
int —The available balance as an integer.
get_hot_balance()
public
get_hot_balance([Currency|null $currency = null ]) : int
Parameters
- $currency : Currency|null = null
Return values
int —get_hot_locked_balance()
public
get_hot_locked_balance([Currency|null $currency = null ]) : int
Parameters
- $currency : Currency|null = null
Return values
int —get_new_address()
public
get_new_address([Currency|null $currency = null ]) : Address
Parameters
- $currency : Currency|null = null
Return values
Address —get_settings_schema()
Return the settings schema for this adapter.
public
final get_settings_schema() : array<string|int, array<string|int, mixed>>
This schema can be used to render input form fields in the wallets-wallet metaboxes.
Tags
Return values
array<string|int, array<string|int, mixed>> —The schema is an array of arrays with the following fields each: id, name, type, description.
get_wallet_version()
public
get_wallet_version() : string
Return values
string —is_locked()
public
is_locked() : bool
Return values
bool —register()
public
static register() : mixed
Return values
mixed —do_deposit()
Process a potential deposit transaction.
protected
final do_deposit( $potential_deposit) : int|null
This takes a Transaction object that is still in memory and looks up the deposit addresses to see if it corresponds to a user address. If the deposit concerns an existing user, the deposit is stored to the DB and the address's action slug is triggered with the transaction data as its first argument. Existing deposits are not re-created.
Concrete implementations of this abstact class must call this method to notify the plugin of any potential deposits. Since the adapter does not know which deposits correspond to users, it can notify the plugin about all potential deposits. The plugin will discard any invalid deposits.
Parameters
- $potential_deposit :
-
A Transaction that does not yet have a user assigned to it and is not saved to the DB.
Return values
int|null —The Transaction post_id or null if the Transaction is of no interest to us/was not saved.
validate_tcp_ip_address()
Validate an IP address.
protected
validate_tcp_ip_address(string $address) : bool
Parameters
- $address : string