{"id":25287685,"url":"https://github.com/nimiq/php-xpub","last_synced_at":"2026-03-08T17:33:43.202Z","repository":{"id":57027311,"uuid":"221599159","full_name":"nimiq/php-xpub","owner":"nimiq","description":"A simple class to derive BTC and ETH extended public keys and addresses without GMP.","archived":false,"fork":false,"pushed_at":"2024-01-10T14:45:54.000Z","size":30,"stargazers_count":10,"open_issues_count":0,"forks_count":4,"subscribers_count":10,"default_branch":"master","last_synced_at":"2025-02-09T11:34:11.966Z","etag":null,"topics":["address","bcmath","bitcoin","btc","derivation","eth","ethereum","gmp","nimiq","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nimiq.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-11-14T02:59:49.000Z","updated_at":"2024-08-12T19:54:50.000Z","dependencies_parsed_at":"2022-08-23T16:20:37.383Z","dependency_job_id":null,"html_url":"https://github.com/nimiq/php-xpub","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimiq%2Fphp-xpub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimiq%2Fphp-xpub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimiq%2Fphp-xpub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nimiq%2Fphp-xpub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nimiq","download_url":"https://codeload.github.com/nimiq/php-xpub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238563743,"owners_count":19492976,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["address","bcmath","bitcoin","btc","derivation","eth","ethereum","gmp","nimiq","php"],"created_at":"2025-02-12T22:51:15.937Z","updated_at":"2025-10-27T22:30:23.791Z","avatar_url":"https://github.com/nimiq.png","language":"PHP","readme":"# Nimiq XPub\n\n[![Build Status](https://github.com/nimiq/php-xpub/actions/workflows/php.yml/badge.svg?branch=master)](https://github.com/nimiq/php-xpub/actions/workflows/php.yml)\n\nA simple class to derive BTC and ETH extended public keys and addresses without GMP.\nOnly the BCMath extension is required (but GMP is still used for faster calculations when available).\n\nSupports the following formats:\n\n| Type                  | Mainnet | Testnet |\n|-----------------------|---------|---------|\n| BIP44 (standard)      | xpub    | tpub    |\n| BIP49 (nested segwit) | ypub    | upub    |\n| BIP84 (native segwit) | zpub    | vpub    |\n\n## Installation\n\nThe Nimiq XPub package is availabe via the [Packagist package registry](https://packagist.org/packages/nimiq/xpub) and can be installed with [Composer](https://getcomposer.org):\n\n```bash\ncomposer require nimiq/xpub\n```\n\n### Requirements\n\n* PHP \u003e= 7.1\n* BCMath or GMP extension\n\n## Usage\n\n```php\n# PSR-4 autoloading with composer\nuse Nimiq\\XPub;\n\n# Create an XPub class instance from an xpub/tpub/ypub/upub/zpub/vpub string.\n$xpub = XPub::fromString( 'xpub...' ); // =\u003e BIP44 Original\n$xpub = XPub::fromString( 'ypub...' ); // =\u003e BIP49 Nested SegWit\n$xpub = XPub::fromString( 'zpub...' ); // =\u003e BIP84 Native SegWit\n\n# You can also specify the address scheme to override auto-detection.\n$xpub = XPub::fromString( 'xpub...', XPub::BIP84 );\n$xpub = XPub::fromString( 'xpub...', XPub::BIP49 );\n$xpub = XPub::fromString( 'zpub...', XPub::BIP44 );\n\n# Derive a child extended public key from it.\n$xpub_i = $xpub-\u003ederive( $i );\n# You can also pass an array to derive a path.\n$xpub_i_k = $xpub-\u003ederive( [$i, $k]);\n\n# An XPub can be serialized back into a string.\n# Pass $asHex = true to serialize into a HEX string, base58 is the default.\n$xpub_string = $xpub_i-\u003etoString( $asHex = false );\n\n# An XPub can be converted into an address.\n# Pass $coin = 'eth' to convert into an ETH address.\n#\n# By default, xpubs are converted into standard addresses,\n# ypubs are converted into nested segwit addresses,\n# and zpubs are converted into native segwit addresses.\n$address = $xpub_i-\u003etoAddress( $coin = 'btc' );\n```\n\n_[See the tests](test/test.php) for further example usage._\n\n## Conversion\n\nYou can use this library to convert between xpub formats, for example:\n\n```php\n// Parse any extended public key string\n$xpub = XPub::fromString( 'xpub...' );\n\n// Change the version on the instance\n$xpub-\u003eversion = 'zpub'; // Use any of the supported formats from the table at the top of the README\n\n// Stringify to the target format\n$zpub = $xpub-\u003etoString(); // 'zpub...'\n```\n\n## Helpers\n\nThe `XPub` class also exposes two common hashing methods:\n\n```php\n# Get a hash160\n$hashed_hex = XPub::hash160( $input_hex );\n\n# Get a double sha256\n$hashed_hex = XPub::doubleSha256( $input_hex );\n```\n\n## Development\n\n### Testing\n\nTo execute the test suite run:\n\n```bash\ncomposer run-script test\n# or\nphp test/test.php\n```\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnimiq%2Fphp-xpub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnimiq%2Fphp-xpub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnimiq%2Fphp-xpub/lists"}