appino/blockchain
Composer 安装命令:
composer require appino/blockchain
包简介
Blockchain API client library
README 文档
README
An unofficial PHP library for interacting with the blockchain.info API.
Installation
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
Add provider to app config
Appino\Blockchain\BlockchainServiceProvider::class
Publish Configuration File
php artisan vendor:publish --provider="Appino\blockchain\BlockchainServiceProvider"
Add 2 Lines to env File
blockchain_api_code=123456789abcdefghijklmnop //you must get api code from blockchain.info blockchain_base_url=http://localhost:3000
Usage
Create
$blocchain = Blockchain::Create();
1. Creating Wallet
/** * @param string $password * @param string|null $email * @param string|null $label * @return WalletResponse * @throws ParameterError */ $blockchain->create($password, $email, $label);
2. Creating Wallet with specific private key
/** * @param string $password * @param string $privKey * @param string|null $email * @param string|null $label * @return WalletResponse * @throws ParameterError */ $blockchain->createWithKey($password, $privKey, $email, $label);
Wallet
$blockchain = Blockchain::Wallet(); $blockchain->credentials($guid, $password);
1. Create new Address
/** * @param null|string $label * @return AccountResponse */ $blockchain->CreateAddress($label));
2. Balance
/** * @return int in satoshi */ $blockchain->balnce();
3. Address Balance
/** * @param int|string $param can be index of address in wallet or address * @return int in satoshi */ $blockchain->AddressBallance($param);
4. Active Addresses
Return list of addresses of a Wallet
/** * @return array<AccountResponse> */ $blockchain->ActiveAddresses();
5. List of Xpubs
Return list of xpub
/** * @return array<string> */ $blockchain->XpubList();
6. Single Address Data
Return Single Address Data
/** * @param int|string $param can be index of address in wallet or address * @return AccountResponse */ $blockchain->SingleAddress($param);
7. Get Receiving Address
Return Receiving Address
/** * @param int|string $param can be index of address in wallet or address * @return string */ $blockchain->ReceivingAddress($param);
8. Archive Address
/** * @param int|string $param can be index of address in wallet or address * @return AccountResponse */ $blockchain->ArchiveAddress($param);
9. UnArchive Address
/** * @param int|string $param can be index of address in wallet or address * @return AccountResponse */ $blockchain->UnArchiveAddress($param);
10. Send Payment
/** * @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);
11. Send Many Payment
/** * @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);
Receive
$blocchain = Blockchain::Receive();
1. Generate Receiving Address
/** * @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);
2. Get Address Gap
/** * @param $xpub string * @return int * @throws \GuzzleHttp\Exception\GuzzleException */ $blockchain->AddressGap($xpub);
3. Balance Notification
/** * @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);
4. Block Notification
/** * @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);
5. Get CallBack Logs
/** * @param string $callback callback url * @return array<LogResponse> * @throws \GuzzleHttp\Exception\GuzzleException */ $blockchain->CallbackLogs($callback);
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email cyberman9000@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
appino/blockchain 适用场景与选型建议
appino/blockchain 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 9 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 10 月 16 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「blockchain」 「cryptocurrency」 「appino」 「blockchian.info」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 appino/blockchain 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 appino/blockchain 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 appino/blockchain 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The BlockTrail PHP SDK, for integration of Bitcoin functionality through the BlockTrail API
Solana PHP SDK for interacting with the Solana blockchain
Cryptonator Merchant API
A fast and dynamic Merkle tree implementation
Multichain JSON-RPC Client
Implementation of Bitclout API interaction through its node
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-10-16