Skip to content

Commit

Permalink
fix : fixes the parsing of json to throw exception.
Browse files Browse the repository at this point in the history
The json received in case of any error is of the type `{error: {code: -32602, message: This payment is destined for ourselves. Self-payments are not supported}, id: (null)commando:pay#106, jsonrpc: 2.0}`.
For now the exceptions are thrown by checking if it contains the `errors` key. But it should be `error` as mentioned in the above response.
  • Loading branch information
Harshit933 authored and vincenzopalazzo committed Jul 12, 2023
1 parent 0b88905 commit 70186d2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/lnlambda/lib/src/lnlambda_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class LNLambdaClient implements LightningClient {
},
body: json.encode(request.toJSON()));
Map<String, dynamic> result = json.decode(response.body);
if (result.containsKey("errors")) {
if (result.containsKey("error")) {
throw Exception(response.body);
}
return result["result"];
Expand Down

0 comments on commit 70186d2

Please sign in to comment.