定制 elis/xpub 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

elis/xpub

Composer 安装命令:

composer require elis/xpub

包简介

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

README 文档

README

A simple class to derive address and extended public keys.

Coins supported:

  • Bitcoin (Bitcoin Cash/Bitcoin SV)
  • Ethereum (Binance Smart Chain)
  • Tron
  • Binance Chain

Supports xpub, tpub, zpub and vpub public key formats.

Install

composer require elis/xpub

Requirements

  • PHP >= 7.1
  • BCMath or GMP extension

Usage

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

# Create an XPub class instance from an xpub/tpub/zpub/vpub string.
$xpub = XPub::fromString( '<xpub...>' ); // => BIP44 Original
$xpub = XPub::fromString( '<zpub...>' ); // => BIP84 Native SegWit
# You can also specify the address scheme.
$xpub = XPub::fromString( '<xpub...>', XPub::BIP84 );
$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.
# (xpubs are converted into regular addresses, zpubs are converted into segwit addresses.)
$address = $xpub_i->toAddress( $coin = 'btc' );

See the tests for example usage.

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 );

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2021-03-14