Skip to content

Commit

Permalink
tor proxy support
Browse files Browse the repository at this point in the history
  • Loading branch information
MrCyjaneK committed Apr 30, 2024
1 parent 7929d49 commit c48a7f8
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
15 changes: 14 additions & 1 deletion lib/wallets/wallet/impl/monero_wallet.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'dart:math';

import 'package:cw_core/monero_transaction_priority.dart';
Expand All @@ -21,6 +22,8 @@ import 'package:isar/isar.dart';
import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart';
import 'package:stackwallet/services/tor_service.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
import 'package:stackwallet/utilities/logger.dart';
Expand Down Expand Up @@ -153,13 +156,23 @@ class MoneroWallet extends CryptonoteWallet with CwBasedInterface {
final node = getCurrentNode();

final host = Uri.parse(node.host).host;
({InternetAddress host, int port})? proxy;
try {
if (TorService.sharedInstance.status !=
TorConnectionStatus.disconnected) {
proxy = TorService.sharedInstance.getProxyInfo();
}
} catch (e) {
print("proxy disabled: $e");
}
await CwBasedInterface.cwWalletBase?.connectToNode(
node: Node(
uri: "$host:${node.port}",
type: WalletType.monero,
trusted: node.trusted ?? false,
),
socksProxyAddress: null,
socksProxyAddress:
proxy == null ? null : "${proxy.host.address}:${proxy.port}",
);
}

Expand Down
18 changes: 15 additions & 3 deletions lib/wallets/wallet/impl/wownero_wallet.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:io';
import 'dart:math';

import 'package:cw_core/monero_transaction_priority.dart';
Expand All @@ -11,7 +12,6 @@ import 'package:cw_core/wallet_credentials.dart';
import 'package:cw_core/wallet_info.dart';
import 'package:cw_core/wallet_type.dart';
import 'package:cw_monero/api/exceptions/creation_transaction_exception.dart';
import 'package:cw_wownero/api/wallet.dart';
import 'package:cw_wownero/pending_wownero_transaction.dart';
import 'package:cw_wownero/wownero_wallet.dart';
import 'package:decimal/decimal.dart';
Expand All @@ -23,6 +23,8 @@ import 'package:isar/isar.dart';
import 'package:stackwallet/db/hive/db.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart';
import 'package:stackwallet/services/tor_service.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
import 'package:stackwallet/utilities/logger.dart';
Expand Down Expand Up @@ -143,13 +145,23 @@ class WowneroWallet extends CryptonoteWallet with CwBasedInterface {
final node = getCurrentNode();

final host = Uri.parse(node.host).host;
({InternetAddress host, int port})? proxy;
try {
if (TorService.sharedInstance.status !=
TorConnectionStatus.disconnected) {
proxy = TorService.sharedInstance.getProxyInfo();
}
} catch (e) {
print("proxy disabled: $e");
}
await CwBasedInterface.cwWalletBase?.connectToNode(
node: Node(
uri: "$host:${node.port}",
type: WalletType.wownero,
trusted: node.trusted ?? false,
),
socksProxyAddress: null,
socksProxyAddress:
proxy == null ? null : "${proxy.host.address}:${proxy.port}",
);
}

Expand Down Expand Up @@ -332,7 +344,7 @@ class WowneroWallet extends CryptonoteWallet with CwBasedInterface {
// days:
// 2))); // subtract a couple days to ensure we have a buffer for SWB
// TODO(mrcyjanek): implement
final bufferedCreateHeight =
const bufferedCreateHeight =
1; //getSeedHeightSync(wallet!.seed.trim());

await info.updateRestoreHeight(
Expand Down

0 comments on commit c48a7f8

Please sign in to comment.