mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-02-02 03:06:35 +00:00
potential fixes
This commit is contained in:
parent
46e89d1d72
commit
0ef8524f52
2 changed files with 17 additions and 23 deletions
|
@ -62,7 +62,7 @@ class Node extends HiveObject with Keyable {
|
|||
|
||||
@HiveField(6)
|
||||
String? socksProxyAddress;
|
||||
|
||||
|
||||
bool get isSSL => useSSL ?? false;
|
||||
|
||||
bool get useSocksProxy => socksProxyAddress == null ? false : socksProxyAddress!.isNotEmpty;
|
||||
|
@ -159,9 +159,6 @@ class Node extends HiveObject with Keyable {
|
|||
}
|
||||
|
||||
Future<bool> requestMoneroNode() async {
|
||||
if (uri.toString().contains(".onion") || useSocksProxy) {
|
||||
return await requestNodeWithProxy();
|
||||
}
|
||||
final path = '/json_rpc';
|
||||
final rpcUri = isSSL ? Uri.https(uri.authority, path) : Uri.http(uri.authority, path);
|
||||
final realm = 'monero-rpc';
|
||||
|
@ -179,17 +176,13 @@ class Node extends HiveObject with Keyable {
|
|||
HttpClientDigestCredentials(login ?? '', password ?? ''),
|
||||
);
|
||||
|
||||
final http.Client client = ioc.IOClient(authenticatingClient);
|
||||
final request = await authenticatingClient.postUrl(rpcUri);
|
||||
request.headers.add("'Content-Type'", "application/json");
|
||||
request.add(utf8.encode(json.encode(body)));
|
||||
final response = await request.close();
|
||||
final responseBody = await utf8.decodeStream(response);
|
||||
|
||||
final response = await client.post(
|
||||
rpcUri,
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: json.encode(body),
|
||||
);
|
||||
|
||||
client.close();
|
||||
|
||||
final resBody = json.decode(response.body) as Map<String, dynamic>;
|
||||
final resBody = json.decode(responseBody) as Map<String, dynamic>;
|
||||
return !(resBody['result']['offline'] as bool);
|
||||
} catch (_) {
|
||||
return false;
|
||||
|
|
|
@ -27,6 +27,8 @@ abstract class TorViewModelBase with Store {
|
|||
});
|
||||
}
|
||||
|
||||
bool torStarted = false;
|
||||
|
||||
final SettingsStore _settingsStore;
|
||||
|
||||
@action
|
||||
|
@ -54,10 +56,11 @@ abstract class TorViewModelBase with Store {
|
|||
}
|
||||
|
||||
bool torOnly = _settingsStore.torConnectionMode == TorConnectionMode.torOnly;
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash].contains(appStore.wallet!.type)) {
|
||||
if ([WalletType.bitcoin, WalletType.litecoin, WalletType.bitcoinCash]
|
||||
.contains(appStore.wallet!.type)) {
|
||||
bitcoin!.setTorOnly(appStore.wallet!, torOnly);
|
||||
}
|
||||
|
||||
|
||||
await appStore.wallet!.connectToNode(node: node);
|
||||
}
|
||||
}
|
||||
|
@ -67,17 +70,13 @@ abstract class TorViewModelBase with Store {
|
|||
try {
|
||||
torConnectionStatus = TorConnectionStatus.connecting;
|
||||
|
||||
await Tor.init();
|
||||
|
||||
// start only if not already running:
|
||||
if (Tor.instance.port == -1) {
|
||||
await Tor.instance.enable();
|
||||
if (!torStarted) {
|
||||
torStarted = true;
|
||||
await Tor.init();
|
||||
}
|
||||
|
||||
_settingsStore.shouldStartTorOnLaunch = true;
|
||||
|
||||
torConnectionStatus = TorConnectionStatus.connected;
|
||||
|
||||
SocksTCPClient.setProxy(proxies: [
|
||||
ProxySettings(
|
||||
InternetAddress.loopbackIPv4,
|
||||
|
@ -86,6 +85,8 @@ abstract class TorViewModelBase with Store {
|
|||
),
|
||||
]);
|
||||
|
||||
torConnectionStatus = TorConnectionStatus.connected;
|
||||
|
||||
// connect to node through the proxy:
|
||||
await connectOrDisconnectNodeToProxy(connect: true);
|
||||
} catch (e) {
|
||||
|
|
Loading…
Reference in a new issue