power/ php-bitcoin-address
一个简单的P2PK、P2PKH、P2SH、P2WPKH、P2WSH输出脚本/地址生成器。
1.1
2023-01-11 14:22 UTC
Requires
- php: >=7.0
- bitwasp/bech32: ^0.0.1
- btccom/cashaddress: ^0.0.3
- stephenhill/base58: ^1.1
Requires (Dev)
- phpunit/phpunit: ^5.7
This package is not auto-updated.
Last update: 2024-09-19 20:13:28 UTC
README
一个简单的P2PK、P2PKH、P2SH、P2WPKH、P2WSH输出脚本/地址解析器/生成器。
支持类型
- 支付到公钥(P2PK)
- 支付到公钥哈希(P2PKH)
- 支付到多重签名(P2MS)
- 支付到脚本哈希(P2SH)
- 支付到见证公钥哈希(P2WPKH)
- 支付到见证脚本哈希(P2WSH)
- P2WPKH-over-P2SH
- P2WSH-over-P2SH
- 任何组合
支持的网络
- 比特币
- 比特币测试网
- 比特币黄金
- 比特币现金
- 莱特币
- 莱特币测试网
- 狗狗币
- 狗狗币测试网
- 维币
- 维币测试网
- 达世币
- 达世币测试网
- 门罗币
安装
composer require andkom/php-bitcoin-address
示例
生成P2PK/P2PKH地址
$address = OutputFactory::p2pk($pubKey)->address(); $address = OutputFactory::p2pkh($pubKeyHash)->address();
生成P2MS地址
$address = OutputFactory::p2ms(2, [$pubKey1, $pubKey2, $pubKey3])->address();
生成P2SH地址
$factory = new OutputFactory(); $p2ms = $factory->p2ms(2, [$pubKey1, $pubKey2, $pubKey3]); $address = $factory->p2sh($p2ms)->address();
生成P2WPKH地址
$address = OutputFactory::p2wpkh($pubKeyHash)->address();
生成P2WSH地址
$factory = new OutputFactory(); $p2ms = $factory->p2ms(2, [$pubKey1, $pubKey2, $pubKey3]); $address = $factory->p2wsh($p2ms)->address();
生成P2WPKH-over-P2SH地址
$factory = new OutputFactory(); $p2wpkh = $factory->p2wpkh($pubKeyHash); $address = $factory->p2sh($p2wpkh)->address();
生成P2WSH-over-P2SH地址
$factory = new OutputFactory(); $p2ms = $factory->p2ms(2, [$pubKey1, $pubKey2, $pubKey3]); $p2wsh = $factory->p2wsh($p2ms); $address = $factory->p2sh($p2wsh)->address();
从输出脚本生成地址
$address = OutputFactory::fromScript($script)->address();