if just one response is returned, return it as a single-item list

This commit is contained in:
sneurlax 2024-02-02 19:01:26 -06:00
parent 7863b7f209
commit 0108121db3

View file

@ -391,10 +391,14 @@ class ElectrumXClient {
final List<dynamic> response;
try {
response = jsonRpcResponse.data as List;
if (jsonRpcResponse.data is Map) {
response = [jsonRpcResponse.data];
} else {
response = jsonRpcResponse.data as List;
}
} catch (_) {
throw Exception(
"Expected json list but got a map: ${jsonRpcResponse.data}",
"Expected json list or map but got a ${jsonRpcResponse.data.runtimeType}: ${jsonRpcResponse.data}",
);
}