{"id":20346028,"url":"https://github.com/andkom/php-bitcoin-address","last_synced_at":"2025-04-12T00:42:48.903Z","repository":{"id":56947742,"uuid":"162169326","full_name":"andkom/php-bitcoin-address","owner":"andkom","description":"A simple P2PK, P2PKH, P2SH, P2WPKH, P2WSH, P2TR output script/address parser/generator/validator.","archived":false,"fork":false,"pushed_at":"2023-11-16T20:22:13.000Z","size":41,"stargazers_count":22,"open_issues_count":1,"forks_count":12,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-09T04:43:35.477Z","etag":null,"topics":["address","address-parser","address-validation","bitcoin","bitcoin-address","bitcoin-script","output","schnorr","schnorr-signatures","script","taproot"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andkom.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-12-17T17:51:13.000Z","updated_at":"2024-12-09T07:16:24.000Z","dependencies_parsed_at":"2023-10-20T17:17:21.611Z","dependency_job_id":null,"html_url":"https://github.com/andkom/php-bitcoin-address","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"f1e821adfe5969cb76b0e2378707d29a7903aacf"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andkom%2Fphp-bitcoin-address","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andkom%2Fphp-bitcoin-address/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andkom%2Fphp-bitcoin-address/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andkom%2Fphp-bitcoin-address/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andkom","download_url":"https://codeload.github.com/andkom/php-bitcoin-address/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248008616,"owners_count":21032554,"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","address-parser","address-validation","bitcoin","bitcoin-address","bitcoin-script","output","schnorr","schnorr-signatures","script","taproot"],"created_at":"2024-11-14T22:11:01.792Z","updated_at":"2025-04-12T00:42:48.881Z","avatar_url":"https://github.com/andkom.png","language":"PHP","readme":"## PHP Bitcoin Address\n\nA simple P2PK, P2PKH, P2SH, P2WPKH, P2WSH, P2TR output script/address parser/generator/validator.\n\n**Supported types:**\n\n- Pay-To-PubKey (P2PK)\n- Pay-To-PubKeyHash (P2PKH)\n- Pay-To-Multisig (P2MS)\n- Pay-To-ScriptHash (P2SH)\n- Pay-To-WitnessPubKeyHash (P2WPKH)\n- Pay-To-WitnessScriptHash (P2WSH)\n- Pay-To-Taproot (P2TR)\n- P2WPKH-over-P2SH\n- P2WSH-over-P2SH\n- any combination\n\n**Supported networks:**\n\n- Bitcoin\n- Bitcoin Testnet\n- Bitcoin Gold\n- Bitcoin Cash\n- Litecoin\n- Litecoin Testnet\n- Dogecoin\n- Dogecoin Testnet\n- Viacoin\n- Viacoin Testnet\n- Dash\n- Dash Testnet\n- Zcash\n\n### Installation\n\n```bash\ncomposer require andkom/php-bitcoin-address\n```\n\n### Examples\n\nGenerate a P2PK/P2PKH address:\n\n```php\n$address = OutputFactory::p2pk($pubKey)-\u003eaddress(); \n$address = OutputFactory::p2pkh($pubKeyHash)-\u003eaddress(); \n```\n\nGenerate a P2MS address:\n\n```php\n$address = OutputFactory::p2ms(2, [$pubKey1, $pubKey2, $pubKey3])-\u003eaddress();\n```\n\nGenerate a P2SH address:\n\n```php\n$factory = new OutputFactory();\n$p2ms = $factory-\u003ep2ms(2, [$pubKey1, $pubKey2, $pubKey3]);\n$address = $factory-\u003ep2sh($p2ms)-\u003eaddress();\n```\n\nGenerate a P2WPKH address:\n\n```php\n$address = OutputFactory::p2wpkh($pubKeyHash)-\u003eaddress();\n```\n\nGenerate a P2WSH address:\n\n```php\n$factory = new OutputFactory();\n$p2ms = $factory-\u003ep2ms(2, [$pubKey1, $pubKey2, $pubKey3]);\n$address = $factory-\u003ep2wsh($p2ms)-\u003eaddress();\n```\n\nGenerate a P2WPKH-over-P2SH address:\n\n```php\n$factory = new OutputFactory();\n$p2wpkh = $factory-\u003ep2wpkh($pubKeyHash);\n$address = $factory-\u003ep2sh($p2wpkh)-\u003eaddress();\n```\n\nGenerate a P2WSH-over-P2SH address:\n\n```php\n$factory = new OutputFactory();\n$p2ms = $factory-\u003ep2ms(2, [$pubKey1, $pubKey2, $pubKey3]);\n$p2wsh = $factory-\u003ep2wsh($p2ms);\n$address = $factory-\u003ep2sh($p2wsh)-\u003eaddress();\n```\n\nGenerate a P2TR address:\n\n```php\n$taprootPubKey = Taproot::construct($pubKey);\n$address = OutputFactory::p2tr($taprootPubKey)-\u003eaddress();\n```\n\nGenerate an address from an output script:\n\n```php\n$address = OutputFactory::fromScript($script)-\u003eaddress();\n```\n\nDecode a Bitcoin address:\n\n```php\n$output = NetworkFactory::bitcoin()-\u003edecodeAddress('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH');\n```\n\nGet a Bitcoin address type:\n\n```php\n$type = NetworkFactory::bitcoin()-\u003edecodeAddress('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH')-\u003etype(); // p2pkh\n```\n\nValidate a Bitcoin address:\n\n```php\nNetworkFactory::bitcoin()-\u003evalidateAddress('1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH'); // true\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandkom%2Fphp-bitcoin-address","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandkom%2Fphp-bitcoin-address","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandkom%2Fphp-bitcoin-address/lists"}