Download the PHP package amashukov/cashaddr-php without Composer
On this page you can find all versions of the php package amashukov/cashaddr-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download amashukov/cashaddr-php
More information about amashukov/cashaddr-php
Files in amashukov/cashaddr-php
Package cashaddr-php
Short Description CashAddr codec for Bitcoin Cash in pure PHP — BCH polymod checksum, base32, bitcoincash / bchtest / bchreg prefixes, P2PKH / P2SH / P2SH32 and token-aware CashTokens address types as a typed immutable value object.
License MIT
Homepage https://github.com/AndreyMashukov/cashaddr-php
Informations about the package cashaddr-php
amashukov/cashaddr-php
CashAddr codec for Bitcoin Cash in pure PHP — BCH polymod checksum, base32 payload, network prefixes and token-aware CashTokens address types as a typed immutable value object.
A CashAddr encoder / decoder for Bitcoin Cash written in plain PHP, with no runtime dependencies and no extensions. It implements the CashAddr specification — the 40-bit BCH polymod checksum over GF(2^5), the base32 alphabet, the version byte with its size bits — and the two token-aware address types added by CashTokens. Parsed addresses become a final readonly CashAddress value object that always prints in the normalized prefix:lowercase form, so two spellings of one address compare equal.
Features
- Spec-exact codec —
CashAddr::encode()/decode()handle every hash size the spec defines (160…512 bits) and any prefix;CashAddr::isChecksumValid()checks the polymod alone. - Typed address —
CashAddresscarries aCashAddrNetwork(bitcoincash,bchtest,bchreg), aCashAddrTypeand the raw hash. - Token-aware types as an enum —
P2PKH(q),P2SH(p),TokenAwareP2PKH(z),TokenAwareP2SH(r);isTokenAware()lets a caller refuse token addresses where it cannot handle them,plain()/tokenAware()convert between the pairs. - Prefix optional —
qr6m7j9n…is matched against the known networks by checksum, or against the one you pass. - Strict input — upper case is accepted, mixed case is rejected, a double prefix is rejected, padding bits must be zero, the version byte must match the payload length.
- Hash sizes per address type — 20 bytes for P2PKH, 20 or 32 bytes (P2SH32) for P2SH.
Installation
Usage
The lower layer works with any prefix and any spec hash size:
Test vectors
The suite runs every vector of the CashAddr specification (checksum vectors, legacy translation table, 160…512-bit payloads) and the CashTokens cashaddr.json set with the token-aware types, in both directions and in upper case.
Requirements
- PHP 8.3+ on a 64-bit build (the polymod state is 40 bits wide)
Related packages
| Package | Role |
|---|---|
| amashukov/bchn-rpc-client-php | Typed JSON-RPC client for Bitcoin Cash Node |
| amashukov/bitcoin-cash-php | Bitcoin Cash meta-package |
| amashukov/blockchain-address-php | Address value objects for EVM, TON and Lightning |
Quality
- PHPStan level 9, clean.
- php-cs-fixer
@PER-CSruleset. - GitHub Actions CI on every push.
License
MIT — see LICENSE.