{"id":16668362,"url":"https://github.com/kielabokkie/bitcoin-address-validator","last_synced_at":"2025-03-17T00:31:34.211Z","repository":{"id":45301984,"uuid":"247682386","full_name":"kielabokkie/bitcoin-address-validator","owner":"kielabokkie","description":"PHP package to validate legacy, segwit, native segwit (bech32) and taproot Bitcoin addresses","archived":false,"fork":false,"pushed_at":"2023-09-28T08:29:21.000Z","size":58,"stargazers_count":37,"open_issues_count":2,"forks_count":8,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-27T15:20:24.478Z","etag":null,"topics":["address","bitcoin","bitcoin-addresses","bitcoin-validator","php","php-library","php-package","segwit","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/kielabokkie.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"kielabokkie"}},"created_at":"2020-03-16T11:14:10.000Z","updated_at":"2024-12-13T15:40:56.000Z","dependencies_parsed_at":"2024-06-21T19:01:58.499Z","dependency_job_id":"051a0a28-2120-4ded-a80e-e2933b1a153e","html_url":"https://github.com/kielabokkie/bitcoin-address-validator","commit_stats":{"total_commits":11,"total_committers":2,"mean_commits":5.5,"dds":0.09090909090909094,"last_synced_commit":"0efa6965715600c52f7c583e76b0ae0bfac063be"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kielabokkie%2Fbitcoin-address-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kielabokkie%2Fbitcoin-address-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kielabokkie%2Fbitcoin-address-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kielabokkie%2Fbitcoin-address-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kielabokkie","download_url":"https://codeload.github.com/kielabokkie/bitcoin-address-validator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243835951,"owners_count":20355611,"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","bitcoin","bitcoin-addresses","bitcoin-validator","php","php-library","php-package","segwit","taproot"],"created_at":"2024-10-12T11:24:45.968Z","updated_at":"2025-03-17T00:31:33.694Z","avatar_url":"https://github.com/kielabokkie.png","language":"PHP","funding_links":["https://github.com/sponsors/kielabokkie"],"categories":[],"sub_categories":[],"readme":"# Bitcoin Address Validator\n\n[![Author](http://img.shields.io/badge/follow-@kielabokkie-blue.svg?logo=twitter\u0026style=flat-square)](https://twitter.com/kielabokkie)\n[![Build](https://img.shields.io/github/workflow/status/kielabokkie/bitcoin-address-validator/tests/master?style=flat-square)](https://github.com/kielabokkie/bitcoin-address-validator/actions)\n[![Packagist Version](https://img.shields.io/packagist/v/kielabokkie/bitcoin-address-validator.svg?style=flat-square)](https://packagist.org/packages/kielabokkie/bitcoin-address-validator)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)\n[![Total Downloads](https://img.shields.io/packagist/dt/kielabokkie/bitcoin-address-validator.svg?style=flat-square)](https://packagist.org/packages/kielabokkie/bitcoin-address-validator)\n\nValidate legacy, segwit, native segwit (bech32), and taproot Bitcoin addresses.\n\n## Requirements\n\n* PHP \u003e= 7.3\n\n| PHP  | Package Version |\n| ---- |-----------------|\n| 7.x | v1.0            |\n| 8.x | v2.0+           |\n\nPlease note that taproot addresses are supported from v2.1 of this package.\n\n## Installation\n\nInstall the package via composer:\n\n```\ncomposer require kielabokkie/bitcoin-address-validator\n```\n\n## Usage\n\nFirst you instantiate the validator class:\n\n```php\n$addressValidator = new \\Kielabokkie\\Bitcoin\\AddressValidator;\n```\n\nValidate any kind of address (legacy, segwit, native segwit and taproot):\n\n```php\n$addressValidator-\u003eisValid('1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i');\n```\n\nLegacy (P2PKH) address:\n\n```php\n$addressValidator-\u003eisPayToPublicKeyHash('1AGNa15ZQXAZUgFiqJ2i7Z2DPU2J6hW62i');\n```\n\nSegwit (P2SH) address:\n\n```php\n$addressValidator-\u003eisPayToScriptHash('3ALJH9Y951VCGcVZYAdpA3KchoP9McEj1G');\n```\n\nNative segwit (bech32) address:\n\n```php\n$addressValidator-\u003eisBech32('bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4');\n```\n\nTaproot (P2TR) address:\n\n```php\n$addressValidator-\u003eisPayToTaproot('bc1pveaamy78cq5hvl74zmfw52fxyjun3lh7lgt44j03ygx02zyk8lesgk06f6');\n```\n\n### Testnet\n\nBy default, the validator only passes mainnet addresses as valid. If you would like to validate both mainnet and testnet addresses you can use method chaining:\n\n```php\n// Both valid\n$addressValidator-\u003eincludeTestnet()-\u003eisBech32('bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4');\n$addressValidator-\u003eincludeTestnet()-\u003eisBech32('tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx');\n```\n\nIf you want to validate only testnet addresses you can do that as follows:\n\n```php\n// Invalid\n$addressValidator-\u003eonlyTestnet()-\u003eisBech32('bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4');\n// Valid\n$addressValidator-\u003eonlyTestnet()-\u003eisBech32('tb1qw508d6qejxtdg4y5r3zarvary0c5xw7kxpjzsx');\n```\n\n## Testing\n\nThis package is tested against the test data of the official [bitcoin/bitcoin](https://github.com/bitcoin/bitcoin/tree/master/src/test/data) repo. If you come across an address that is not validated correctly please [open an issue](https://github.com/kielabokkie/bitcoin-address-validator/issues) for it.\n\nRun the tests with:\n\n```bash\ncomposer test\n```\n\n## Credits\n\nThis package is based on the following packages and uses a lot of their code:\n\n* [bitwasp/bech32](https://github.com/Bit-Wasp/bech32) by [@afk11](https://github.com/afk11)\n* [brooksyang/bech32m](https://github.com/BrooksYang/bech32m) by [BrooksYang](https://github.com/BrooksYang)\n* [linusu/bitcoin-address-validator](https://github.com/LinusU/php-bitcoin-address-validator) by [@LinusU](https://github.com/LinusU)\n\nAll credit goes to the original authors.\n\n## Donate\n\nDid this package made you lots of money, save you some time or just sparked joy?\n\nA donation would be much appreciated: `32vtWJSomccxQ6y1tgSwSHXN5PChpdYy27`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkielabokkie%2Fbitcoin-address-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkielabokkie%2Fbitcoin-address-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkielabokkie%2Fbitcoin-address-validator/lists"}