Merge branch 'stellar' into tor

This commit is contained in:
sneurlax 2024-04-25 14:05:35 -05:00
commit 2a472491a6
4 changed files with 31 additions and 6 deletions

View file

@ -19,6 +19,9 @@ class Stellar extends Bip39Currency {
@override
int get minConfirms => 1;
@override
bool get torSupport => true;
@override
String get genesisHash => throw UnimplementedError(
"Not used for stellar",

View file

@ -1,7 +1,9 @@
import 'dart:async';
import 'dart:convert';
import 'dart:io';
import 'package:isar/isar.dart';
import 'package:socks5_proxy/socks.dart';
import 'package:stackwallet/models/balance.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
@ -9,6 +11,7 @@ import 'package:stackwallet/models/isar/models/blockchain_data/v2/input_v2.dart'
import 'package:stackwallet/models/isar/models/blockchain_data/v2/output_v2.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/v2/transaction_v2.dart';
import 'package:stackwallet/models/paymint/fee_object_model.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';
@ -43,6 +46,7 @@ class StellarWallet extends Bip39Wallet<Stellar> {
// ============== Private ====================================================
stellar.StellarSDK? _stellarSdk;
HttpClient? _httpClient;
Future<int> _getBaseFee() async {
final fees = await stellarSdk.feeStats.execute();
@ -51,7 +55,21 @@ class StellarWallet extends Bip39Wallet<Stellar> {
void _updateSdk() {
final currentNode = getCurrentNode();
_stellarSdk = stellar.StellarSDK("${currentNode.host}:${currentNode.port}");
// TODO [prio=med]: refactor out and call before requests in case Tor is enabled/disabled, listen to prefs change, or similar.
if (prefs.useTor) {
final ({InternetAddress host, int port}) proxyInfo =
TorService.sharedInstance.getProxyInfo();
_httpClient = HttpClient();
SocksTCPClient.assignToHttpClient(
_httpClient!, [ProxySettings(proxyInfo.host, proxyInfo.port)]);
} else {
_httpClient = null;
}
_stellarSdk = stellar.StellarSDK("${currentNode.host}:${currentNode.port}",
httpClient: _httpClient);
}
Future<bool> _accountExists(String accountId) async {

View file

@ -1659,10 +1659,11 @@ packages:
stellar_flutter_sdk:
dependency: "direct main"
description:
name: stellar_flutter_sdk
sha256: "4c55b1b6dfbde7f89bba59a422754280715fa3b5726cff5e7eeaed454d2c4b89"
url: "https://pub.dev"
source: hosted
path: "."
ref: eca1d730e952cf6a6d64502f977cfc03876b75d4
resolved-ref: eca1d730e952cf6a6d64502f977cfc03876b75d4
url: "https://github.com/cypherstack/stellar_flutter_sdk.git"
source: git
version: "1.5.3"
stream_channel:
dependency: "direct main"

View file

@ -156,7 +156,10 @@ dependencies:
desktop_drop: ^0.4.1
nanodart: ^2.0.0
basic_utils: ^5.5.4
stellar_flutter_sdk: ^1.5.3
stellar_flutter_sdk: # ^1.5.3
git: # TODO [prio=low]: Revert to official package once Tor support is merged upstream.
url: https://github.com/cypherstack/stellar_flutter_sdk.git
ref: eca1d730e952cf6a6d64502f977cfc03876b75d4 # tor-backport branch (based on 1.5.3).
bip340: ^0.2.0
# tezart: ^2.0.5
tezart: