Bitcoin and Altcoin Wallets 6.2.4

Bitcoin_Core_Like_Wallet_Adapter extends Wallet_Adapter
in package

The Bitcoin core-like adapter is for communicating with Bitcoin core and with similar wallets.

"Similar" wallets are those that are direct forks from Bitcoin. As long as the JSON-RPC API is the same, this adapter can be used for a large number of full node wallets. Examples are Litecoin and Dogecoin.

Tags
since
6.0.0

Introduced.

Table of Contents

$scrape_behind  : int
$sequence_id  : mixed
$settings  : mixed
$settings_schema  : mixed
$wallet  : mixed
__construct()  : mixed
__get()  : mixed|null
Get a setting automagically
__set()  : mixed
blocknotify()  : void
Processes an incoming blockchain block, iterating through all of its blockchain transactions.
do_cron()  : void
Do periodic tasks related to this adapter.
do_description_text()  : void
Render a short description of what this adapter is about.
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|null
Block height
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
Retrieve the hot wallet balance.
get_hot_locked_balance()  : int
get_new_address()  : Address
Create a new address for this wallet.
get_settings_schema()  : array<string|int, array<string|int, mixed>>
Return the settings schema for this adapter.
get_wallet_version()  : string
Wallet backend version
is_locked()  : bool
Determines if withdrawals are locked.
register()  : mixed
walletnotify()  : void
Processes an incoming blockchain transaction, and if it contains potential user deposits, it notifies the plugin so it can update the ledger (i.e. posts of wallets_tx post type).
do_deposit()  : int|null
Process a potential deposit transaction.
get_url()  : string
rpc()  : mixed
Perform an RPC call.
validate_tcp_ip_address()  : bool
Validate an IP address.
lock()  : void
scrape_blocks_incrementally()  : void
Scrape blocks incrementally.
unlock()  : void
update_tx_states()  : void
Updates transaction states based on blockchain height and required confirmations.

Properties

Methods

__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

blocknotify()

Processes an incoming blockchain block, iterating through all of its blockchain transactions.

public blocknotify(string $block_hash, Currency $currency) : void

If a transaction contains potential user deposits, this method notifies the plugin, so it can update the ledger (i.e. posts of wallets_tx post type).

Parameters
$block_hash : string

The blockchain hash for the block.

$currency : Currency

The currency.

Return values
void

do_cron()

Do periodic tasks related to this adapter.

public do_cron([callable $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
Return values
void

do_description_text()

Render a short description of what this adapter is about.

public do_description_text() : void

A short description of this adapter, explaining what type of wallet it connects to.

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, mixed> $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, mixed>

Array of transactions to process. The transactions may be modified.

Return values
void

get_block_height()

Block height

public get_block_height([Currency $currency = null ]) : int|null
Parameters
$currency : Currency = null

If the wallet supports multiple currencies, pass the desired currency here.

Return values
int|null

The block height up to which the connected wallet is synced currently or null if block height cannot be determined.

get_extra_field_name()

Return the extra field for addresses associated with this currency, if any.

public get_extra_field_name([Currency $currency = null ]) : null|string

For example: Destination Tag, Payment ID, Memo, etc.

Parameters
$currency : Currency = null

The currency to query for. Useful only for adapters to multi-currency wallets.

Tags
since
6.0.0

Introduced.

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
since
6.0.0

Introduced.

Return values
int

The available balance as an integer.

get_new_address()

Create a new address for this wallet.

public get_new_address([Currency $currency = null ]) : Address

Will generate a new address

Parameters
$currency : Currency = null

If the wallet supports multiple currencies, pass the desired currency here.

Return values
Address

The object encapsulating the new 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
since
6.0.0

Introduced.

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

Wallet backend version

public get_wallet_version() : string
Return values
string

The version of the currently connected wallet, if available.

is_locked()

Determines if withdrawals are locked.

public is_locked() : bool

A wallet can be locked for withdrawals if the necessary secrets are not available, or for any other reasaon.

Return values
bool

True if withdrawals cannot be performed at this time.

walletnotify()

Processes an incoming blockchain transaction, and if it contains potential user deposits, it notifies the plugin so it can update the ledger (i.e. posts of wallets_tx post type).

public walletnotify(string $txid, Currency $currency) : void
Parameters
$txid : string

The blockchain transaction ID.

$currency : Currency
Return values
void

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.

rpc()

Perform an RPC call.

protected rpc(string $method, mixed ...$params) : mixed
Parameters
$method : string

The bitcoin cli command.

$params : mixed

The arguments to the command, as defined in bitcoin help.

Tags
throws
RuntimeException

If the call fails for any reason (connectivity, authentication, access control, etc).

Return values
mixed

The returned data.

validate_tcp_ip_address()

Validate an IP address.

protected validate_tcp_ip_address(string $address) : bool
Parameters
$address : string
Tags
throws
InvalidArgumentException

If the IP address is not valid.

Return values
bool

scrape_blocks_incrementally()

Scrape blocks incrementally.

private scrape_blocks_incrementally(mixed $log) : void

Starts from the current block height

Parameters
$log : mixed
Return values
void

update_tx_states()

Updates transaction states based on blockchain height and required confirmations.

private update_tx_states(mixed $log) : void
Parameters
$log : mixed
Return values
void

Search results