Skip to content

Commit 5b42aec

Browse files
author
Michael
committed
Port to Litecoin
1 parent 3704100 commit 5b42aec

18 files changed

+590
-119
lines changed

.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/php-litecoinrpc.iml

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 440 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
# Simple Bitcoin JSON-RPC client based on GuzzleHttp
1+
# Simple Litecoin JSON-RPC client based on GuzzleHttp
22

3-
[![Join the chat at https://gitter.im/php-bitcoinrpc/Lobby](https://badges.gitter.im/php-bitcoinrpc/Lobby.svg)](https://gitter.im/php-bitcoinrpc/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
4-
5-
[![Latest Stable Version](https://poser.pugx.org/denpa/php-bitcoinrpc/v/stable)](https://packagist.org/packages/denpa/php-bitcoinrpc) [![License](https://poser.pugx.org/denpa/php-bitcoinrpc/license)](https://packagist.org/packages/denpa/php-bitcoinrpc) [![Build Status](https://travis-ci.org/denpamusic/php-bitcoinrpc.svg)](https://travis-ci.org/denpamusic/php-bitcoinrpc) [![Code Climate](https://codeclimate.com/github/denpamusic/php-bitcoinrpc/badges/gpa.svg)](https://codeclimate.com/github/denpamusic/php-bitcoinrpc) <a href="https://codeclimate.com/github/denpamusic/php-bitcoinrpc/coverage"><img src="https://codeclimate.com/github/denpamusic/php-bitcoinrpc/badges/coverage.svg" /></a> [![Dependency Status](https://www.versioneye.com/user/projects/58833bfce25f5900365362cf/badge.svg?style=rounded)](https://www.versioneye.com/user/projects/58833bfce25f5900365362cf)
3+
## About
4+
This project is based on [php-litecoinrpc](https://github.com/denpamusic/php-bitcoinrpc) project - fully unit-tested Litecoin JSON-RPC client powered by GuzzleHttp.
65

76
## Installation
8-
Run ```php composer.phar require denpa/php-bitcoinrpc``` in your project directory or add following lines to composer.json
7+
Run ```php composer.phar require majestic/php-litecoinrpc``` in your project directory or add following lines to composer.json
98
```javascript
109
"require": {
11-
"denpa/php-bitcoinrpc": "^2.0"
10+
"majestic/php-litecoinrpc": "^2.0"
1211
}
1312
```
1413
and run ```php composer.phar update```.
@@ -19,15 +18,15 @@ PHP 7.0 or higher (should also work on 5.6, but this is unsupported)
1918
## Usage
2019
Create new object with url as parameter
2120
```php
22-
use Denpa\Bitcoin\Client as BitcoinClient;
21+
use Majestic\Litecoin\Client as LitecoinClient;
2322

24-
$bitcoind = new BitcoinClient('http://rpcuser:rpcpassword@localhost:8332/');
23+
$litecoind = new LitecoinClient('http://rpcuser:rpcpassword@localhost:8332/');
2524
```
26-
or use array to define your bitcoind settings
25+
or use array to define your litecoind settings
2726
```php
28-
use Denpa\Bitcoin\Client as BitcoinClient;
27+
use Majestic\Litecoin\Client as LitecoinClient;
2928

30-
$bitcoind = new BitcoinClient([
29+
$litecoind = new LitecoinClient([
3130
'scheme' => 'http', // optional, default http
3231
'host' => 'localhost', // optional, default localhost
3332
'port' => 8332, // optional, default 8332
@@ -36,12 +35,12 @@ $bitcoind = new BitcoinClient([
3635
'ca' => '/etc/ssl/ca-cert.pem' // optional, for use with https scheme
3736
]);
3837
```
39-
Then call methods defined in [Bitcoin Core API Documentation](https://bitcoin.org/en/developer-reference#bitcoin-core-apis) with magic:
38+
Then call methods defined in [Litecoin Core API Documentation](https://litecoin.info/Litecoin_API) with magic:
4039
```php
4140
/**
4241
* Get block info.
4342
*/
44-
$block = $bitcoind->getBlock('000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f');
43+
$block = $litecoind->getBlock('000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f');
4544

4645
$block('hash')->get(); // 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
4746
$block['height']; // 0 (array access)
@@ -60,23 +59,23 @@ $block('tx')->last(); // txid of last transaction
6059
/**
6160
* Send transaction.
6261
*/
63-
$result = $bitcoind->sendToAddress('mmXgiR6KAhZCyQ8ndr2BCfEq1wNG2UnyG6', 0.1);
62+
$result = $litecoind->sendToAddress('mmXgiR6KAhZCyQ8ndr2BCfEq1wNG2UnyG6', 0.1);
6463
$txid = $result->get();
6564

6665
/**
6766
* Get transaction amount.
6867
*/
69-
$result = $bitcoind->listSinceBlock();
68+
$result = $litecoind->listSinceBlock();
7069
$totalAmount = $result->sum('transactions.*.amount');
71-
$totalSatoshi = BitcoinClient::toSatoshi($totalAmount);
70+
$totalSatoshi = LitecoinClient::toSatoshi($totalAmount);
7271
```
7372
To send asynchronous request, add Async to method name:
7473
```php
75-
use Denpa\Bitcoin\BitcoindResponse;
74+
use Majestic\Litecoin\LitecoindResponse;
7675

77-
$promise = $bitcoind->getBlockAsync(
76+
$promise = $litecoind->getBlockAsync(
7877
'000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
79-
function (BitcoindResponse $success) {
78+
function (LitecoindResponse $success) {
8079
//
8180
},
8281
function (\Exception $exception) {
@@ -92,7 +91,7 @@ You can also send requests using request method:
9291
/**
9392
* Get block info.
9493
*/
95-
$block = $bitcoind->request('getBlock', '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f');
94+
$block = $litecoind->request('getBlock', '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f');
9695

9796
$block('hash'); // 000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f
9897
$block['height']; // 0 (array access)
@@ -114,12 +113,12 @@ $txid = $result->get();
114113
```
115114
or requestAsync method for asynchronous calls:
116115
```php
117-
use Denpa\Bitcoin\BitcoindResponse;
116+
use Majestic\Litecoin\LitecoindResponse;
118117

119-
$promise = $bitcoind->requestAsync(
118+
$promise = $litecoind->requestAsync(
120119
'getBlock',
121120
'000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f',
122-
function (BitcoindResponse $success) {
121+
function (LitecoindResponse $success) {
123122
//
124123
},
125124
function (\Exception $exception) {
@@ -137,6 +136,6 @@ This product is distributed under MIT license.
137136
## Donations
138137

139138
If you like this project,
140-
you can donate Bitcoins to 13gkVWc3sdzpmCLkGkXXfPBwnh6ZXct947.
139+
you can donate Litecoins to LKdsQGCwBbgJNdXSQtAvVbFMpwgwThtsSY.
141140

142141
Thanks for your support!❤

composer.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
2-
"name": "denpa/php-bitcoinrpc",
2+
"name": "majestic/php-litecoinrpc",
33
"type": "library",
4-
"description": "Bitcoin JSON-RPC client based on GuzzleHttp",
5-
"keywords": ["bitcoin","api","jsonrpc","guzzle"],
6-
"homepage": "https://github.com/denpamusic/php-bitcoinrpc",
4+
"description": "Litecoin JSON-RPC client based on GuzzleHttp",
5+
"keywords": ["litecoin","api","jsonrpc","guzzle"],
6+
"homepage": "https://github.com/majestic84/php-litecoinrpc",
77
"license": "MIT",
88
"authors": [
99
{
10-
"name": "Denis Paavilainen",
11-
"email": "[email protected]",
10+
"name": "majestic84",
11+
"email": "[email protected]",
1212
"role": "Developer"
1313
}
1414
],
@@ -22,7 +22,7 @@
2222
},
2323
"autoload": {
2424
"psr-4" : {
25-
"Denpa\\Bitcoin\\": "src"
25+
"Majestic\\Litecoin\\": "src"
2626
},
2727
"classmap" : [
2828
"tests"

phpunit.xml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
verbose="true"
1515
>
1616
<testsuites>
17-
<testsuite name="Bitcoin API Test Suite">
17+
<testsuite name="Litecoin API Test Suite">
1818
<directory>tests</directory>
1919
</testsuite>
2020
</testsuites>

src/Client.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Denpa\Bitcoin;
3+
namespace Majestic\Litecoin;
44

55
use GuzzleHttp\Client as GuzzleHttp;
66
use GuzzleHttp\ClientInterface;
@@ -40,7 +40,7 @@ public function __construct($config = [])
4040
$handlerStack = HandlerStack::create();
4141
$handlerStack->push(
4242
Middleware::mapResponse(function (ResponseInterface $response) {
43-
return BitcoindResponse::createFrom($response);
43+
return LitecoindResponse::createFrom($response);
4444
}),
4545
'json_response'
4646
);
@@ -98,7 +98,7 @@ public function setClient(ClientInterface $client)
9898
}
9999

100100
/**
101-
* Makes request to Bitcoin Core.
101+
* Makes request to Litecoin Core.
102102
*
103103
* @param string $method
104104
* @param mixed $params
@@ -118,7 +118,7 @@ public function request($method, $params = [])
118118

119119
if ($response->hasError()) {
120120
// throw exception on error
121-
throw new Exceptions\BitcoindException($response->error());
121+
throw new Exceptions\LitecoindException($response->error());
122122
}
123123

124124
return $response;
@@ -127,20 +127,20 @@ public function request($method, $params = [])
127127
$exception->hasResponse() &&
128128
$exception->getResponse()->hasError()
129129
) {
130-
throw new Exceptions\BitcoindException($exception->getResponse()->error());
130+
throw new Exceptions\LitecoindException($exception->getResponse()->error());
131131
}
132132

133133
throw new Exceptions\ClientException(
134134
$exception->getMessage(),
135135
$exception->getCode()
136136
);
137-
} catch (Exceptions\BitcoindException $exception) {
137+
} catch (Exceptions\LitecoindException $exception) {
138138
throw $exception;
139139
}
140140
}
141141

142142
/**
143-
* Makes async request to Bitcoin Core.
143+
* Makes async request to Litecoin Core.
144144
*
145145
* @param string $method
146146
* @param mixed $params
@@ -168,7 +168,7 @@ public function requestAsync(
168168
function (ResponseInterface $response) use ($onFullfiled) {
169169
$error = null;
170170
if ($response->hasError()) {
171-
$error = new Exceptions\BitcoindException($response->error());
171+
$error = new Exceptions\LitecoindException($response->error());
172172
}
173173

174174
if (is_callable($onFullfiled)) {
@@ -180,7 +180,7 @@ function (RequestException $exception) use ($onRejected) {
180180
$exception->hasResponse() &&
181181
$exception->getResponse()->hasError()
182182
) {
183-
$exception = new Exceptions\BitcoindException(
183+
$exception = new Exceptions\LitecoindException(
184184
$exception->getResponse()->error()
185185
);
186186
}
@@ -202,7 +202,7 @@ function (RequestException $exception) use ($onRejected) {
202202
}
203203

204204
/**
205-
* Makes request to Bitcoin Core.
205+
* Makes request to Litecoin Core.
206206
*
207207
* @param string $method
208208
* @param array $params
@@ -265,7 +265,7 @@ protected function parseUrl($config)
265265
}
266266

267267
/**
268-
* Converts amount from satoshi to bitcoin.
268+
* Converts amount from satoshi to litecoin.
269269
*
270270
* @param int $amount
271271
*
@@ -277,7 +277,7 @@ public static function toBtc($amount)
277277
}
278278

279279
/**
280-
* Converts amount from bitcoin to satoshi.
280+
* Converts amount from litecoin to satoshi.
281281
*
282282
* @param float $amount
283283
*

src/Exceptions/ClientException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22

3-
namespace Denpa\Bitcoin\Exceptions;
3+
namespace Majestic\Litecoin\Exceptions;
44

55
use RuntimeException;
66

src/Exceptions/BitcoindException.php renamed to src/Exceptions/LitecoindException.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?php
22

3-
namespace Denpa\Bitcoin\Exceptions;
3+
namespace Majestic\Litecoin\Exceptions;
44

55
use RuntimeException;
66

77
class BitcoindException extends RuntimeException
88
{
99
/**
10-
* Construct new bitcoind exception.
10+
* Construct new litecoind exception.
1111
*
1212
* @param object $error
1313
*

0 commit comments

Comments
 (0)