Skip to content

Commit

Permalink
Upgrades from stack (#36)
Browse files Browse the repository at this point in the history
* untested protected rpc version

* update tests

* cleaned up electrumx rpc

* fix: bug in setting _isConnected as well as adding call to refresh on reconnection established

* fix: update electrumx tests

* fix: update fiat price on fiat currency selection changed

* Fix failing tests

* fix: rpc test

---------

Co-authored-by: likho <likhojiba@gmail.com>
julian-CStack and Likho authored May 29, 2023
1 parent 966896b commit 5a88095
Showing 30 changed files with 9,860 additions and 2,322 deletions.
27 changes: 18 additions & 9 deletions lib/electrumx_rpc/electrumx.dart
Original file line number Diff line number Diff line change
@@ -132,13 +132,12 @@ class ElectrumX {

final response = await _rpcClient!.request(jsonRequestString);

print("=================================================");
print("TYPE: ${response.runtimeType}");
print("RESPONSE: $response");
print("=================================================");
if (response.exception != null) {
throw response.exception!;
}

if (response["error"] != null) {
if (response["error"]
if (response.data["error"] != null) {
if (response.data["error"]
.toString()
.contains("No such mempool or blockchain transaction")) {
throw NoSuchTransactionException(
@@ -148,11 +147,15 @@ class ElectrumX {
}

throw Exception(
"JSONRPC response \ncommand: $command \nargs: $args \nerror: $response");
"JSONRPC response\n"
" command: $command\n"
" args: $args\n"
" error: $response.data",
);
}

currentFailoverIndex = -1;
return response;
return response.data;
} on WifiOnlyException {
rethrow;
} on SocketException {
@@ -233,7 +236,13 @@ class ElectrumX {
// Logging.instance.log("batch request: $request");

// send batch request
final response = (await _rpcClient!.request(request)) as List<dynamic>;
final jsonRpcResponse = (await _rpcClient!.request(request));

if (jsonRpcResponse.exception != null) {
throw jsonRpcResponse.exception!;
}

final response = jsonRpcResponse.data as List;

// check for errors, format and throw if there are any
final List<String> errors = [];
Loading

0 comments on commit 5a88095

Please sign in to comment.