blocktrail/blocktrail-sdk 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

blocktrail/blocktrail-sdk

Composer 安装命令:

composer require blocktrail/blocktrail-sdk

包简介

The BlockTrail PHP SDK, for integration of Bitcoin functionality through the BlockTrail API

README 文档

README

This is the BlockTrail PHP SDK. This SDK contains methods for easily interacting with the BlockTrail API. Below are examples to get you started. For additional examples, please see our official documentation at https://dev.btc.com/docs/php

Latest Stable Version Latest Unstable Version License

Build Status

Upgrading from v2.x to v3.0.0

IMPORTANT v3.0.0 introduces a new DEFAULT wallet encryption, please make sure you upgrade the SDK everywhere you're using it!!

Upgrading from v1.x to v2.0.0

IMPORTANT v2.0.0 has a few BC breaks, please check docs/CHANGELOG.md!!

Upgrading from v1.2.x to v1.3.0

IMPORTANT v1.3.0 adds the option to choose a fee strategy and by default chooses DYNAMIC, please check docs/CHANGELOG.md for the details!!

IMPORTANT! FLOATS ARE EVIL!!

As is best practice with financial data, The API returns all values as an integer, the Bitcoin value in Satoshi's. In PHP even more than in other languages it's really easy to make mistakes whem converting from float to integer etc!

When doing so it's really important that you use the bcmath or gmp libraries to avoid weird rounding errors! The BlockTrail SDK has some easy to use functions to do this for you, we recommend using these and we also strongly recommend doing all Bitcoin calculation and storing of data in integers and only convert to/from Bitcoin float values for displaying it to the user.

use Blocktrail\SDK\BlocktrailSDK;

echo "123456789 Satoshi to BTC: " . BlocktrailSDK::toBTC(123456789) . " \n";
echo "1.23456789 BTC to Satoshi: " . BlocktrailSDK::toSatoshi(1.23456789) . " \n";

A bit more about this can be found in our documentation.

Requirements

The SDK requires PHP 5.6+ and the Intl, GMP and BCMath PHP extensions.
To install these on Ubuntu use:

sudo apt-get install php5-bcmath php5-intl php5-gmp
sudo php5enmod mcrypt

BCMath should already be part of the default php5 package

On Windows you need to uncomment the extensions in your php.ini if they are not already enabled:

extension=php_intl.dll  
extension=php_gmp.dll  

Installation

To install the SDK, you will need to be using Composer in your project. If you aren't using Composer yet, it's really simple! Here's how to install composer and the BlockTrail PHP SDK.

# Install Composer
curl -sS https://getcomposer.org/installer | php

# Add the BlockTrail SDK as a dependency
php composer.phar require blocktrail/blocktrail-sdk

Next, require Composer's autoloader, in your application, to automatically load the BlockTrail SDK in your project:

require 'vendor/autoload.php';
use Blocktrail\SDK\BlocktrailSDK;

Or if put the following in your composer.json:

"blocktrail/blocktrail-sdk": "1.2.*"

Windows Developers
A note for windows developers: you may encounter an issue in php with cURL and SSL certificates, where cURL is unable to verify a server's cert with a CA ((error 60)[http://curl.haxx.se/libcurl/c/libcurl-errors.html]).
Too often the suggested solution is to disable ssl cert verification in cURL, but this completely defeats the point of using SSL. Instead you should take two very simple steps to solve the issue permanently:

  1. download cacert.pem from the curl website. This is a bundle of trusted CA root certs extracted from mozilla.org. Save it in a folder within your php installation.
  2. open your php.ini and add/edit the following line (use an absolute path to where you placed the cert bundle):
curl.cainfo = C:\php\certs\cacert.pem

(Optional) Use libsecp256k1

The underlying bitcoin-php library that is used to sign transactions can use libsecp256k1 for (A LOT) faster signing of transactions. If the secp256k1-php PHP extension is installed it will be automatically used and will greatly improve performance!

The installation is a bit cumbersome though and because libsecp256k1 still changes a lot building might not always work! If you can get it to install; AWESOME, if not, have patience while we're working on figuring out how to provide installers for them.

https://github.com/Bit-Wasp/secp256k1-php#to-install

MAKE SURE TO RUN THE TESTSUITE OF secp256k1-php AFTER THE INSTALL BEFORE ENABLING THE EXTENSION!!

Usage

Please visit our official documentation at https://dev.btc.com/docs/php for the usage.

Support and Feedback

Be sure to visit the BlockTrail API official documentation website for additional information about our API.

If you find a bug, please submit the issue in Github directly. BlockTrail-PHP-SDK Issues

If you need additional assistance, contact one of our developers at support@btc.com.

Unit Tests and Coding Style

The project follows the PSR2 coding style, which can easily be validated with ./vendor/bin/phpcs --standard=./phpcs.xml -n -a ./src/. Unit Tests are created with PHPunit and can be ran with ./vendor/bin/phpunit

Release

# make sure you've committed everything?
git status

# desired new tag
TAG="v1.1.1"

# strips off the v from your input
TAG=$(echo $TAG | sed 's/^v//g')

# update version number in src/Blocktrail.php
sed -i 's/const SDK_VERSION = "[0-9].[0-9].[0-9]";/const SDK_VERSION = "'$TAG'";/g' src/Blocktrail.php

# commit the updated version number
git commit -am "release v${TAG}"

# tag the version
git tag v$TAG

# push
git push
git push --tags

License

The BlockTrail PHP SDK is released under the terms of the MIT license. See LICENCE.md for more information or see http://opensource.org/licenses/MIT.

blocktrail/blocktrail-sdk 适用场景与选型建议

blocktrail/blocktrail-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 21.12k 次下载、GitHub Stars 达 48, 最近一次更新时间为 2014 年 10 月 13 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「api」 「payment」 「sdk」 「transaction」 「bitcoin」 「wallet」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 blocktrail/blocktrail-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 blocktrail/blocktrail-sdk 我们能提供哪些服务?
定制开发 / 二次开发

基于 blocktrail/blocktrail-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 21.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 49
  • 点击次数: 9
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 48
  • Watchers: 6
  • Forks: 48
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-10-13