Download the PHP package bitwasp/stratum without Composer
On this page you can find all versions of the php package bitwasp/stratum. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download bitwasp/stratum
More information about bitwasp/stratum
Files in bitwasp/stratum
Package stratum
Short Description library for interfacing with stratum servers, used to serve both bitcoin mining and electrum clients
License
Homepage https://github.com/Bit-Wasp/stratum-php
Informations about the package stratum
stratum-php
Implementation of the Stratum protocol (for electrum and mining) using ReactPHP
Client
The Client class is used to make a connection to a host. It takes a ConnectorInterface
and RequestFactory
.
react/socket-client
provides a number of connectors, which can be combined
to produce the desired functionality.
The SecureConnector initiates a TLS session to encrypt your connection. $context_options is an optional value, but many Electrum servers have misconfigured SSL certificates! (incorrect CN field, or are self-signed) These will not be accepted with the default verification settings, and can be disabled by changing the $context_options
Connection
A Connection
represents a connection to a peer.
Requests can be sent to the peer using Connection::request($method, $params = [])
,
which returns a Promise for the pending result. When a response with the same ID is
received, the promise will resolve this as the result.
Request
instances can be sent using Connection::sendRequest(Request $request)
which also returns a promise.
For a list of methods for the electrum and mining clients, see the respective Api classes. The constants are method's for these APIs.
NotificationInterface
's can be sent using Connection::sendNotify(NotificationInterface $note)
Notifications are not requests, and don't receive a response. This method is only relevant if
using Connection
from a servers perspective.
Api's
The Stratum protocol is implemented by electrum servers and stratum mining pools.
Their methods are exposed by ElectrumClient
and MiningClient
respectively.
The api methods cause a Request to be sent, returning a promise to capture the result.
Events
Connection
emits a message
event when a message is received which
was not initiated by a Request. These messages are typically due to subscriptions.
The following events are emitted automatically by the library when encountered. The event name is the method used to enable the subscription.
- 'blockchain.headers.subscribe' emits a
HeadersNotification
- 'blockchain.address.subscribe' emits a
AddressNotification
- 'blockchain.numblocks.subscribe' emits a
NumBlocksNotification
- 'mining.subscribe' emits a
MiningNotification
- 'mining.set_difficulty' emits a
SetDifficultyNotification