Skip to content
This repository was archived by the owner on Sep 4, 2021. It is now read-only.

Commit a0b4b33

Browse files
authored
Merge pull request #10 from zorn-v/patch-1
Last electrum history compat
2 parents f83c776 + b4f647d commit a0b4b33

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Request/Method/Wallet/GetHistory.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Electrum\Request\AbstractMethod;
66
use Electrum\Request\MethodInterface;
77
use Electrum\Response\Model\Wallet\Transaction;
8+
use Electrum\Response\Exception\BadResponseException;
89

910
/**
1011
* Wallet history. Returns the transaction history of your wallet.
@@ -23,11 +24,19 @@ class GetHistory extends AbstractMethod implements MethodInterface
2324
*
2425
* @return HistoryResponse
2526
* @throws \Electrum\Request\Exception\BadRequestException
26-
* @throws \Electrum\Response\Exception\ElectrumResponseException
27+
* @throws \Electrum\Response\Exception\BadResponseException
2728
*/
2829
public function execute(array $optional = [])
2930
{
3031
$data = $this->getClient()->execute($this->method, $optional);
32+
if (!is_array($data)) {
33+
$data = json_decode($data, true);
34+
if (isset($data['transactions'])) {
35+
$data = $data['transactions'];
36+
} else {
37+
throw new BadResponseException('Cannot get history');
38+
}
39+
}
3140
$transactions = [];
3241
foreach ($data as $transaction) {
3342
$transactions[] = $this->hydrate(new Transaction(), $transaction);

0 commit comments

Comments
 (0)