bitcont / bitcoin
此包的最新版本(1.0.0)没有可用的许可证信息。
轻量级PHP比特币客户端。
1.0.0
2013-12-10 10:45 UTC
Requires
- php: >= 5.3.0
- kdyby/curl: @dev
- tivoka/tivoka: *
This package is not auto-updated.
Last update: 2024-09-24 01:33:01 UTC
README
目前,有两种解析器可用。
###blockchain.info### 此解析器使用blockchain.info API来检索地址和交易信息。设置简单,但可能相当慢。
###blockchain.info + bitcoind结合### 此解析器使用blockchain.info API来检索地址信息,并使用bitcoind json-rpc API来检索交易信息。它更快,但需要bitcoind。
或者,您可以将自己的解析器添加进来,只要它实现了Bitcont\Bitcoin\Clients\IParser接口。
示例
// choose your parser $bitcoin = new Bitcont\Bitcoin\Clients\BlockchainInfo\Client; // blockchain.info parser $bitcoin = new Bitcont\Bitcoin\Clients\BitcoindInfo\Client('bitcoind username', 'bitcoind password'); // blockchain.info + bitcoind parser // get bitcoin address $address = $bitcoin->getAddress('1Kug5MazR3c8VsBn61JZdvzdix49K7CCES'); // returns IAddress $address->getId(); // returns '1Kug5MazR3c8VsBn61JZdvzdix49K7CCES' // get bitcoin transaction $transaction = $bitcoin->getTransaction('b26369a892dcc3408afcf96af42d0313e1e3c4eed8124ba57506483b6fa3ffc6'); // returns ITransaction $transaction->getId(); // returns 'b26369a892dcc3408afcf96af42d0313e1e3c4eed8124ba57506483b6fa3ffc6' // get transaction inputs $inputs = $transaction->getInputs(); // returns array of IInput // get the first input's info $value = $inputs[0]->getValue(); // returns the number of satoshis (integer) $sender = $inputs[0]->getAddress(); // returns the sender address // get transaction outputs $outputs = $transaction->getOutputs(); // returns array of IOutput // get the last output's value $value = end($outputs)->getValue(); // returns the number of satoshis (integer) $recipient = end($outputs)->getAddress(); // returns the recipient address // get all transactions for an address $transactions = $bitcoin->getTransactions($address); // returns array of ITransaction (oldest first)
安装
建议通过composer进行安装。
要求
PHP 5.3或更高版本。