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

Commit fdb78a3

Browse files
authored
Update ElectrumResponseException.php
If wallet does not enough money for transaction, response structure: [ id => 0 error => message (string) ]
1 parent b3f1572 commit fdb78a3

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/Response/Exception/ElectrumResponseException.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,18 @@ public static function createFromElectrumResponse(array $response)
2323
$message = '';
2424
$code = 0;
2525

26-
if (isset($response['error']['message'])) {
26+
if (isset($response['error'])) {
27+
$text = '';
28+
if(is_string($response['error'])) {
29+
$text = $response['error'];
30+
} elseif (is_array($response['error'])
31+
and isset($response['error']['message'])
32+
and is_string($response['error']['message'])) {
33+
$text = $response['error']['message'];
34+
}
2735
$message = vsprintf(
2836
'Electrum API returned error: `%s`',
29-
$response['error']['message']
37+
$text
3038
);
3139
}
3240

@@ -36,4 +44,4 @@ public static function createFromElectrumResponse(array $response)
3644

3745
return new self($message, $code);
3846
}
39-
}
47+
}

0 commit comments

Comments
 (0)