{"id":14980246,"url":"https://github.com/nbobtc/bitcoind-php","last_synced_at":"2025-04-04T19:14:26.428Z","repository":{"id":5432274,"uuid":"6624617","full_name":"nbobtc/bitcoind-php","owner":"nbobtc","description":"Low level PHP wrapper around bitcoind","archived":false,"fork":false,"pushed_at":"2020-09-30T18:49:27.000Z","size":137,"stargazers_count":165,"open_issues_count":10,"forks_count":62,"subscribers_count":11,"default_branch":"2.x","last_synced_at":"2025-03-28T18:15:44.844Z","etag":null,"topics":["bitcoin-api","bitcoind","php"],"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/nbobtc.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-11-10T05:17:24.000Z","updated_at":"2025-03-15T20:58:33.000Z","dependencies_parsed_at":"2022-07-06T17:33:02.238Z","dependency_job_id":null,"html_url":"https://github.com/nbobtc/bitcoind-php","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbobtc%2Fbitcoind-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbobtc%2Fbitcoind-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbobtc%2Fbitcoind-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nbobtc%2Fbitcoind-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nbobtc","download_url":"https://codeload.github.com/nbobtc/bitcoind-php/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247234923,"owners_count":20905854,"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":["bitcoin-api","bitcoind","php"],"created_at":"2024-09-24T14:01:30.492Z","updated_at":"2025-04-04T19:14:26.411Z","avatar_url":"https://github.com/nbobtc.png","language":"PHP","readme":"nbobtc/bitcoind-php [![Travis branch](https://img.shields.io/travis/nbobtc/bitcoind-php/2.x.svg)](https://travis-ci.org/nbobtc/bitcoind-php) [![Packagist](https://img.shields.io/packagist/v/nbobtc/bitcoind-php.svg)](https://packagist.org/packages/nbobtc/bitcoind-php) [![Packagist Pre Release](https://img.shields.io/packagist/vpre/nbobtc/bitcoind-php.svg)](https://packagist.org/packages/nbobtc/bitcoind-php)\n===================\n\n[![Code Climate](https://img.shields.io/codeclimate/github/nbobtc/bitcoind-php.svg)](https://codeclimate.com/github/nbobtc/bitcoind-php) [![Code Climate](https://img.shields.io/codeclimate/coverage/github/nbobtc/bitcoind-php.svg)](https://codeclimate.com/github/nbobtc/bitcoind-php) [![SensioLabs Insight](https://img.shields.io/sensiolabs/i/c7af9182-f53b-4164-820d-46e7499252f3.svg)](https://insight.sensiolabs.com/projects/c7af9182-f53b-4164-820d-46e7499252f3)\n\nThis project is used to interact with a headless bitcoin program called\nbitcoind. It also contains various utility classes for working with Bitcoin as a\nPHP Developer.\n\n## Installation\n\nYou can install this library by using [Composer]. You can also view more info\nabout this on [Packagist].\n\n```bash\ncomposer require nbobtc/bitcoind-php\n```\n\n## Usage\n\nTo use the project you need to just create a new instance of the class.\n\n```php\n\u003c?php\n\nrequire __DIR__ . '/vendor/autoload.php';\n\n$command = new \\Nbobtc\\Command\\Command('getinfo');\n$client  = new \\Nbobtc\\Http\\Client('https://username:password@localhost:18332');\n\n/** @var \\Nbobtc\\Http\\Message\\Response */\n$response = $client-\u003esendCommand($command);\n\n/** @var string */\n$contents = $response-\u003egetBody()-\u003egetContents();\necho $contents;\n\n\n```\n\nYou are able to get the [Request] and [Response] objects back from\nthe client with the correct getters: `getRequest()` and `getResponse()`.\n\nYou can also parse the response however you wish to do so since the result is\nreturned to you as a string. See below for some ideas!\n\n## Commands\n\nCommands are created in such a way that this will support any future updates the\n[Bitcoin API] by providing you with an easy class that sets all the required\ninformation.\n\nYou are able to pass into the object the `method` and the `parameters` that are\nrequired. Here are a few examples:\n\n```php\n// No Parameters\n$command = new Command('getinfo');\n\n// One Parameter\n$command = new Command('getblock', '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f');\n\n// Multiple Parameters\n$command = new Command('sendfrom', array('fromaccount', 'tobitcoinaddress', 'amount'));\n```\n\nThe second argument MUST be in the same order as on the [Bitcoin API] wiki page.\nThere is no need to assign the values any keys.\n\n### Parameters\n\nParameters are the second argument when creating a new Command. This argument\ncan either be a string OR an array. For example, both of these are valid.\n\n```php\n$command = new Command('getblock', array('000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f'));\n$command = new Command('getblock', '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f');\n```\n\nMost commands in the [Bitcoin API] take one parameter. If it takes MORE than\none, you must pass the parameters in as an array in the ORDER you find them on\nthat page.\n\n### Extending Commands\n\nIf, for any reason, you need to extend a command, it MUST implement\n[CommandInterface]. You can find documentation within the interface on how to\nimplement this.\n\n## Drivers\n\nDrivers are used by the ClientInterface for connecting to a bitcoind service and\nsending Requests. The return a Response. If you need to implement a new driver\ntake a look at the [DriverInterface].\n\n### cURL Driver\n\nThis is used by default and allows you a lot of options for customizing it to\nyour needs.\n\nYou can set various [cURL Options] by passing them into the function\n`addCurlOption($option, $value)`.\n\nHere's an example of how to configure and use the driver.\n\n```php\n$driver = new \\Nbobtc\\Http\\Driver\\CurlDriver();\n$driver\n    -\u003eaddCurlOption(CURLOPT_VERBOSE, true)\n    -\u003eaddCurlOption(CURLOPT_STDERR, '/var/logs/curl.err');\n\n$client = new \\Nbobtc\\Http\\Client('https://username:password@localhost:18332');\n$client-\u003ewithDriver($driver);\n```\n\nFeel free to take a look at the `CurlDriver` source code.\n\n## Cookbook\n\n### How to enable a Keep-Alive ie Persistent Connection\n\nThis example shows how you are able to set the client up to [Persistent\nConnection].\n\n```php\n$client = new \\Nbobtc\\Http\\Client('https://username:password@localhost:18332');\n$client-\u003egetRequest()-\u003ewithHeader('Connection', 'Keep-Alive');\n```\n\n### How to set a CA Cert\n\nThis library provides some wonderful flexibility that will allow you to\nconfigure the client to use your own CA Cert.\n\n```php\n$driver = new \\Nbobtc\\Http\\Driver\\CurlDriver();\n$driver-\u003eaddCurlOption(CURLOPT_CAINFO, '/path/to/cert');\n\n$client = new \\Nbobtc\\Http\\Client('https://username:password@localhost:18332');\n$client-\u003ewithDriver($driver);\n```\n\n### How to Convert Output to an Array\n\nSome like the arrays\n\n```php\n$response = $client-\u003esendCommand($command);\n$output   = json_decode($response-\u003egetBody()-\u003egetContents(), true);\n```\n\n### How to Convert Output to a stdClass object\n\nSome like the objects\n\n```php\n$response = $client-\u003esendCommand($command);\n$output   = json_decode($response-\u003egetBody()-\u003egetContents());\n```\n\n## Testing\n\nAll testing is done using PHPUnit. You should be able to run `phpunit` in the\nroot directory of this project (the directory where phpunit.xml.dist is located)\nand the tests will run.\n\nIf submitting a pull request or working on this library, please make sure that\nthe tests will pass.\n\n## Change log\n\nSee [CHANGELOG.md].\n\nContains information on releases such as what was added, changed, etc. It's good\nto look at to see what has changed from release to release.\n\n## Contributing\n\nSee [CONTRIBUTING.md].\n\nVarious ways on contributing to this project.\n\n## Branching\n\n### master\n\nThis is the latest and greatest, it should not be used an is considered\ndevelopment for testing new features and functionality. This should NOT be used\nin a production environment.\n\n### 2.x\n\nCurrent production branch. All 2.x tags come off of this branch.\n\n### 1.x\n\nDeprecated, only used for bug fixes and for historical records.\n\n## License (MIT) [![Packagist](https://img.shields.io/packagist/l/nbobtc/bitcoind-php.svg)](https://github.com/nbobtc/bitcoind-php/blob/2.x/LICENSE)\n\nCopyright (C) 2012-2018 Joshua Estes\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of\nthis software and associated documentation files (the \"Software\"), to deal in\nthe Software without restriction, including without limitation the rights to\nuse, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of\nthe Software, and to permit persons to whom the Software is furnished to do so,\nsubject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS\nFOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR\nCOPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER\nIN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN\nCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\n[Composer]: https://getcomposer.org/\n[Packagist]: https://packagist.org/packages/nbobtc/bitcoind-php\n[CHANGELOG.md]: https://github.com/nbobtc/bitcoind-php/blob/2.x/CHANGELOG.md\n[CONTRIBUTING.md]: https://github.com/nbobtc/bitcoind-php/blob/2.x/CONTRIBUTING.md\n[Bitcoin API]: https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list\n[Persistent Connection]: http://en.wikipedia.org/wiki/HTTP_persistent_connection\n[cURL Options]: http://php.net/manual/en/function.curl-setopt.php\n[Releases]: https://github.com/nbobtc/bitcoind-php/releases\n[CommandInterface]: https://github.com/nbobtc/bitcoind-php/blob/2.x/src/Command/CommandInterface.php\n[Request]: https://github.com/nbobtc/bitcoind-php/blob/2.x/src/Http/Message/Request.php\n[Response]: https://github.com/nbobtc/bitcoind-php/blob/2.x/src/Http/Message/Response.php\n[DriverInterface]: https://github.com/nbobtc/bitcoind-php/blob/2.x/src/Http/Driver/DriverInterface.php\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnbobtc%2Fbitcoind-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnbobtc%2Fbitcoind-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnbobtc%2Fbitcoind-php/lists"}