PHPackages                             headzoo/bitcoin-wallet-api - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. headzoo/bitcoin-wallet-api

ActiveLibrary[API Development](/categories/api)

headzoo/bitcoin-wallet-api
==========================

PHP library supporting communication with the Bitcoin wallet JSON-RPC API.

0.4.0(12y ago)368727MITPHPPHP &gt;=5.4.0

Since Dec 18Pushed 12y ago7 watchersCompare

[ Source](https://github.com/headzoo/bitcoin-wallet-api)[ Packagist](https://packagist.org/packages/headzoo/bitcoin-wallet-api)[ RSS](/packages/headzoo-bitcoin-wallet-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (5)Used By (0)

Bitcoin Wallet API v0.4.0
=========================

[](#bitcoin-wallet-api-v040)

PHP library which facilitates communication with the Bitcoin JSON-RPC API. The rest of this documentation refers to the Bitcoin wallet, but this library works with any Bitcoin wallet descendant. Including wallets for Litecoin and Dogecoin.

- [Overview](#overview)
- [Requirements](#requirements)
- [Installing](#installing)
- [Wallet Configuration](#wallet-configuration)
- [Quick Start](#quick-start)
- [Class Documentation](#class-documentation)
    - [Headzoo\\CoinTalk\\JsonRPC](#headzoobitcoinwalletapijsonrpc)
    - [Headzoo\\CoinTalk\\Wallet](#headzoobitcoinwalletapiwallet)
    - [Headzoo\\Bitcoin\\Wallet\\Api\\RPCPool](#headzoobitcoinwalletapirpcpool)
- [Change Log](#change-log)
- [TODO](#todo)
- [License](#license)

Overview
--------

[](#overview)

The goal of this project is to provide more than a thin PHP wrapper to the Bitcoin JSON-RPC API; there are plenty of PHP libraries for that purpose. This library is meant to be more powerful than other libraries by offering the following features:

- Concrete methods are defined for each API call, which means modern IDEs can provide auto-complete and argument documentation.
- Arguments for each API call are checked for correct type and format, which is useful during development and debugging.
- Abstracts away some of the Bitcoin API complications and inconsistencies, while tyring to stay close to the original.
- Better error handling and reporting.
- RPCPool management so that wallets may be clustered, with queries are evenly distributed to the cluster.
- Follows [PSR](http://www.php-fig.org/) standards.
- Designed from the ground up to be unit testable.
- Solid documentation for each API call, which is often taken directly from the Bitcoin source code.

See the [Bitcoin API wiki](https://en.bitcoin.it/wiki/Original_Bitcoin_client/API_Calls_list) for information on each method.

Requirements
------------

[](#requirements)

- [PHP 5.5 or greater](https://php.net/downloads.php).
- [SimpleXML PHP extension](http://php.net/simplexml).
- [psr/log](https://github.com/php-fig/log).
- [A Bitcoin wallet which supports the JSON-API API](https://bitcoin.org/en/choose-your-wallet).

Installing
----------

[](#installing)

Add the project to your composer.json as a dependency.

```
"require": {
    "headzoo/bitcoin-wallet-api" : "dev-master"
}

```

And then run `composer update`.

Wallet Configuration
--------------------

[](#wallet-configuration)

You will need to configure you wallet to act as a server before using this library. This is done by adding a few configuration values to the `bitcoin.conf` file. Shut down your wallet if it's running, and find your Bitcoin data directory. By default the data directory is located at `/home/[user]/.bitcoin` on Linux systems, and `/Users/[user]/AppData/Roaming/Bitcoin` on Windows systems. Create the `bitcoin.conf` file in the data directory if it does not already exist.

Add the following lines:

```
rpcuser=testuser
rpcpassword=testpass
rpcallowip=127.0.0.1
rpcport=9335
server=1

```

You will of course want to choose a strong username and password combination. Non-Bitcoin wallets are configured in the same way. For example the Litecoin data directory is located at `/home/[user]/.litecoin` on Linux systems, and `/Users/[user]/AppData/Roaming/Litecoin` on Windows systems, and the configuration file is named litecoin.conf.

**Note**: You will also need to add `txindex=1` to your configuration if you want to query the wallet for non-wallet transactions. You may need to start your wallet with the `-rescan` switch for the first time after adding this configuration directive.

Quick Start
-----------

[](#quick-start)

```
