承接 nimiq/xpub 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

nimiq/xpub

Composer 安装命令:

composer require nimiq/xpub

包简介

A simple class to derive BTC and ETH extended public keys and addresses without GMP.

README 文档

README

Build Status

A simple class to derive BTC and ETH extended public keys and addresses without GMP. Only the BCMath extension is required (but GMP is still used for faster calculations when available).

Supports the following formats:

Type Mainnet Testnet
BIP44 (standard) xpub tpub
BIP49 (nested segwit) ypub upub
BIP84 (native segwit) zpub vpub

Installation

The Nimiq XPub package is availabe via the Packagist package registry and can be installed with Composer:

composer require nimiq/xpub

Requirements

  • PHP >= 7.1
  • BCMath or GMP extension

Usage

# PSR-4 autoloading with composer
use Nimiq\XPub;

# Create an XPub class instance from an xpub/tpub/ypub/upub/zpub/vpub string.
$xpub = XPub::fromString( 'xpub...' ); // => BIP44 Original
$xpub = XPub::fromString( 'ypub...' ); // => BIP49 Nested SegWit
$xpub = XPub::fromString( 'zpub...' ); // => BIP84 Native SegWit

# You can also specify the address scheme to override auto-detection.
$xpub = XPub::fromString( 'xpub...', XPub::BIP84 );
$xpub = XPub::fromString( 'xpub...', XPub::BIP49 );
$xpub = XPub::fromString( 'zpub...', XPub::BIP44 );

# Derive a child extended public key from it.
$xpub_i = $xpub->derive( $i );
# You can also pass an array to derive a path.
$xpub_i_k = $xpub->derive( [$i, $k]);

# An XPub can be serialized back into a string.
# Pass $asHex = true to serialize into a HEX string, base58 is the default.
$xpub_string = $xpub_i->toString( $asHex = false );

# An XPub can be converted into an address.
# Pass $coin = 'eth' to convert into an ETH address.
#
# By default, xpubs are converted into standard addresses,
# ypubs are converted into nested segwit addresses,
# and zpubs are converted into native segwit addresses.
$address = $xpub_i->toAddress( $coin = 'btc' );

See the tests for further example usage.

Conversion

You can use this library to convert between xpub formats, for example:

// Parse any extended public key string
$xpub = XPub::fromString( 'xpub...' );

// Change the version on the instance
$xpub->version = 'zpub'; // Use any of the supported formats from the table at the top of the README

// Stringify to the target format
$zpub = $xpub->toString(); // 'zpub...'

Helpers

The XPub class also exposes two common hashing methods:

# Get a hash160
$hashed_hex = XPub::hash160( $input_hex );

# Get a double sha256
$hashed_hex = XPub::doubleSha256( $input_hex );

Development

Testing

To execute the test suite run:

composer run-script test
# or
php test/test.php

nimiq/xpub 适用场景与选型建议

nimiq/xpub 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.95k 次下载、GitHub Stars 达 11, 最近一次更新时间为 2019 年 11 月 14 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 nimiq/xpub 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 3.95k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 16
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 8
  • Forks: 6
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2019-11-14