An unofficial PHP library for interacting with the blockchain.info API.
In order to use this package you must provide an URL to an instance of service-my-wallet-v3. Before using these functionalities.service-my-wallet-v3.
You can install the package via composer:
composer require appino/blockchain
Appino\Blockchain\BlockchainServiceProvider::class
php artisan vendor:publish --provider="Appino\blockchain\BlockchainServiceProvider"
blockchain_api_code=123456789abcdefghijklmnop //you must get api code from blockchain.info
blockchain_base_url=http://localhost:3000
$blocchain = Blockchain::Create();
/**
* @param string $password
* @param string|null $email
* @param string|null $label
* @return WalletResponse
* @throws ParameterError
*/
$blockchain->create($password, $email, $label);
/**
* @param string $password
* @param string $privKey
* @param string|null $email
* @param string|null $label
* @return WalletResponse
* @throws ParameterError
*/
$blockchain->createWithKey($password, $privKey, $email, $label);
$blockchain = Blockchain::Wallet();
$blockchain->credentials($guid, $password);
/**
* @param null|string $label
* @return AccountResponse
*/
$blockchain->CreateAddress($label));
/**
* @return int in satoshi
*/
$blockchain->balnce();
/**
* @param int|string $param can be index of address in wallet or address
* @return int in satoshi
*/
$blockchain->AddressBallance($param);
Return list of addresses of a Wallet
/**
* @return array<AccountResponse>
*/
$blockchain->ActiveAddresses();
Return list of xpub
/**
* @return array<string>
*/
$blockchain->XpubList();
Return Single Address Data
/**
* @param int|string $param can be index of address in wallet or address
* @return AccountResponse
*/
$blockchain->SingleAddress($param);
Return Receiving Address
/**
* @param int|string $param can be index of address in wallet or address
* @return string
*/
$blockchain->ReceivingAddress($param);
/**
* @param int|string $param can be index of address in wallet or address
* @return AccountResponse
*/
$blockchain->ArchiveAddress($param);
/**
* @param int|string $param can be index of address in wallet or address
* @return AccountResponse
*/
$blockchain->UnArchiveAddress($param);
/**
* @param string $to bitcoin address that you want to send payment to
* @param integer $amount amount of payment you want to send in satoshi
* @param integer|string|null $from xpub address or index of account that you want to send payment from
* @param int|null $fee
* @param int|null $fee_per_byte
* @return PaymentResponse
* @throws ParameterError
*/
$blockchain->SendPayment($to, $amount, $from, $fee, $fee_per_byte);
/**
* @param array<string,integer> $recipients recipients must be an array of address as key and satoshi as integer
* @param integer|string|null $from xpub address or index of account that you want to send payment from
* @param integer|null $fee must be in satoshi (better to set null or use fee_per_byte)
* @param integer|null $fee_per_byte must be in satoshi
* @return PaymentResponse
* @throws ParameterError
*/
$blockchain->SendManyPayment($recipients, $from=null, $fee=null, $fee_per_byte = null);
$blocchain = Blockchain::Receive();
/**
* @param string $xpub The public key.
* @param string $callback The callback URL.
* @param int $gap_limit How many unused addresses are allowed.
* @return ReceiveResponse
*/
$blockchain->Generate($xpub, $callback, $gap_limit = 20);
/**
* @param $xpub string
* @return int
* @throws \GuzzleHttp\Exception\GuzzleException
*/
$blockchain->AddressGap($xpub);
/**
* @param string $address
* @param string $callback callback url
* @param Notification|string $on what to do after notification called
* @param int $confs how many confiramtion need to send notification
* @param Operation|string $op on Receive/Send/All notification will send
* @return NotificationResponse
*/
$blockchain->BalanceNotification($address, $callback, $on, $confs, $op);
for deleting the notification use:
/**
* @param $id int
* @return bool
* @throws \GuzzleHttp\Exception\GuzzleException
*/
$blockchain->DeleteBalanceNotification($id);
/**
* @param string $callback callback url
* @param Notification|string $on what to do after notification called
* @param int $confs how many confiramtion need to send notification
* @param int|null $height height of block default(currentblock height plus 1)
* @return NotificationResponse
* @throws \GuzzleHttp\Exception\GuzzleException
*/
$blockchain->BlockNotification($callback, $on, $confs, $height);
for deleting the notification use:
/**
* @param int $id
* @return bool
* @throws \GuzzleHttp\Exception\GuzzleException
*/
$blockchain->DeleteBlockNotification($id);
/**
* @param string $callback callback url
* @return array<LogResponse>
* @throws \GuzzleHttp\Exception\GuzzleException
*/
$blockchain->CallbackLogs($callback);
Please see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email cyberman9000@gmail.com instead of using the issue tracker.
The MIT License (MIT). Please see License File for more information.