mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2025-02-02 03:06:29 +00:00
Merge branch 'arti' into wallets_refactor
This commit is contained in:
commit
a0a653b088
44 changed files with 787 additions and 605 deletions
5
.gitmodules
vendored
5
.gitmodules
vendored
|
@ -6,7 +6,4 @@
|
||||||
url = https://github.com/cypherstack/flutter_libmonero.git
|
url = https://github.com/cypherstack/flutter_libmonero.git
|
||||||
[submodule "crypto_plugins/flutter_liblelantus"]
|
[submodule "crypto_plugins/flutter_liblelantus"]
|
||||||
path = crypto_plugins/flutter_liblelantus
|
path = crypto_plugins/flutter_liblelantus
|
||||||
url = https://github.com/cypherstack/flutter_liblelantus.git
|
url = https://github.com/cypherstack/flutter_liblelantus.git
|
||||||
[submodule "crypto_plugins/tor"]
|
|
||||||
path = crypto_plugins/tor
|
|
||||||
url = https://github.com/cypherstack/tor.git
|
|
|
@ -34,7 +34,9 @@ if (keystorePropertiesFile.exists()) {
|
||||||
android {
|
android {
|
||||||
compileSdkVersion 33
|
compileSdkVersion 33
|
||||||
|
|
||||||
ndkVersion = "21.1.6352462"
|
// ndkVersion = "21.1.6352462"
|
||||||
|
// ndkVersion = "25.2.9519653"
|
||||||
|
ndkVersion = "23.1.7779620"
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
|
@ -49,7 +51,9 @@ android {
|
||||||
applicationId "com.cypherstack.stackwallet"
|
applicationId "com.cypherstack.stackwallet"
|
||||||
minSdkVersion 23
|
minSdkVersion 23
|
||||||
targetSdkVersion 33
|
targetSdkVersion 33
|
||||||
ndkVersion = "21.1.6352462"
|
// ndkVersion = "21.1.6352462"
|
||||||
|
// ndkVersion = "25.2.9519653"
|
||||||
|
ndkVersion = "23.1.7779620"
|
||||||
versionCode flutterVersionCode.toInteger()
|
versionCode flutterVersionCode.toInteger()
|
||||||
versionName flutterVersionName
|
versionName flutterVersionName
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
buildscript {
|
buildscript {
|
||||||
ext.kotlin_version = '1.7.10'
|
ext.kotlin_version = '1.8.0'
|
||||||
repositories {
|
repositories {
|
||||||
google()
|
google()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:7.3.0'
|
classpath 'com.android.tools.build:gradle:7.3.1'
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
1
assets/lottie/onion_animation.json
Normal file
1
assets/lottie/onion_animation.json
Normal file
File diff suppressed because one or more lines are too long
|
@ -1 +1 @@
|
||||||
Subproject commit f677dec0b34d3f9fe8fce2bc8ff5c508c3f3bb9a
|
Subproject commit 2de3fa0459ac29361d65a86883e1d0648e6a4b1a
|
|
@ -1 +1 @@
|
||||||
Subproject commit 9cd241b5ea142e21c01dd7639b42603281c43287
|
Subproject commit 1f8fde935bbb23585477b0cb884bee9be6d12a87
|
|
@ -1 +1 @@
|
||||||
Subproject commit e48952185556a10f182184fd572bcb04365f5831
|
Subproject commit 8a46a5d0984cf7fbc1ce5d77cbb74dc6933da59c
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit a819223b23e9fa1d76bde82ed9109651e96f2ad3
|
|
|
@ -187,8 +187,8 @@ class ElectrumX {
|
||||||
void _checkRpcClient() {
|
void _checkRpcClient() {
|
||||||
// If we're supposed to use Tor...
|
// If we're supposed to use Tor...
|
||||||
if (_prefs.useTor) {
|
if (_prefs.useTor) {
|
||||||
// But Tor isn't enabled...
|
// But Tor isn't running...
|
||||||
if (!_torService.enabled) {
|
if (_torService.status != TorConnectionStatus.connected) {
|
||||||
// And the killswitch isn't set...
|
// And the killswitch isn't set...
|
||||||
if (!_prefs.torKillSwitch) {
|
if (!_prefs.torKillSwitch) {
|
||||||
// Then we'll just proceed and connect to ElectrumX through clearnet at the bottom of this function.
|
// Then we'll just proceed and connect to ElectrumX through clearnet at the bottom of this function.
|
||||||
|
@ -203,7 +203,7 @@ class ElectrumX {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Get the proxy info from the TorService.
|
// Get the proxy info from the TorService.
|
||||||
final proxyInfo = _torService.proxyInfo;
|
final proxyInfo = _torService.getProxyInfo();
|
||||||
|
|
||||||
if (currentFailoverIndex == -1) {
|
if (currentFailoverIndex == -1) {
|
||||||
_rpcClient ??= JsonRPC(
|
_rpcClient ??= JsonRPC(
|
||||||
|
|
|
@ -173,7 +173,9 @@ void main() async {
|
||||||
// Some refactoring will need to be done here to make sure we don't make any
|
// Some refactoring will need to be done here to make sure we don't make any
|
||||||
// network calls before starting up tor
|
// network calls before starting up tor
|
||||||
if (Prefs.instance.useTor) {
|
if (Prefs.instance.useTor) {
|
||||||
TorService.sharedInstance.init();
|
TorService.sharedInstance.init(
|
||||||
|
torDataDirPath: (await StackFileSystem.applicationTorDirectory()).path,
|
||||||
|
);
|
||||||
await TorService.sharedInstance.start();
|
await TorService.sharedInstance.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,10 +12,12 @@ import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
|
import 'package:stackwallet/models/isar/models/ethereum/eth_contract.dart';
|
||||||
import 'package:stackwallet/pages/buy_view/buy_form.dart';
|
import 'package:stackwallet/pages/buy_view/buy_form.dart';
|
||||||
import 'package:stackwallet/providers/global/prefs_provider.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/themes/stack_colors.dart';
|
import 'package:stackwallet/themes/stack_colors.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||||
|
import 'package:stackwallet/widgets/tor_subscription.dart';
|
||||||
|
|
||||||
class BuyView extends ConsumerStatefulWidget {
|
class BuyView extends ConsumerStatefulWidget {
|
||||||
const BuyView({
|
const BuyView({
|
||||||
|
@ -36,18 +38,16 @@ class BuyView extends ConsumerStatefulWidget {
|
||||||
class _BuyViewState extends ConsumerState<BuyView> {
|
class _BuyViewState extends ConsumerState<BuyView> {
|
||||||
Coin? coin;
|
Coin? coin;
|
||||||
EthContract? tokenContract;
|
EthContract? tokenContract;
|
||||||
late bool torEnabled = false;
|
|
||||||
|
late bool torEnabled;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
coin = widget.coin;
|
coin = widget.coin;
|
||||||
tokenContract = widget.tokenContract;
|
tokenContract = widget.tokenContract;
|
||||||
|
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
torEnabled =
|
||||||
setState(() {
|
ref.read(pTorService).status != TorConnectionStatus.disconnected;
|
||||||
torEnabled = ref.read(prefsChangeNotifierProvider).useTor;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
@ -56,35 +56,42 @@ class _BuyViewState extends ConsumerState<BuyView> {
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
debugPrint("BUILD: $runtimeType");
|
debugPrint("BUILD: $runtimeType");
|
||||||
|
|
||||||
return Stack(
|
return TorSubscription(
|
||||||
children: [
|
onTorStatusChanged: (status) {
|
||||||
SafeArea(
|
setState(() {
|
||||||
child: Padding(
|
torEnabled = status != TorConnectionStatus.disconnected;
|
||||||
padding: const EdgeInsets.only(
|
});
|
||||||
left: 16,
|
},
|
||||||
right: 16,
|
child: Stack(
|
||||||
top: 16,
|
children: [
|
||||||
),
|
SafeArea(
|
||||||
child: BuyForm(
|
child: Padding(
|
||||||
coin: coin,
|
padding: const EdgeInsets.only(
|
||||||
tokenContract: tokenContract,
|
left: 16,
|
||||||
|
right: 16,
|
||||||
|
top: 16,
|
||||||
|
),
|
||||||
|
child: BuyForm(
|
||||||
|
coin: coin,
|
||||||
|
tokenContract: tokenContract,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
if (torEnabled)
|
||||||
if (torEnabled)
|
Container(
|
||||||
Container(
|
color: Theme.of(context)
|
||||||
color: Theme.of(context)
|
.extension<StackColors>()!
|
||||||
.extension<StackColors>()!
|
.overlay
|
||||||
.overlay
|
.withOpacity(0.7),
|
||||||
.withOpacity(0.7),
|
height: MediaQuery.of(context).size.height,
|
||||||
height: MediaQuery.of(context).size.height,
|
width: MediaQuery.of(context).size.width,
|
||||||
width: MediaQuery.of(context).size.width,
|
child: const StackDialog(
|
||||||
child: const StackDialog(
|
title: "Tor is enabled",
|
||||||
title: "Tor is enabled",
|
message: "Purchasing not available while Tor is enabled",
|
||||||
message: "Purchasing not available while Tor is enabled",
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,7 @@ import 'package:stackwallet/models/isar/ordinal.dart';
|
||||||
import 'package:stackwallet/networking/http.dart';
|
import 'package:stackwallet/networking/http.dart';
|
||||||
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
import 'package:stackwallet/notifications/show_flush_bar.dart';
|
||||||
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
import 'package:stackwallet/providers/db/main_db_provider.dart';
|
||||||
|
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||||
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
import 'package:stackwallet/providers/global/wallets_provider.dart';
|
||||||
import 'package:stackwallet/services/tor_service.dart';
|
import 'package:stackwallet/services/tor_service.dart';
|
||||||
import 'package:stackwallet/themes/stack_colors.dart';
|
import 'package:stackwallet/themes/stack_colors.dart';
|
||||||
|
@ -20,7 +21,6 @@ import 'package:stackwallet/utilities/amount/amount_formatter.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/prefs.dart';
|
|
||||||
import 'package:stackwallet/utilities/show_loading.dart';
|
import 'package:stackwallet/utilities/show_loading.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/widgets/background.dart';
|
import 'package:stackwallet/widgets/background.dart';
|
||||||
|
@ -219,7 +219,7 @@ class _DetailsItemWCopy extends StatelessWidget {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class _OrdinalImageGroup extends StatelessWidget {
|
class _OrdinalImageGroup extends ConsumerWidget {
|
||||||
const _OrdinalImageGroup({
|
const _OrdinalImageGroup({
|
||||||
Key? key,
|
Key? key,
|
||||||
required this.walletId,
|
required this.walletId,
|
||||||
|
@ -231,13 +231,14 @@ class _OrdinalImageGroup extends StatelessWidget {
|
||||||
|
|
||||||
static const _spacing = 12.0;
|
static const _spacing = 12.0;
|
||||||
|
|
||||||
Future<String> _savePngToFile() async {
|
Future<String> _savePngToFile(WidgetRef ref) async {
|
||||||
HTTP client = HTTP();
|
HTTP client = HTTP();
|
||||||
|
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: Uri.parse(ordinal.content),
|
url: Uri.parse(ordinal.content),
|
||||||
proxyInfo:
|
proxyInfo: ref.read(prefsChangeNotifierProvider).useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? ref.read(pTorService).getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code != 200) {
|
if (response.code != 200) {
|
||||||
|
@ -268,7 +269,7 @@ class _OrdinalImageGroup extends StatelessWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
return Column(
|
return Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
crossAxisAlignment: CrossAxisAlignment.center,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
|
@ -318,7 +319,7 @@ class _OrdinalImageGroup extends StatelessWidget {
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
bool didError = false;
|
bool didError = false;
|
||||||
final filePath = await showLoading<String>(
|
final filePath = await showLoading<String>(
|
||||||
whileFuture: _savePngToFile(),
|
whileFuture: _savePngToFile(ref),
|
||||||
context: context,
|
context: context,
|
||||||
isDesktop: true,
|
isDesktop: true,
|
||||||
message: "Saving ordinal image",
|
message: "Saving ordinal image",
|
||||||
|
|
|
@ -50,8 +50,9 @@ Future<bool> doesCommitExist(
|
||||||
final commitQuery = await client.get(
|
final commitQuery = await client.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final response = jsonDecode(commitQuery.body.toString());
|
final response = jsonDecode(commitQuery.body.toString());
|
||||||
|
@ -89,8 +90,9 @@ Future<bool> isHeadCommit(
|
||||||
final commitQuery = await client.get(
|
final commitQuery = await client.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final response = jsonDecode(commitQuery.body.toString());
|
final response = jsonDecode(commitQuery.body.toString());
|
||||||
|
|
|
@ -13,6 +13,7 @@ import 'dart:async';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:flutter_svg/flutter_svg.dart';
|
import 'package:flutter_svg/flutter_svg.dart';
|
||||||
|
import 'package:lottie/lottie.dart';
|
||||||
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
import 'package:stackwallet/providers/global/prefs_provider.dart';
|
||||||
import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.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/services/tor_service.dart';
|
||||||
|
@ -20,6 +21,7 @@ import 'package:stackwallet/themes/stack_colors.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
|
import 'package:stackwallet/utilities/stack_file_system.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/widgets/background.dart';
|
import 'package:stackwallet/widgets/background.dart';
|
||||||
import 'package:stackwallet/widgets/conditional_parent.dart';
|
import 'package:stackwallet/widgets/conditional_parent.dart';
|
||||||
|
@ -31,7 +33,9 @@ import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||||
import 'package:stackwallet/widgets/tor_subscription.dart';
|
import 'package:stackwallet/widgets/tor_subscription.dart';
|
||||||
|
|
||||||
class TorSettingsView extends ConsumerStatefulWidget {
|
class TorSettingsView extends ConsumerStatefulWidget {
|
||||||
const TorSettingsView({Key? key}) : super(key: key);
|
const TorSettingsView({
|
||||||
|
Key? key,
|
||||||
|
}) : super(key: key);
|
||||||
|
|
||||||
static const String routeName = "/torSettings";
|
static const String routeName = "/torSettings";
|
||||||
|
|
||||||
|
@ -71,7 +75,7 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
|
||||||
useSafeArea: false,
|
useSafeArea: false,
|
||||||
barrierDismissible: true,
|
barrierDismissible: true,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return const StackDialog(
|
return StackDialog(
|
||||||
title: "What is Tor?",
|
title: "What is Tor?",
|
||||||
message:
|
message:
|
||||||
"Short for \"The Onion Router\", is an open-source software that enables internet communication"
|
"Short for \"The Onion Router\", is an open-source software that enables internet communication"
|
||||||
|
@ -79,6 +83,7 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
|
||||||
" to obscure the origin and destination of data.",
|
" to obscure the origin and destination of data.",
|
||||||
rightButton: SecondaryButton(
|
rightButton: SecondaryButton(
|
||||||
label: "Close",
|
label: "Close",
|
||||||
|
onPressed: Navigator.of(context).pop,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -98,7 +103,7 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
|
||||||
children: [
|
children: [
|
||||||
Padding(
|
Padding(
|
||||||
padding: EdgeInsets.all(10.0),
|
padding: EdgeInsets.all(10.0),
|
||||||
child: TorIcon(),
|
child: TorAnimatedButton(),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
@ -140,7 +145,7 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
|
||||||
useSafeArea: false,
|
useSafeArea: false,
|
||||||
barrierDismissible: true,
|
barrierDismissible: true,
|
||||||
builder: (context) {
|
builder: (context) {
|
||||||
return const StackDialog(
|
return StackDialog(
|
||||||
title: "What is Tor killswitch?",
|
title: "What is Tor killswitch?",
|
||||||
message:
|
message:
|
||||||
"A security feature that protects your information from accidental exposure by"
|
"A security feature that protects your information from accidental exposure by"
|
||||||
|
@ -148,6 +153,8 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
|
||||||
" connection is disrupted or compromised.",
|
" connection is disrupted or compromised.",
|
||||||
rightButton: SecondaryButton(
|
rightButton: SecondaryButton(
|
||||||
label: "Close",
|
label: "Close",
|
||||||
|
onPressed:
|
||||||
|
Navigator.of(context).pop,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
@ -194,48 +201,19 @@ class _TorSettingsViewState extends ConsumerState<TorSettingsView> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class TorIcon extends ConsumerStatefulWidget {
|
class TorAnimatedButton extends ConsumerStatefulWidget {
|
||||||
const TorIcon({super.key});
|
const TorAnimatedButton({super.key});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
ConsumerState<TorIcon> createState() => _TorIconState();
|
ConsumerState<TorAnimatedButton> createState() => _TorAnimatedButtonState();
|
||||||
}
|
}
|
||||||
|
|
||||||
class _TorIconState extends ConsumerState<TorIcon> {
|
class _TorAnimatedButtonState extends ConsumerState<TorAnimatedButton>
|
||||||
|
with SingleTickerProviderStateMixin {
|
||||||
|
late final AnimationController controller1;
|
||||||
|
|
||||||
late TorConnectionStatus _status;
|
late TorConnectionStatus _status;
|
||||||
|
|
||||||
Color _color(
|
|
||||||
TorConnectionStatus status,
|
|
||||||
StackColors colors,
|
|
||||||
) {
|
|
||||||
switch (status) {
|
|
||||||
case TorConnectionStatus.disconnected:
|
|
||||||
return colors.textSubtitle3;
|
|
||||||
|
|
||||||
case TorConnectionStatus.connected:
|
|
||||||
return colors.accentColorGreen;
|
|
||||||
|
|
||||||
case TorConnectionStatus.connecting:
|
|
||||||
return colors.accentColorYellow;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
String _label(
|
|
||||||
TorConnectionStatus status,
|
|
||||||
StackColors colors,
|
|
||||||
) {
|
|
||||||
switch (status) {
|
|
||||||
case TorConnectionStatus.disconnected:
|
|
||||||
return "CONNECT";
|
|
||||||
|
|
||||||
case TorConnectionStatus.connected:
|
|
||||||
return "STOP";
|
|
||||||
|
|
||||||
case TorConnectionStatus.connecting:
|
|
||||||
return "CONNECTING";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool _tapLock = false;
|
bool _tapLock = false;
|
||||||
|
|
||||||
Future<void> onTap() async {
|
Future<void> onTap() async {
|
||||||
|
@ -268,22 +246,106 @@ class _TorIconState extends ConsumerState<TorIcon> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _playConnecting() async {
|
||||||
|
await _play(
|
||||||
|
from: "connecting-start",
|
||||||
|
to: "connecting-end",
|
||||||
|
repeat: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _playConnectingDone() async {
|
||||||
|
await _play(
|
||||||
|
from: "connecting-end",
|
||||||
|
to: "connected-start",
|
||||||
|
repeat: false,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _playConnected() async {
|
||||||
|
await _play(
|
||||||
|
from: "connected-start",
|
||||||
|
to: "connected-end",
|
||||||
|
repeat: true,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _playDisconnect() async {
|
||||||
|
await _play(
|
||||||
|
from: "disconnection-start",
|
||||||
|
to: "disconnection-end",
|
||||||
|
repeat: false,
|
||||||
|
);
|
||||||
|
controller1.reset();
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<void> _play({
|
||||||
|
required String from,
|
||||||
|
required String to,
|
||||||
|
required bool repeat,
|
||||||
|
}) async {
|
||||||
|
final composition = await _completer.future;
|
||||||
|
final start = composition.getMarker(from)!.start;
|
||||||
|
final end = composition.getMarker(to)!.start;
|
||||||
|
|
||||||
|
controller1.value = start;
|
||||||
|
|
||||||
|
if (repeat) {
|
||||||
|
await controller1.repeat(
|
||||||
|
min: start,
|
||||||
|
max: end,
|
||||||
|
period: composition.duration * (end - start),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
await controller1.animateTo(
|
||||||
|
end,
|
||||||
|
duration: composition.duration * (end - start),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
late Completer<LottieComposition> _completer;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_status = ref.read(pTorService).enabled
|
controller1 = AnimationController(vsync: this);
|
||||||
? TorConnectionStatus.connected
|
|
||||||
: TorConnectionStatus.disconnected;
|
_status = ref.read(pTorService).status;
|
||||||
|
|
||||||
|
_completer = Completer();
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void dispose() {
|
||||||
|
controller1.dispose();
|
||||||
|
|
||||||
|
super.dispose();
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
// TODO: modify size (waiting for updated onion lottie animation file)
|
||||||
|
final width = MediaQuery.of(context).size.width / 1.5;
|
||||||
|
|
||||||
return TorSubscription(
|
return TorSubscription(
|
||||||
onTorStatusChanged: (status) {
|
onTorStatusChanged: (status) async {
|
||||||
setState(() {
|
_status = status;
|
||||||
_status = status;
|
switch (_status) {
|
||||||
});
|
case TorConnectionStatus.disconnected:
|
||||||
|
await _playDisconnect();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TorConnectionStatus.connected:
|
||||||
|
await _playConnectingDone();
|
||||||
|
await _playConnected();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TorConnectionStatus.connecting:
|
||||||
|
await _playConnecting();
|
||||||
|
break;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
child: ConditionalParent(
|
child: ConditionalParent(
|
||||||
condition: _status != TorConnectionStatus.connecting,
|
condition: _status != TorConnectionStatus.connecting,
|
||||||
|
@ -291,32 +353,29 @@ class _TorIconState extends ConsumerState<TorIcon> {
|
||||||
onTap: onTap,
|
onTap: onTap,
|
||||||
child: child,
|
child: child,
|
||||||
),
|
),
|
||||||
child: SizedBox(
|
child: Column(
|
||||||
width: 220,
|
children: [
|
||||||
height: 220,
|
SizedBox(
|
||||||
child: Stack(
|
width: width,
|
||||||
alignment: AlignmentDirectional.center,
|
child: Lottie.asset(
|
||||||
children: [
|
Assets.lottie.onionTor,
|
||||||
SvgPicture.asset(
|
controller: controller1,
|
||||||
Assets.svg.tor,
|
width: width,
|
||||||
color: _color(
|
// height: width,
|
||||||
_status,
|
onLoaded: (composition) {
|
||||||
Theme.of(context).extension<StackColors>()!,
|
_completer.complete(composition);
|
||||||
),
|
controller1.duration = composition.duration;
|
||||||
width: 200,
|
|
||||||
height: 200,
|
if (_status == TorConnectionStatus.connected) {
|
||||||
|
_playConnected();
|
||||||
|
} else if (_status == TorConnectionStatus.connecting) {
|
||||||
|
_playConnecting();
|
||||||
|
}
|
||||||
|
},
|
||||||
),
|
),
|
||||||
Text(
|
),
|
||||||
_label(
|
const UpperCaseTorText(),
|
||||||
_status,
|
],
|
||||||
Theme.of(context).extension<StackColors>()!,
|
|
||||||
),
|
|
||||||
style: STextStyles.smallMed14(context).copyWith(
|
|
||||||
color: Theme.of(context).extension<StackColors>()!.popupBG,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
@ -399,9 +458,7 @@ class _TorButtonState extends ConsumerState<TorButton> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_status = ref.read(pTorService).enabled
|
_status = ref.read(pTorService).status;
|
||||||
? TorConnectionStatus.connected
|
|
||||||
: TorConnectionStatus.disconnected;
|
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
@ -447,6 +504,78 @@ class _TorButtonState extends ConsumerState<TorButton> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class UpperCaseTorText extends ConsumerStatefulWidget {
|
||||||
|
const UpperCaseTorText({super.key});
|
||||||
|
|
||||||
|
@override
|
||||||
|
ConsumerState<UpperCaseTorText> createState() => _UpperCaseTorTextState();
|
||||||
|
}
|
||||||
|
|
||||||
|
class _UpperCaseTorTextState extends ConsumerState<UpperCaseTorText> {
|
||||||
|
late TorConnectionStatus _status;
|
||||||
|
|
||||||
|
Color _color(
|
||||||
|
TorConnectionStatus status,
|
||||||
|
StackColors colors,
|
||||||
|
) {
|
||||||
|
switch (status) {
|
||||||
|
case TorConnectionStatus.disconnected:
|
||||||
|
return colors.textSubtitle3;
|
||||||
|
|
||||||
|
case TorConnectionStatus.connected:
|
||||||
|
return colors.accentColorGreen;
|
||||||
|
|
||||||
|
case TorConnectionStatus.connecting:
|
||||||
|
return colors.accentColorYellow;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String _label(
|
||||||
|
TorConnectionStatus status,
|
||||||
|
) {
|
||||||
|
switch (status) {
|
||||||
|
case TorConnectionStatus.disconnected:
|
||||||
|
return "CONNECT";
|
||||||
|
|
||||||
|
case TorConnectionStatus.connected:
|
||||||
|
return "STOP";
|
||||||
|
|
||||||
|
case TorConnectionStatus.connecting:
|
||||||
|
return "CONNECTING";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void initState() {
|
||||||
|
_status = ref.read(pTorService).status;
|
||||||
|
|
||||||
|
super.initState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
Widget build(BuildContext context) {
|
||||||
|
return TorSubscription(
|
||||||
|
onTorStatusChanged: (status) {
|
||||||
|
setState(() {
|
||||||
|
_status = status;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
child: Text(
|
||||||
|
_label(
|
||||||
|
_status,
|
||||||
|
),
|
||||||
|
style: STextStyles.pageTitleH2(
|
||||||
|
context,
|
||||||
|
).copyWith(
|
||||||
|
color: _color(
|
||||||
|
_status,
|
||||||
|
Theme.of(context).extension<StackColors>()!,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Connect to the Tor network.
|
/// Connect to the Tor network.
|
||||||
///
|
///
|
||||||
/// This method is called when the user taps the "Connect" button.
|
/// This method is called when the user taps the "Connect" button.
|
||||||
|
@ -455,11 +584,11 @@ class _TorButtonState extends ConsumerState<TorButton> {
|
||||||
///
|
///
|
||||||
/// Returns a Future that completes when the Tor service has started.
|
/// Returns a Future that completes when the Tor service has started.
|
||||||
Future<void> _connectTor(WidgetRef ref, BuildContext context) async {
|
Future<void> _connectTor(WidgetRef ref, BuildContext context) async {
|
||||||
// Init the Tor service if it hasn't already been.
|
|
||||||
ref.read(pTorService).init();
|
|
||||||
|
|
||||||
// Start the Tor service.
|
|
||||||
try {
|
try {
|
||||||
|
// Init the Tor service if it hasn't already been.
|
||||||
|
final torDir = await StackFileSystem.applicationTorDirectory();
|
||||||
|
ref.read(pTorService).init(torDataDirPath: torDir.path);
|
||||||
|
// Start the Tor service.
|
||||||
await ref.read(pTorService).start();
|
await ref.read(pTorService).start();
|
||||||
|
|
||||||
// Toggle the useTor preference on success.
|
// Toggle the useTor preference on success.
|
||||||
|
@ -485,7 +614,7 @@ Future<void> _connectTor(WidgetRef ref, BuildContext context) async {
|
||||||
Future<void> _disconnectTor(WidgetRef ref, BuildContext context) async {
|
Future<void> _disconnectTor(WidgetRef ref, BuildContext context) async {
|
||||||
// Stop the Tor service.
|
// Stop the Tor service.
|
||||||
try {
|
try {
|
||||||
await ref.read(pTorService).stop();
|
await ref.read(pTorService).disable();
|
||||||
|
|
||||||
// Toggle the useTor preference on success.
|
// Toggle the useTor preference on success.
|
||||||
ref.read(prefsChangeNotifierProvider).useTor = false;
|
ref.read(prefsChangeNotifierProvider).useTor = false;
|
||||||
|
|
|
@ -36,6 +36,7 @@ import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/constants.dart';
|
import 'package:stackwallet/utilities/constants.dart';
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
import 'package:stackwallet/utilities/enums/coin_enum.dart';
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
|
import 'package:stackwallet/utilities/stack_file_system.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/util.dart';
|
import 'package:stackwallet/utilities/util.dart';
|
||||||
import 'package:stackwallet/widgets/animated_text.dart';
|
import 'package:stackwallet/widgets/animated_text.dart';
|
||||||
|
@ -48,6 +49,7 @@ import 'package:stackwallet/widgets/progress_bar.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_container.dart';
|
import 'package:stackwallet/widgets/rounded_container.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||||
import 'package:stackwallet/widgets/stack_dialog.dart';
|
import 'package:stackwallet/widgets/stack_dialog.dart';
|
||||||
|
import 'package:stackwallet/widgets/tor_subscription.dart';
|
||||||
import 'package:tuple/tuple.dart';
|
import 'package:tuple/tuple.dart';
|
||||||
import 'package:wakelock/wakelock.dart';
|
import 'package:wakelock/wakelock.dart';
|
||||||
|
|
||||||
|
@ -98,10 +100,6 @@ class _WalletNetworkSettingsViewState
|
||||||
/// The current status of the Tor connection.
|
/// The current status of the Tor connection.
|
||||||
late TorConnectionStatus _torConnectionStatus;
|
late TorConnectionStatus _torConnectionStatus;
|
||||||
|
|
||||||
/// The subscription to the TorConnectionStatusChangedEvent.
|
|
||||||
late final StreamSubscription<TorConnectionStatusChangedEvent>
|
|
||||||
_torConnectionStatusSubscription;
|
|
||||||
|
|
||||||
Future<void> _attemptRescan() async {
|
Future<void> _attemptRescan() async {
|
||||||
if (!Platform.isLinux) await Wakelock.enable();
|
if (!Platform.isLinux) await Wakelock.enable();
|
||||||
|
|
||||||
|
@ -280,22 +278,7 @@ class _WalletNetworkSettingsViewState
|
||||||
// );
|
// );
|
||||||
|
|
||||||
// Initialize the TorConnectionStatus.
|
// Initialize the TorConnectionStatus.
|
||||||
_torConnectionStatus = ref.read(pTorService).enabled
|
_torConnectionStatus = ref.read(pTorService).status;
|
||||||
? TorConnectionStatus.connected
|
|
||||||
: TorConnectionStatus.disconnected;
|
|
||||||
|
|
||||||
// Subscribe to the TorConnectionStatusChangedEvent.
|
|
||||||
_torConnectionStatusSubscription =
|
|
||||||
eventBus.on<TorConnectionStatusChangedEvent>().listen(
|
|
||||||
(event) async {
|
|
||||||
// Rebuild the widget.
|
|
||||||
setState(() {
|
|
||||||
_torConnectionStatus = event.newStatus;
|
|
||||||
});
|
|
||||||
|
|
||||||
// TODO implement spinner or animations and control from here
|
|
||||||
},
|
|
||||||
);
|
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
@ -306,7 +289,6 @@ class _WalletNetworkSettingsViewState
|
||||||
_syncStatusSubscription.cancel();
|
_syncStatusSubscription.cancel();
|
||||||
_refreshSubscription.cancel();
|
_refreshSubscription.cancel();
|
||||||
_blocksRemainingSubscription?.cancel();
|
_blocksRemainingSubscription?.cancel();
|
||||||
_torConnectionStatusSubscription.cancel();
|
|
||||||
super.dispose();
|
super.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -793,7 +775,7 @@ class _WalletNetworkSettingsViewState
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// Stop the Tor service.
|
// Stop the Tor service.
|
||||||
try {
|
try {
|
||||||
await ref.read(pTorService).stop();
|
await ref.read(pTorService).disable();
|
||||||
|
|
||||||
// Toggle the useTor preference on success.
|
// Toggle the useTor preference on success.
|
||||||
ref.read(prefsChangeNotifierProvider).useTor = false;
|
ref.read(prefsChangeNotifierProvider).useTor = false;
|
||||||
|
@ -813,11 +795,12 @@ class _WalletNetworkSettingsViewState
|
||||||
prefsChangeNotifierProvider.select((value) => value.useTor)))
|
prefsChangeNotifierProvider.select((value) => value.useTor)))
|
||||||
GestureDetector(
|
GestureDetector(
|
||||||
onTap: () async {
|
onTap: () async {
|
||||||
// Init the Tor service if it hasn't already been.
|
|
||||||
ref.read(pTorService).init();
|
|
||||||
|
|
||||||
// Start the Tor service.
|
|
||||||
try {
|
try {
|
||||||
|
// Init the Tor service if it hasn't already been.
|
||||||
|
final torDir =
|
||||||
|
await StackFileSystem.applicationTorDirectory();
|
||||||
|
ref.read(pTorService).init(torDataDirPath: torDir.path);
|
||||||
|
// Start the Tor service.
|
||||||
await ref.read(pTorService).start();
|
await ref.read(pTorService).start();
|
||||||
|
|
||||||
// Toggle the useTor preference on success.
|
// Toggle the useTor preference on success.
|
||||||
|
@ -827,6 +810,7 @@ class _WalletNetworkSettingsViewState
|
||||||
"Error starting tor: $e\n$s",
|
"Error starting tor: $e\n$s",
|
||||||
level: LogLevel.Error,
|
level: LogLevel.Error,
|
||||||
);
|
);
|
||||||
|
// TODO: show dialog with error message
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Text(
|
child: Text(
|
||||||
|
@ -896,35 +880,46 @@ class _WalletNetworkSettingsViewState
|
||||||
SizedBox(
|
SizedBox(
|
||||||
width: _boxPadding,
|
width: _boxPadding,
|
||||||
),
|
),
|
||||||
Column(
|
TorSubscription(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
onTorStatusChanged: (status) {
|
||||||
children: [
|
setState(() {
|
||||||
Text(
|
_torConnectionStatus = status;
|
||||||
"Tor status",
|
});
|
||||||
style: STextStyles.desktopTextExtraExtraSmall(context)
|
},
|
||||||
.copyWith(
|
child: Column(
|
||||||
color: Theme.of(context)
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
.extension<StackColors>()!
|
children: [
|
||||||
.textDark,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (_torConnectionStatus == TorConnectionStatus.connected)
|
|
||||||
Text(
|
Text(
|
||||||
"Connected",
|
"Tor status",
|
||||||
style: STextStyles.desktopTextExtraExtraSmall(context),
|
style: STextStyles.desktopTextExtraExtraSmall(context)
|
||||||
|
.copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.textDark,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
if (_torConnectionStatus == TorConnectionStatus.connecting)
|
if (_torConnectionStatus == TorConnectionStatus.connected)
|
||||||
Text(
|
Text(
|
||||||
"Connecting...",
|
"Connected",
|
||||||
style: STextStyles.desktopTextExtraExtraSmall(context),
|
style:
|
||||||
),
|
STextStyles.desktopTextExtraExtraSmall(context),
|
||||||
if (_torConnectionStatus ==
|
),
|
||||||
TorConnectionStatus.disconnected)
|
if (_torConnectionStatus ==
|
||||||
Text(
|
TorConnectionStatus.connecting)
|
||||||
"Disconnected",
|
Text(
|
||||||
style: STextStyles.desktopTextExtraExtraSmall(context),
|
"Connecting...",
|
||||||
),
|
style:
|
||||||
],
|
STextStyles.desktopTextExtraExtraSmall(context),
|
||||||
|
),
|
||||||
|
if (_torConnectionStatus ==
|
||||||
|
TorConnectionStatus.disconnected)
|
||||||
|
Text(
|
||||||
|
"Disconnected",
|
||||||
|
style:
|
||||||
|
STextStyles.desktopTextExtraExtraSmall(context),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -11,13 +11,15 @@
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
import 'package:flutter_riverpod/flutter_riverpod.dart';
|
||||||
import 'package:stackwallet/pages/buy_view/buy_form.dart';
|
import 'package:stackwallet/pages/buy_view/buy_form.dart';
|
||||||
import 'package:stackwallet/providers/global/prefs_provider.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/themes/stack_colors.dart';
|
import 'package:stackwallet/themes/stack_colors.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
|
||||||
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
|
||||||
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
import 'package:stackwallet/widgets/rounded_white_container.dart';
|
||||||
|
import 'package:stackwallet/widgets/tor_subscription.dart';
|
||||||
|
|
||||||
class DesktopBuyView extends ConsumerStatefulWidget {
|
class DesktopBuyView extends ConsumerStatefulWidget {
|
||||||
const DesktopBuyView({Key? key}) : super(key: key);
|
const DesktopBuyView({Key? key}) : super(key: key);
|
||||||
|
@ -29,117 +31,121 @@ class DesktopBuyView extends ConsumerStatefulWidget {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _DesktopBuyViewState extends ConsumerState<DesktopBuyView> {
|
class _DesktopBuyViewState extends ConsumerState<DesktopBuyView> {
|
||||||
late bool torEnabled = false;
|
late bool torEnabled;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
WidgetsBinding.instance.addPostFrameCallback((_) async {
|
torEnabled =
|
||||||
setState(() {
|
ref.read(pTorService).status != TorConnectionStatus.disconnected;
|
||||||
torEnabled = ref.read(prefsChangeNotifierProvider).useTor;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return Stack(
|
return TorSubscription(
|
||||||
children: [
|
onTorStatusChanged: (status) {
|
||||||
DesktopScaffold(
|
setState(() {
|
||||||
appBar: DesktopAppBar(
|
torEnabled = status != TorConnectionStatus.disconnected;
|
||||||
isCompactHeight: true,
|
});
|
||||||
leading: Padding(
|
},
|
||||||
padding: const EdgeInsets.only(
|
child: Stack(
|
||||||
left: 24,
|
children: [
|
||||||
|
DesktopScaffold(
|
||||||
|
appBar: DesktopAppBar(
|
||||||
|
isCompactHeight: true,
|
||||||
|
leading: Padding(
|
||||||
|
padding: const EdgeInsets.only(
|
||||||
|
left: 24,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
"Buy crypto",
|
||||||
|
style: STextStyles.desktopH3(context),
|
||||||
|
),
|
||||||
),
|
),
|
||||||
child: Text(
|
),
|
||||||
"Buy crypto",
|
body: const Padding(
|
||||||
style: STextStyles.desktopH3(context),
|
padding: EdgeInsets.only(
|
||||||
|
left: 24,
|
||||||
|
right: 24,
|
||||||
|
bottom: 24,
|
||||||
|
),
|
||||||
|
child: Row(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Expanded(
|
||||||
|
child: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min,
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
SizedBox(
|
||||||
|
height: 16,
|
||||||
|
),
|
||||||
|
RoundedWhiteContainer(
|
||||||
|
padding: EdgeInsets.all(24),
|
||||||
|
child: BuyForm(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
SizedBox(
|
||||||
|
width: 16,
|
||||||
|
),
|
||||||
|
// Expanded(
|
||||||
|
// child: Row(
|
||||||
|
// children: const [
|
||||||
|
// Expanded(
|
||||||
|
// child: DesktopTradeHistory(),
|
||||||
|
// ),
|
||||||
|
// ],
|
||||||
|
// ),
|
||||||
|
// ),
|
||||||
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
body: Padding(
|
if (torEnabled)
|
||||||
padding: const EdgeInsets.only(
|
Container(
|
||||||
left: 24,
|
color: Theme.of(context)
|
||||||
right: 24,
|
.extension<StackColors>()!
|
||||||
bottom: 24,
|
.overlay
|
||||||
),
|
.withOpacity(0.7),
|
||||||
child: Row(
|
height: MediaQuery.of(context).size.height,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
width: MediaQuery.of(context).size.width,
|
||||||
children: [
|
child: DesktopDialog(
|
||||||
Expanded(
|
maxHeight: 200,
|
||||||
|
maxWidth: 350,
|
||||||
|
child: Padding(
|
||||||
|
padding: const EdgeInsets.all(
|
||||||
|
15.0,
|
||||||
|
),
|
||||||
child: Column(
|
child: Column(
|
||||||
mainAxisSize: MainAxisSize.min,
|
// crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
// mainAxisAlignment: MainAxisAlignment.center,
|
||||||
children: const [
|
children: [
|
||||||
SizedBox(
|
Text(
|
||||||
height: 16,
|
"Tor is enabled",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: STextStyles.pageTitleH1(context),
|
||||||
),
|
),
|
||||||
RoundedWhiteContainer(
|
const SizedBox(
|
||||||
padding: EdgeInsets.all(24),
|
height: 30,
|
||||||
child: BuyForm(),
|
),
|
||||||
|
Text(
|
||||||
|
"Purchasing not available while Tor is enabled",
|
||||||
|
textAlign: TextAlign.center,
|
||||||
|
style: STextStyles.desktopTextMedium(context).copyWith(
|
||||||
|
color: Theme.of(context)
|
||||||
|
.extension<StackColors>()!
|
||||||
|
.infoItemLabel,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(
|
|
||||||
width: 16,
|
|
||||||
),
|
|
||||||
// Expanded(
|
|
||||||
// child: Row(
|
|
||||||
// children: const [
|
|
||||||
// Expanded(
|
|
||||||
// child: DesktopTradeHistory(),
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// ),
|
|
||||||
// ),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
),
|
|
||||||
if (torEnabled)
|
|
||||||
Container(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.extension<StackColors>()!
|
|
||||||
.overlay
|
|
||||||
.withOpacity(0.7),
|
|
||||||
height: MediaQuery.of(context).size.height,
|
|
||||||
width: MediaQuery.of(context).size.width,
|
|
||||||
child: DesktopDialog(
|
|
||||||
maxHeight: 200,
|
|
||||||
maxWidth: 350,
|
|
||||||
child: Padding(
|
|
||||||
padding: const EdgeInsets.all(
|
|
||||||
15.0,
|
|
||||||
),
|
|
||||||
child: Column(
|
|
||||||
// crossAxisAlignment: CrossAxisAlignment.center,
|
|
||||||
// mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: [
|
|
||||||
Text(
|
|
||||||
"Tor is enabled",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: STextStyles.pageTitleH1(context),
|
|
||||||
),
|
|
||||||
const SizedBox(
|
|
||||||
height: 30,
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
"Purchasing not available while Tor is enabled",
|
|
||||||
textAlign: TextAlign.center,
|
|
||||||
style: STextStyles.desktopTextMedium(context).copyWith(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.extension<StackColors>()!
|
|
||||||
.infoItemLabel,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
),
|
],
|
||||||
],
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,8 +56,9 @@ class _DesktopOrdinalDetailsViewState
|
||||||
|
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: Uri.parse(widget.ordinal.content),
|
url: Uri.parse(widget.ordinal.content),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code != 200) {
|
if (response.code != 200) {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import 'package:stackwallet/services/tor_service.dart';
|
||||||
import 'package:stackwallet/themes/stack_colors.dart';
|
import 'package:stackwallet/themes/stack_colors.dart';
|
||||||
import 'package:stackwallet/utilities/assets.dart';
|
import 'package:stackwallet/utilities/assets.dart';
|
||||||
import 'package:stackwallet/utilities/logger.dart';
|
import 'package:stackwallet/utilities/logger.dart';
|
||||||
|
import 'package:stackwallet/utilities/stack_file_system.dart';
|
||||||
import 'package:stackwallet/utilities/text_styles.dart';
|
import 'package:stackwallet/utilities/text_styles.dart';
|
||||||
import 'package:stackwallet/utilities/util.dart';
|
import 'package:stackwallet/utilities/util.dart';
|
||||||
import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart';
|
import 'package:stackwallet/widgets/custom_buttons/draggable_switch_button.dart';
|
||||||
|
@ -59,11 +60,11 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
||||||
width: 200,
|
width: 200,
|
||||||
buttonHeight: ButtonHeight.m,
|
buttonHeight: ButtonHeight.m,
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
// Init the Tor service if it hasn't already been.
|
|
||||||
ref.read(pTorService).init();
|
|
||||||
|
|
||||||
// Start the Tor service.
|
|
||||||
try {
|
try {
|
||||||
|
// Init the Tor service if it hasn't already been.
|
||||||
|
final torDir = await StackFileSystem.applicationTorDirectory();
|
||||||
|
ref.read(pTorService).init(torDataDirPath: torDir.path);
|
||||||
|
// Start the Tor service.
|
||||||
await ref.read(pTorService).start();
|
await ref.read(pTorService).start();
|
||||||
|
|
||||||
// Toggle the useTor preference on success.
|
// Toggle the useTor preference on success.
|
||||||
|
@ -73,6 +74,7 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
||||||
"Error starting tor: $e\n$s",
|
"Error starting tor: $e\n$s",
|
||||||
level: LogLevel.Error,
|
level: LogLevel.Error,
|
||||||
);
|
);
|
||||||
|
// TODO: show dialog with error message
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
@ -93,7 +95,7 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
||||||
onPressed: () async {
|
onPressed: () async {
|
||||||
// Stop the Tor service.
|
// Stop the Tor service.
|
||||||
try {
|
try {
|
||||||
await ref.read(pTorService).stop();
|
await ref.read(pTorService).disable();
|
||||||
|
|
||||||
// Toggle the useTor preference on success.
|
// Toggle the useTor preference on success.
|
||||||
ref.read(prefsChangeNotifierProvider).useTor = false;
|
ref.read(prefsChangeNotifierProvider).useTor = false;
|
||||||
|
@ -114,9 +116,7 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
||||||
eventBus = GlobalEventBus.instance;
|
eventBus = GlobalEventBus.instance;
|
||||||
|
|
||||||
// Set the initial Tor connection status.
|
// Set the initial Tor connection status.
|
||||||
_torConnectionStatus = ref.read(pTorService).enabled
|
_torConnectionStatus = ref.read(pTorService).status;
|
||||||
? TorConnectionStatus.connected
|
|
||||||
: TorConnectionStatus.disconnected;
|
|
||||||
|
|
||||||
// Subscribe to the TorConnectionStatusChangedEvent.
|
// Subscribe to the TorConnectionStatusChangedEvent.
|
||||||
_torConnectionStatusSubscription =
|
_torConnectionStatusSubscription =
|
||||||
|
@ -219,8 +219,21 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.end,
|
MainAxisAlignment
|
||||||
|
.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.only(
|
||||||
|
left: 32,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
"What is Tor?",
|
||||||
|
style:
|
||||||
|
STextStyles.desktopH2(
|
||||||
|
context),
|
||||||
|
),
|
||||||
|
),
|
||||||
DesktopDialogCloseButton(
|
DesktopDialogCloseButton(
|
||||||
onPressedOverride: () =>
|
onPressedOverride: () =>
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
|
@ -229,34 +242,24 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding: const EdgeInsets.all(20),
|
padding: const EdgeInsets.only(
|
||||||
child: Column(
|
top: 12,
|
||||||
mainAxisSize: MainAxisSize.max,
|
left: 32,
|
||||||
children: [
|
bottom: 32,
|
||||||
Text(
|
right: 32,
|
||||||
"What is Tor?",
|
),
|
||||||
style:
|
child: Text(
|
||||||
STextStyles.desktopH2(
|
"Short for \"The Onion Router\", is an open-source software that enables internet communication"
|
||||||
context),
|
" to remain anonymous by routing internet traffic through a series of layered nodes,"
|
||||||
),
|
" to obscure the origin and destination of data.",
|
||||||
const SizedBox(
|
style: STextStyles
|
||||||
height: 20,
|
.desktopTextMedium(
|
||||||
),
|
context)
|
||||||
Text(
|
.copyWith(
|
||||||
"Short for \"The Onion Router\", is an open-source software that enables internet communication"
|
color: Theme.of(context)
|
||||||
" to remain anonymous by routing internet traffic through a series of layered nodes,"
|
.extension<StackColors>()!
|
||||||
" to obscure the origin and destination of data.",
|
.textDark3,
|
||||||
style: STextStyles
|
),
|
||||||
.desktopTextMedium(
|
|
||||||
context)
|
|
||||||
.copyWith(
|
|
||||||
color: Theme.of(context)
|
|
||||||
.extension<
|
|
||||||
StackColors>()!
|
|
||||||
.textDark3,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -289,21 +292,25 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
children: [
|
children: [
|
||||||
RichText(
|
Column(
|
||||||
textAlign: TextAlign.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
text: TextSpan(
|
children: [
|
||||||
children: [
|
Text(
|
||||||
TextSpan(
|
"Tor killswitch",
|
||||||
text: "Tor killswitch",
|
style: STextStyles.desktopTextExtraExtraSmall(
|
||||||
style: STextStyles.desktopTextExtraExtraSmall(
|
context)
|
||||||
context)
|
.copyWith(
|
||||||
.copyWith(
|
color: Theme.of(context)
|
||||||
color: Theme.of(context)
|
.extension<StackColors>()!
|
||||||
.extension<StackColors>()!
|
.textDark),
|
||||||
.textDark),
|
),
|
||||||
),
|
const SizedBox(
|
||||||
TextSpan(
|
height: 8,
|
||||||
text: "\nWhat is Tor killswitch?",
|
),
|
||||||
|
RichText(
|
||||||
|
textAlign: TextAlign.start,
|
||||||
|
text: TextSpan(
|
||||||
|
text: "What is Tor killswitch?",
|
||||||
style: STextStyles.richLink(context).copyWith(
|
style: STextStyles.richLink(context).copyWith(
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
),
|
),
|
||||||
|
@ -321,8 +328,20 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
||||||
children: [
|
children: [
|
||||||
Row(
|
Row(
|
||||||
mainAxisAlignment:
|
mainAxisAlignment:
|
||||||
MainAxisAlignment.end,
|
MainAxisAlignment
|
||||||
|
.spaceBetween,
|
||||||
children: [
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding:
|
||||||
|
const EdgeInsets.only(
|
||||||
|
left: 32,
|
||||||
|
),
|
||||||
|
child: Text(
|
||||||
|
"What is Tor killswitch?",
|
||||||
|
style: STextStyles
|
||||||
|
.desktopH2(context),
|
||||||
|
),
|
||||||
|
),
|
||||||
DesktopDialogCloseButton(
|
DesktopDialogCloseButton(
|
||||||
onPressedOverride: () =>
|
onPressedOverride: () =>
|
||||||
Navigator.of(context)
|
Navigator.of(context)
|
||||||
|
@ -332,35 +351,25 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
||||||
),
|
),
|
||||||
Padding(
|
Padding(
|
||||||
padding:
|
padding:
|
||||||
const EdgeInsets.all(20),
|
const EdgeInsets.only(
|
||||||
child: Column(
|
top: 12,
|
||||||
mainAxisSize:
|
left: 32,
|
||||||
MainAxisSize.max,
|
bottom: 32,
|
||||||
children: [
|
right: 32,
|
||||||
Text(
|
),
|
||||||
"What is Tor killswitch?",
|
child: Text(
|
||||||
style: STextStyles
|
"A security feature that protects your information from accidental exposure by"
|
||||||
.desktopH2(context),
|
" disconnecting your device from the Tor network if the"
|
||||||
),
|
" connection is disrupted or compromised.",
|
||||||
const SizedBox(
|
style: STextStyles
|
||||||
height: 20,
|
.desktopTextMedium(
|
||||||
),
|
context)
|
||||||
Text(
|
.copyWith(
|
||||||
"A security feature that protects your information from accidental exposure by"
|
color: Theme.of(context)
|
||||||
" disconnecting your device from the Tor network if the"
|
.extension<
|
||||||
" connection is disrupted or compromised.",
|
StackColors>()!
|
||||||
style: STextStyles
|
.textDark3,
|
||||||
.desktopTextMedium(
|
),
|
||||||
context)
|
|
||||||
.copyWith(
|
|
||||||
color: Theme.of(
|
|
||||||
context)
|
|
||||||
.extension<
|
|
||||||
StackColors>()!
|
|
||||||
.textDark3,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
@ -370,8 +379,8 @@ class _TorSettingsState extends ConsumerState<TorSettings> {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
],
|
),
|
||||||
),
|
],
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
|
|
|
@ -59,7 +59,7 @@ class SimplexAPI {
|
||||||
url: url,
|
url: url,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
Prefs.instance.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
if (res.code != 200) {
|
if (res.code != 200) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
|
@ -125,7 +125,7 @@ class SimplexAPI {
|
||||||
url: url,
|
url: url,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
Prefs.instance.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
if (res.code != 200) {
|
if (res.code != 200) {
|
||||||
throw Exception(
|
throw Exception(
|
||||||
|
@ -206,7 +206,7 @@ class SimplexAPI {
|
||||||
url: url,
|
url: url,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
Prefs.instance.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
if (res.code != 200) {
|
if (res.code != 200) {
|
||||||
throw Exception('getQuote exception: statusCode= ${res.code}');
|
throw Exception('getQuote exception: statusCode= ${res.code}');
|
||||||
|
@ -313,7 +313,7 @@ class SimplexAPI {
|
||||||
url: url,
|
url: url,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
Prefs.instance.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
if (res.code != 200) {
|
if (res.code != 200) {
|
||||||
throw Exception('newOrder exception: statusCode= ${res.code}');
|
throw Exception('newOrder exception: statusCode= ${res.code}');
|
||||||
|
|
|
@ -160,7 +160,7 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
)
|
)
|
||||||
.then((client) {
|
.then((client) {
|
||||||
if (client.code == 200) {
|
if (client.code == 200) {
|
||||||
|
@ -195,7 +195,7 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: balanceBody,
|
body: balanceBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
final balanceData = jsonDecode(balanceResponse.body);
|
final balanceData = jsonDecode(balanceResponse.body);
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: infoBody,
|
body: infoBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final String frontier =
|
final String frontier =
|
||||||
|
@ -270,7 +270,7 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: processBody,
|
body: processBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final Map<String, dynamic> decoded =
|
final Map<String, dynamic> decoded =
|
||||||
|
@ -344,7 +344,7 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: body,
|
body: body,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
final data = jsonDecode(response.body);
|
final data = jsonDecode(response.body);
|
||||||
_balance = Balance(
|
_balance = Balance(
|
||||||
|
@ -388,7 +388,7 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: infoBody,
|
body: infoBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
final infoData = jsonDecode(infoResponse.body);
|
final infoData = jsonDecode(infoResponse.body);
|
||||||
|
|
||||||
|
@ -408,7 +408,7 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: balanceBody,
|
body: balanceBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final balanceData = jsonDecode(balanceResponse.body);
|
final balanceData = jsonDecode(balanceResponse.body);
|
||||||
|
@ -483,7 +483,7 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: processBody,
|
body: processBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final Map<String, dynamic> decoded =
|
final Map<String, dynamic> decoded =
|
||||||
|
@ -504,7 +504,7 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
"count": "-1",
|
"count": "-1",
|
||||||
}),
|
}),
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final receivableData = await jsonDecode(receivableResponse.body);
|
final receivableData = await jsonDecode(receivableResponse.body);
|
||||||
|
@ -536,7 +536,7 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
"count": "-1",
|
"count": "-1",
|
||||||
}),
|
}),
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
final data = await jsonDecode(response.body);
|
final data = await jsonDecode(response.body);
|
||||||
final transactions =
|
final transactions =
|
||||||
|
@ -858,7 +858,7 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
return response.code == 200;
|
return response.code == 200;
|
||||||
|
@ -952,7 +952,7 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: infoBody,
|
body: infoBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
final infoData = jsonDecode(infoResponse.body);
|
final infoData = jsonDecode(infoResponse.body);
|
||||||
|
|
||||||
|
|
|
@ -169,7 +169,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
)
|
)
|
||||||
.then((Response response) {
|
.then((Response response) {
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
|
@ -204,7 +204,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: balanceBody,
|
body: balanceBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
final balanceData = jsonDecode(balanceResponse.body);
|
final balanceData = jsonDecode(balanceResponse.body);
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: infoBody,
|
body: infoBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final String frontier =
|
final String frontier =
|
||||||
|
@ -279,7 +279,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: processBody,
|
body: processBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final Map<String, dynamic> decoded =
|
final Map<String, dynamic> decoded =
|
||||||
|
@ -349,7 +349,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: body,
|
body: body,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
final data = jsonDecode(response.body);
|
final data = jsonDecode(response.body);
|
||||||
_balance = Balance(
|
_balance = Balance(
|
||||||
|
@ -393,7 +393,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: infoBody,
|
body: infoBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
final infoData = jsonDecode(infoResponse.body);
|
final infoData = jsonDecode(infoResponse.body);
|
||||||
|
|
||||||
|
@ -413,7 +413,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: balanceBody,
|
body: balanceBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final balanceData = jsonDecode(balanceResponse.body);
|
final balanceData = jsonDecode(balanceResponse.body);
|
||||||
|
@ -488,7 +488,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: processBody,
|
body: processBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final Map<String, dynamic> decoded =
|
final Map<String, dynamic> decoded =
|
||||||
|
@ -509,7 +509,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
"count": "-1",
|
"count": "-1",
|
||||||
}),
|
}),
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final receivableData = await jsonDecode(receivableResponse.body);
|
final receivableData = await jsonDecode(receivableResponse.body);
|
||||||
|
@ -541,7 +541,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
"count": "-1",
|
"count": "-1",
|
||||||
}),
|
}),
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
final data = await jsonDecode(response.body);
|
final data = await jsonDecode(response.body);
|
||||||
final transactions =
|
final transactions =
|
||||||
|
@ -869,7 +869,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
|
|
||||||
return response.code == 200;
|
return response.code == 200;
|
||||||
|
@ -963,7 +963,7 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: infoBody,
|
body: infoBody,
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
final infoData = jsonDecode(infoResponse.body);
|
final infoData = jsonDecode(infoResponse.body);
|
||||||
|
|
||||||
|
|
|
@ -245,7 +245,7 @@ class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
var response = jsonDecode((await client.get(
|
var response = jsonDecode((await client.get(
|
||||||
url: Uri.parse(api),
|
url: Uri.parse(api),
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
))
|
))
|
||||||
.body)[0];
|
.body)[0];
|
||||||
double totalFees = response[4] as double;
|
double totalFees = response[4] as double;
|
||||||
|
@ -270,7 +270,7 @@ class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
var response = jsonDecode((await client.get(
|
var response = jsonDecode((await client.get(
|
||||||
url: Uri.parse(api),
|
url: Uri.parse(api),
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
))
|
))
|
||||||
.body);
|
.body);
|
||||||
double totalFees = response[0][4] as double;
|
double totalFees = response[0][4] as double;
|
||||||
|
@ -509,9 +509,8 @@ class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
var response = jsonDecode(await client
|
var response = jsonDecode(await client
|
||||||
.get(
|
.get(
|
||||||
url: Uri.parse(balanceCall),
|
url: Uri.parse(balanceCall),
|
||||||
proxyInfo: Prefs.instance.useTor
|
proxyInfo:
|
||||||
? TorService.sharedInstance.proxyInfo
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
: null,
|
|
||||||
)
|
)
|
||||||
.then((value) => value.body));
|
.then((value) => value.body));
|
||||||
Amount balanceInAmount = Amount(
|
Amount balanceInAmount = Amount(
|
||||||
|
@ -538,9 +537,8 @@ class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
var response = jsonDecode(await client
|
var response = jsonDecode(await client
|
||||||
.get(
|
.get(
|
||||||
url: Uri.parse(transactionsCall),
|
url: Uri.parse(transactionsCall),
|
||||||
proxyInfo: Prefs.instance.useTor
|
proxyInfo:
|
||||||
? TorService.sharedInstance.proxyInfo
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
: null,
|
|
||||||
)
|
)
|
||||||
.then((value) => value.body));
|
.then((value) => value.body));
|
||||||
List<Tuple2<Transaction, Address>> txs = [];
|
List<Tuple2<Transaction, Address>> txs = [];
|
||||||
|
@ -619,9 +617,8 @@ class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
var jsonParsedResponse = jsonDecode(await client
|
var jsonParsedResponse = jsonDecode(await client
|
||||||
.get(
|
.get(
|
||||||
url: Uri.parse(api),
|
url: Uri.parse(api),
|
||||||
proxyInfo: Prefs.instance.useTor
|
proxyInfo:
|
||||||
? TorService.sharedInstance.proxyInfo
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
: null,
|
|
||||||
)
|
)
|
||||||
.then((value) => value.body));
|
.then((value) => value.body));
|
||||||
final int intHeight = int.parse(jsonParsedResponse["level"].toString());
|
final int intHeight = int.parse(jsonParsedResponse["level"].toString());
|
||||||
|
@ -707,7 +704,7 @@ class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB {
|
||||||
url: Uri.parse(
|
url: Uri.parse(
|
||||||
"${getCurrentNode().host}:${getCurrentNode().port}/chains/main/blocks/head/header/shell"),
|
"${getCurrentNode().host}:${getCurrentNode().port}/chains/main/blocks/head/header/shell"),
|
||||||
proxyInfo:
|
proxyInfo:
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
_prefs.useTor ? TorService.sharedInstance.getProxyInfo() : null,
|
||||||
);
|
);
|
||||||
return true;
|
return true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
|
@ -61,8 +61,9 @@ abstract class EthereumAPI {
|
||||||
url: Uri.parse(
|
url: Uri.parse(
|
||||||
"$stackBaseServer/export?addrs=$address&firstBlock=$firstBlock",
|
"$stackBaseServer/export?addrs=$address&firstBlock=$firstBlock",
|
||||||
),
|
),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
|
@ -184,8 +185,9 @@ abstract class EthereumAPI {
|
||||||
url: Uri.parse(
|
url: Uri.parse(
|
||||||
"$stackBaseServer/transactions?transactions=${txns.map((e) => e.hash).join(" ")}&raw=true",
|
"$stackBaseServer/transactions?transactions=${txns.map((e) => e.hash).join(" ")}&raw=true",
|
||||||
),
|
),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
|
@ -244,8 +246,9 @@ abstract class EthereumAPI {
|
||||||
url: Uri.parse(
|
url: Uri.parse(
|
||||||
"$stackBaseServer/transactions?transactions=${txids.join(" ")}",
|
"$stackBaseServer/transactions?transactions=${txids.join(" ")}",
|
||||||
),
|
),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
|
@ -303,8 +306,9 @@ abstract class EthereumAPI {
|
||||||
url: Uri.parse(
|
url: Uri.parse(
|
||||||
"$stackBaseServer/export?addrs=$address&emitter=$tokenContractAddress&logs=true",
|
"$stackBaseServer/export?addrs=$address&emitter=$tokenContractAddress&logs=true",
|
||||||
),
|
),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
|
@ -437,8 +441,9 @@ abstract class EthereumAPI {
|
||||||
);
|
);
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
|
@ -488,8 +493,9 @@ abstract class EthereumAPI {
|
||||||
);
|
);
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
|
@ -535,8 +541,9 @@ abstract class EthereumAPI {
|
||||||
url: Uri.parse(
|
url: Uri.parse(
|
||||||
"$stackBaseServer/gas-prices",
|
"$stackBaseServer/gas-prices",
|
||||||
),
|
),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
|
@ -606,8 +613,9 @@ abstract class EthereumAPI {
|
||||||
url: Uri.parse(
|
url: Uri.parse(
|
||||||
"$stackBaseServer/tokens?addrs=$contractAddress&parts=all",
|
"$stackBaseServer/tokens?addrs=$contractAddress&parts=all",
|
||||||
),
|
),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
|
@ -675,8 +683,9 @@ abstract class EthereumAPI {
|
||||||
url: Uri.parse(
|
url: Uri.parse(
|
||||||
"$stackBaseServer/abis?addrs=$contractAddress&verbose=true",
|
"$stackBaseServer/abis?addrs=$contractAddress&verbose=true",
|
||||||
),
|
),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
|
@ -717,8 +726,9 @@ abstract class EthereumAPI {
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: Uri.parse(
|
url: Uri.parse(
|
||||||
"$stackBaseServer/state?addrs=$contractAddress&parts=proxy"),
|
"$stackBaseServer/state?addrs=$contractAddress&parts=proxy"),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
final json = jsonDecode(response.body);
|
final json = jsonDecode(response.body);
|
||||||
|
|
|
@ -60,8 +60,9 @@ class ChangeNowAPI {
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
String? data;
|
String? data;
|
||||||
try {
|
try {
|
||||||
|
@ -90,8 +91,9 @@ class ChangeNowAPI {
|
||||||
// 'Content-Type': 'application/json',
|
// 'Content-Type': 'application/json',
|
||||||
'x-changenow-api-key': apiKey,
|
'x-changenow-api-key': apiKey,
|
||||||
},
|
},
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final data = response.body;
|
final data = response.body;
|
||||||
|
@ -114,8 +116,9 @@ class ChangeNowAPI {
|
||||||
url: uri,
|
url: uri,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: jsonEncode(body),
|
body: jsonEncode(body),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
String? data;
|
String? data;
|
||||||
|
|
|
@ -49,8 +49,9 @@ class MajesticBankAPI {
|
||||||
try {
|
try {
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
code = response.code;
|
code = response.code;
|
||||||
|
|
|
@ -47,8 +47,9 @@ class SimpleSwapAPI {
|
||||||
try {
|
try {
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
code = response.code;
|
code = response.code;
|
||||||
|
@ -74,8 +75,9 @@ class SimpleSwapAPI {
|
||||||
url: uri,
|
url: uri,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
body: jsonEncode(body),
|
body: jsonEncode(body),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
|
|
|
@ -52,8 +52,9 @@ abstract class TrocadorAPI {
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
code = response.code;
|
code = response.code;
|
||||||
|
|
|
@ -22,8 +22,9 @@ class LitescribeAPI {
|
||||||
Future<LitescribeResponse> _getResponse(String endpoint) async {
|
Future<LitescribeResponse> _getResponse(String endpoint) async {
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: Uri.parse('$baseUrl$endpoint'),
|
url: Uri.parse('$baseUrl$endpoint'),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
return LitescribeResponse(data: _validateJson(response.body));
|
return LitescribeResponse(data: _validateJson(response.body));
|
||||||
|
|
|
@ -25,8 +25,9 @@ class MonKeyService {
|
||||||
|
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: Uri.parse(url),
|
url: Uri.parse(url),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (response.code == 200) {
|
if (response.code == 200) {
|
||||||
|
|
|
@ -31,8 +31,9 @@ class NanoAPI {
|
||||||
"representative": "true",
|
"representative": "true",
|
||||||
"account": account,
|
"account": account,
|
||||||
}),
|
}),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final map = jsonDecode(response.body);
|
final map = jsonDecode(response.body);
|
||||||
|
@ -124,8 +125,9 @@ class NanoAPI {
|
||||||
"subtype": "change",
|
"subtype": "change",
|
||||||
"block": block,
|
"block": block,
|
||||||
}),
|
}),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
return jsonDecode(response.body);
|
return jsonDecode(response.body);
|
||||||
|
|
|
@ -107,8 +107,9 @@ class PriceAPI {
|
||||||
final coinGeckoResponse = await client.get(
|
final coinGeckoResponse = await client.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final coinGeckoData = jsonDecode(coinGeckoResponse.body) as List<dynamic>;
|
final coinGeckoData = jsonDecode(coinGeckoResponse.body) as List<dynamic>;
|
||||||
|
@ -154,8 +155,9 @@ class PriceAPI {
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final json = jsonDecode(response.body) as List<dynamic>;
|
final json = jsonDecode(response.body) as List<dynamic>;
|
||||||
|
@ -195,8 +197,9 @@ class PriceAPI {
|
||||||
final coinGeckoResponse = await client.get(
|
final coinGeckoResponse = await client.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final coinGeckoData = jsonDecode(coinGeckoResponse.body) as Map;
|
final coinGeckoData = jsonDecode(coinGeckoResponse.body) as Map;
|
||||||
|
|
|
@ -10,33 +10,45 @@ final pTorService = Provider((_) => TorService.sharedInstance);
|
||||||
|
|
||||||
class TorService {
|
class TorService {
|
||||||
Tor? _tor;
|
Tor? _tor;
|
||||||
|
String? _torDataDirPath;
|
||||||
|
|
||||||
/// Flag to indicate that a Tor circuit is thought to have been established.
|
/// Current status. Same as that fired on the event bus
|
||||||
bool _enabled = false;
|
TorConnectionStatus get status => _status;
|
||||||
|
TorConnectionStatus _status = TorConnectionStatus.disconnected;
|
||||||
/// Getter for the enabled flag.
|
|
||||||
bool get enabled => _enabled;
|
|
||||||
|
|
||||||
TorService._();
|
|
||||||
|
|
||||||
/// Singleton instance of the TorService.
|
/// Singleton instance of the TorService.
|
||||||
///
|
///
|
||||||
/// Use this to access the TorService and its properties.
|
/// Use this to access the TorService and its properties.
|
||||||
static final sharedInstance = TorService._();
|
static final sharedInstance = TorService._();
|
||||||
|
|
||||||
|
// private constructor for singleton
|
||||||
|
TorService._();
|
||||||
|
|
||||||
/// Getter for the proxyInfo.
|
/// Getter for the proxyInfo.
|
||||||
|
///
|
||||||
|
/// Returns null if disabled on the stack wallet level.
|
||||||
({
|
({
|
||||||
InternetAddress host,
|
InternetAddress host,
|
||||||
int port,
|
int port,
|
||||||
}) get proxyInfo => (
|
}) getProxyInfo() {
|
||||||
|
if (status == TorConnectionStatus.connected) {
|
||||||
|
return (
|
||||||
host: InternetAddress.loopbackIPv4,
|
host: InternetAddress.loopbackIPv4,
|
||||||
port: _tor!.port,
|
port: _tor!.port,
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
throw Exception("Tor proxy info fetched while not connected!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// Initialize the tor ffi lib instance if it hasn't already been set. Nothing
|
/// Initialize the tor ffi lib instance if it hasn't already been set. Nothing
|
||||||
/// changes if _tor is already been set.
|
/// changes if _tor is already been set.
|
||||||
void init({Tor? mockableOverride}) {
|
void init({
|
||||||
|
required String torDataDirPath,
|
||||||
|
Tor? mockableOverride,
|
||||||
|
}) {
|
||||||
_tor ??= mockableOverride ?? Tor.instance;
|
_tor ??= mockableOverride ?? Tor.instance;
|
||||||
|
_torDataDirPath ??= torDataDirPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Start the Tor service.
|
/// Start the Tor service.
|
||||||
|
@ -47,46 +59,25 @@ class TorService {
|
||||||
///
|
///
|
||||||
/// Returns a Future that completes when the Tor service has started.
|
/// Returns a Future that completes when the Tor service has started.
|
||||||
Future<void> start() async {
|
Future<void> start() async {
|
||||||
if (_tor == null) {
|
if (_tor == null || _torDataDirPath == null) {
|
||||||
throw Exception("TorService.init has not been called!");
|
throw Exception("TorService.init has not been called!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_enabled) {
|
|
||||||
// already started so just return
|
|
||||||
// could throw an exception here or something so the caller
|
|
||||||
// is explicitly made aware of this
|
|
||||||
// TODO restart tor after that's been added to the tor-ffi crate
|
|
||||||
// (probably better to have a restart function separately)
|
|
||||||
|
|
||||||
// Fire a TorConnectionStatusChangedEvent on the event bus.
|
|
||||||
GlobalEventBus.instance.fire(
|
|
||||||
TorConnectionStatusChangedEvent(
|
|
||||||
TorConnectionStatus.connected,
|
|
||||||
"Tor connection status changed: connect ($_enabled)",
|
|
||||||
),
|
|
||||||
);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the Tor service.
|
// Start the Tor service.
|
||||||
try {
|
try {
|
||||||
GlobalEventBus.instance.fire(
|
_updateStatusAndFireEvent(
|
||||||
TorConnectionStatusChangedEvent(
|
status: TorConnectionStatus.connecting,
|
||||||
TorConnectionStatus.connecting,
|
message: "TorService.start call in progress",
|
||||||
"Tor connection status changed: connecting",
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
await _tor!.start();
|
|
||||||
|
await _tor!.start(torDataDirPath: _torDataDirPath!);
|
||||||
|
|
||||||
// no exception or error so we can (probably?) assume tor
|
// no exception or error so we can (probably?) assume tor
|
||||||
// has started successfully
|
// has started successfully
|
||||||
_enabled = true;
|
|
||||||
|
|
||||||
// Fire a TorConnectionStatusChangedEvent on the event bus.
|
// Fire a TorConnectionStatusChangedEvent on the event bus.
|
||||||
GlobalEventBus.instance.fire(
|
_updateStatusAndFireEvent(
|
||||||
TorConnectionStatusChangedEvent(
|
status: TorConnectionStatus.connected,
|
||||||
TorConnectionStatus.connected,
|
message: "TorService.start call success",
|
||||||
"Tor connection status changed: connect ($_enabled)",
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
} catch (e, s) {
|
} catch (e, s) {
|
||||||
Logging.instance.log(
|
Logging.instance.log(
|
||||||
|
@ -96,47 +87,41 @@ class TorService {
|
||||||
// _enabled should already be false
|
// _enabled should already be false
|
||||||
|
|
||||||
// Fire a TorConnectionStatusChangedEvent on the event bus.
|
// Fire a TorConnectionStatusChangedEvent on the event bus.
|
||||||
GlobalEventBus.instance.fire(
|
_updateStatusAndFireEvent(
|
||||||
TorConnectionStatusChangedEvent(
|
status: TorConnectionStatus.disconnected,
|
||||||
TorConnectionStatus.disconnected,
|
message: "TorService.start call failed",
|
||||||
"Tor connection status changed: $_enabled (failed)",
|
|
||||||
),
|
|
||||||
);
|
);
|
||||||
rethrow;
|
rethrow;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> stop() async {
|
/// disable tor
|
||||||
|
Future<void> disable() async {
|
||||||
if (_tor == null) {
|
if (_tor == null) {
|
||||||
throw Exception("TorService.init has not been called!");
|
throw Exception("TorService.init has not been called!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_enabled) {
|
// no need to update status and fire event if status won't change
|
||||||
// already stopped so just return
|
if (_status == TorConnectionStatus.disconnected) {
|
||||||
// could throw an exception here or something so the caller
|
|
||||||
// is explicitly made aware of this
|
|
||||||
// TODO make sure to kill
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stop the Tor service.
|
_updateStatusAndFireEvent(
|
||||||
try {
|
status: TorConnectionStatus.disconnected,
|
||||||
_tor!.disable();
|
message: "TorService.disable call success",
|
||||||
// no exception or error so we can (probably?) assume tor
|
);
|
||||||
// has started successfully
|
}
|
||||||
_enabled = false;
|
|
||||||
GlobalEventBus.instance.fire(
|
void _updateStatusAndFireEvent({
|
||||||
TorConnectionStatusChangedEvent(
|
required TorConnectionStatus status,
|
||||||
TorConnectionStatus.disconnected,
|
required String message,
|
||||||
"Tor connection status changed: $_enabled (disabled)",
|
}) {
|
||||||
),
|
_status = status;
|
||||||
);
|
GlobalEventBus.instance.fire(
|
||||||
} catch (e, s) {
|
TorConnectionStatusChangedEvent(
|
||||||
Logging.instance.log(
|
_status,
|
||||||
"TorService.stop failed: $e\n$s",
|
message,
|
||||||
level: LogLevel.Warning,
|
),
|
||||||
);
|
);
|
||||||
rethrow;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,8 +213,9 @@ class ThemeService {
|
||||||
try {
|
try {
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: Uri.parse("$baseServerUrl/themes"),
|
url: Uri.parse("$baseServerUrl/themes"),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final jsonList = jsonDecode(response.body) as List;
|
final jsonList = jsonDecode(response.body) as List;
|
||||||
|
@ -240,8 +241,9 @@ class ThemeService {
|
||||||
try {
|
try {
|
||||||
final response = await client.get(
|
final response = await client.get(
|
||||||
url: Uri.parse("$baseServerUrl/theme/${themeMetaData.id}"),
|
url: Uri.parse("$baseServerUrl/theme/${themeMetaData.id}"),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
final bytes = Uint8List.fromList(response.bodyBytes);
|
final bytes = Uint8List.fromList(response.bodyBytes);
|
||||||
|
|
|
@ -258,4 +258,5 @@ class _ANIMATIONS {
|
||||||
String get iconSend => "assets/lottie/icon_send.json";
|
String get iconSend => "assets/lottie/icon_send.json";
|
||||||
String get loaderAndCheckmark => "assets/lottie/loader_and_checkmark.json";
|
String get loaderAndCheckmark => "assets/lottie/loader_and_checkmark.json";
|
||||||
String get arrowRotate => "assets/lottie/arrow_rotate.json";
|
String get arrowRotate => "assets/lottie/arrow_rotate.json";
|
||||||
|
String get onionTor => "assets/lottie/onion_animation.json";
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,8 +52,9 @@ class PaynymIsApi {
|
||||||
url: uri,
|
url: uri,
|
||||||
headers: headers,
|
headers: headers,
|
||||||
body: jsonEncode(body),
|
body: jsonEncode(body),
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
);
|
);
|
||||||
|
|
||||||
debugPrint("Paynym request uri: $uri");
|
debugPrint("Paynym request uri: $uri");
|
||||||
|
|
|
@ -24,7 +24,7 @@ Future<bool> _testEpicBoxNodeConnection(Uri uri) async {
|
||||||
url: uri,
|
url: uri,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
proxyInfo: Prefs.instance.useTor
|
proxyInfo: Prefs.instance.useTor
|
||||||
? TorService.sharedInstance.proxyInfo
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
: null,
|
: null,
|
||||||
)
|
)
|
||||||
.timeout(const Duration(milliseconds: 2000),
|
.timeout(const Duration(milliseconds: 2000),
|
||||||
|
|
|
@ -13,8 +13,9 @@ Future<bool> testStellarNodeConnection(String host, int port) async {
|
||||||
.get(
|
.get(
|
||||||
url: uri,
|
url: uri,
|
||||||
headers: {'Content-Type': 'application/json'},
|
headers: {'Content-Type': 'application/json'},
|
||||||
proxyInfo:
|
proxyInfo: Prefs.instance.useTor
|
||||||
Prefs.instance.useTor ? TorService.sharedInstance.proxyInfo : null,
|
? TorService.sharedInstance.getProxyInfo()
|
||||||
|
: null,
|
||||||
)
|
)
|
||||||
.timeout(const Duration(milliseconds: 2000),
|
.timeout(const Duration(milliseconds: 2000),
|
||||||
onTimeout: () async => http.Response(utf8.encode('Error'), 408));
|
onTimeout: () async => http.Response(utf8.encode('Error'), 408));
|
||||||
|
|
|
@ -81,9 +81,7 @@ class _DesktopTorStatusButtonState extends ConsumerState<DesktopTorStatusButton>
|
||||||
eventBus = GlobalEventBus.instance;
|
eventBus = GlobalEventBus.instance;
|
||||||
|
|
||||||
// Initialize the TorConnectionStatus.
|
// Initialize the TorConnectionStatus.
|
||||||
_torConnectionStatus = ref.read(pTorService).enabled
|
_torConnectionStatus = ref.read(pTorService).status;
|
||||||
? TorConnectionStatus.connected
|
|
||||||
: TorConnectionStatus.disconnected;
|
|
||||||
|
|
||||||
// Subscribe to the TorConnectionStatusChangedEvent.
|
// Subscribe to the TorConnectionStatusChangedEvent.
|
||||||
_torConnectionStatusSubscription =
|
_torConnectionStatusSubscription =
|
||||||
|
@ -93,25 +91,6 @@ class _DesktopTorStatusButtonState extends ConsumerState<DesktopTorStatusButton>
|
||||||
setState(() {
|
setState(() {
|
||||||
_torConnectionStatus = event.newStatus;
|
_torConnectionStatus = event.newStatus;
|
||||||
});
|
});
|
||||||
|
|
||||||
// TODO implement spinner or animations and control from here
|
|
||||||
// switch (event.newStatus) {
|
|
||||||
// case TorConnectionStatus.disconnected:
|
|
||||||
// // if (_spinController.hasLoadedAnimation) {
|
|
||||||
// // _spinController.stop?.call();
|
|
||||||
// // }
|
|
||||||
// break;
|
|
||||||
// case TorConnectionStatus.connecting:
|
|
||||||
// // if (_spinController.hasLoadedAnimation) {
|
|
||||||
// // _spinController.repeat?.call();
|
|
||||||
// // }
|
|
||||||
// break;
|
|
||||||
// case TorConnectionStatus.connected:
|
|
||||||
// // if (_spinController.hasLoadedAnimation) {
|
|
||||||
// // _spinController.stop?.call();
|
|
||||||
// // }
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -37,9 +37,7 @@ class _SmallTorIconState extends ConsumerState<SmallTorIcon> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
_status = ref.read(pTorService).enabled
|
_status = ref.read(pTorService).status;
|
||||||
? TorConnectionStatus.connected
|
|
||||||
: TorConnectionStatus.disconnected;
|
|
||||||
|
|
||||||
super.initState();
|
super.initState();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1655,9 +1655,11 @@ packages:
|
||||||
tor_ffi_plugin:
|
tor_ffi_plugin:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
path: "crypto_plugins/tor"
|
path: "."
|
||||||
relative: true
|
ref: "8a26a160bdc4dcac2ba5a0350a151a345d1dead9"
|
||||||
source: path
|
resolved-ref: "8a26a160bdc4dcac2ba5a0350a151a345d1dead9"
|
||||||
|
url: "https://github.com/cypherstack/tor.git"
|
||||||
|
source: git
|
||||||
version: "0.0.1"
|
version: "0.0.1"
|
||||||
tuple:
|
tuple:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
|
|
|
@ -58,7 +58,9 @@ dependencies:
|
||||||
ref: 081ca1863c2feba00c35bb5b297902f12f499941
|
ref: 081ca1863c2feba00c35bb5b297902f12f499941
|
||||||
|
|
||||||
tor_ffi_plugin:
|
tor_ffi_plugin:
|
||||||
path: ./crypto_plugins/tor
|
git:
|
||||||
|
url: https://github.com/cypherstack/tor.git
|
||||||
|
ref: 8a26a160bdc4dcac2ba5a0350a151a345d1dead9
|
||||||
|
|
||||||
# Utility plugins
|
# Utility plugins
|
||||||
http: ^0.13.0
|
http: ^0.13.0
|
||||||
|
@ -377,6 +379,7 @@ flutter:
|
||||||
- assets/lottie/icon_send.json
|
- assets/lottie/icon_send.json
|
||||||
- assets/lottie/loader_and_checkmark.json
|
- assets/lottie/loader_and_checkmark.json
|
||||||
- assets/lottie/arrow_rotate.json
|
- assets/lottie/arrow_rotate.json
|
||||||
|
- assets/lottie/onion_animation.json
|
||||||
|
|
||||||
# default themes_testing
|
# default themes_testing
|
||||||
- assets/default_themes/
|
- assets/default_themes/
|
||||||
|
|
|
@ -5,6 +5,7 @@ import 'package:mockito/annotations.dart';
|
||||||
import 'package:mockito/mockito.dart';
|
import 'package:mockito/mockito.dart';
|
||||||
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
|
import 'package:stackwallet/electrumx_rpc/electrumx.dart';
|
||||||
import 'package:stackwallet/electrumx_rpc/rpc.dart';
|
import 'package:stackwallet/electrumx_rpc/rpc.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/services/tor_service.dart';
|
||||||
import 'package:stackwallet/utilities/prefs.dart';
|
import 'package:stackwallet/utilities/prefs.dart';
|
||||||
|
|
||||||
|
@ -1528,7 +1529,8 @@ void main() {
|
||||||
.thenAnswer((_) => false); // Or true, shouldn't matter.
|
.thenAnswer((_) => false); // Or true, shouldn't matter.
|
||||||
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
||||||
final mockTorService = MockTorService();
|
final mockTorService = MockTorService();
|
||||||
when(mockTorService.enabled).thenAnswer((_) => false);
|
when(mockTorService.status)
|
||||||
|
.thenAnswer((_) => TorConnectionStatus.disconnected);
|
||||||
|
|
||||||
final client = ElectrumX(
|
final client = ElectrumX(
|
||||||
host: "some server",
|
host: "some server",
|
||||||
|
@ -1551,7 +1553,7 @@ void main() {
|
||||||
verify(mockPrefs.useTor).called(1);
|
verify(mockPrefs.useTor).called(1);
|
||||||
verifyNever(mockPrefs.torKillSwitch);
|
verifyNever(mockPrefs.torKillSwitch);
|
||||||
verifyNoMoreInteractions(mockPrefs);
|
verifyNoMoreInteractions(mockPrefs);
|
||||||
verifyNever(mockTorService.enabled);
|
verifyNever(mockTorService.status);
|
||||||
verifyNoMoreInteractions(mockTorService);
|
verifyNoMoreInteractions(mockTorService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1575,8 +1577,9 @@ void main() {
|
||||||
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
||||||
|
|
||||||
final mockTorService = MockTorService();
|
final mockTorService = MockTorService();
|
||||||
when(mockTorService.enabled).thenAnswer((_) => false);
|
when(mockTorService.status)
|
||||||
when(mockTorService.proxyInfo).thenAnswer((_) => (
|
.thenAnswer((_) => TorConnectionStatus.disconnected);
|
||||||
|
when(mockTorService.getProxyInfo()).thenAnswer((_) => (
|
||||||
host: InternetAddress('1.2.3.4'),
|
host: InternetAddress('1.2.3.4'),
|
||||||
port: -1
|
port: -1
|
||||||
)); // Port is set to -1 until Tor is enabled.
|
)); // Port is set to -1 until Tor is enabled.
|
||||||
|
@ -1601,8 +1604,8 @@ void main() {
|
||||||
verify(mockPrefs.useTor).called(1);
|
verify(mockPrefs.useTor).called(1);
|
||||||
verify(mockPrefs.torKillSwitch).called(1);
|
verify(mockPrefs.torKillSwitch).called(1);
|
||||||
verifyNoMoreInteractions(mockPrefs);
|
verifyNoMoreInteractions(mockPrefs);
|
||||||
verify(mockTorService.enabled).called(1);
|
verify(mockTorService.status).called(1);
|
||||||
verifyNever(mockTorService.proxyInfo);
|
verifyNever(mockTorService.getProxyInfo());
|
||||||
verifyNoMoreInteractions(mockTorService);
|
verifyNoMoreInteractions(mockTorService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1628,8 +1631,9 @@ void main() {
|
||||||
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
||||||
|
|
||||||
final mockTorService = MockTorService();
|
final mockTorService = MockTorService();
|
||||||
when(mockTorService.enabled).thenAnswer((_) => true);
|
when(mockTorService.status)
|
||||||
when(mockTorService.proxyInfo)
|
.thenAnswer((_) => TorConnectionStatus.connected);
|
||||||
|
when(mockTorService.getProxyInfo())
|
||||||
.thenAnswer((_) => (host: InternetAddress('1.2.3.4'), port: 42));
|
.thenAnswer((_) => (host: InternetAddress('1.2.3.4'), port: 42));
|
||||||
|
|
||||||
final client = ElectrumX(
|
final client = ElectrumX(
|
||||||
|
@ -1653,8 +1657,8 @@ void main() {
|
||||||
verify(mockPrefs.useTor).called(1);
|
verify(mockPrefs.useTor).called(1);
|
||||||
verifyNever(mockPrefs.torKillSwitch);
|
verifyNever(mockPrefs.torKillSwitch);
|
||||||
verifyNoMoreInteractions(mockPrefs);
|
verifyNoMoreInteractions(mockPrefs);
|
||||||
verify(mockTorService.enabled).called(1);
|
verify(mockTorService.status).called(1);
|
||||||
verify(mockTorService.proxyInfo).called(1);
|
verify(mockTorService.getProxyInfo()).called(1);
|
||||||
verifyNoMoreInteractions(mockTorService);
|
verifyNoMoreInteractions(mockTorService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1685,7 +1689,8 @@ void main() {
|
||||||
when(mockPrefs.torKillSwitch).thenAnswer((_) => true);
|
when(mockPrefs.torKillSwitch).thenAnswer((_) => true);
|
||||||
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
||||||
final mockTorService = MockTorService();
|
final mockTorService = MockTorService();
|
||||||
when(mockTorService.enabled).thenAnswer((_) => false);
|
when(mockTorService.status)
|
||||||
|
.thenAnswer((_) => TorConnectionStatus.disconnected);
|
||||||
|
|
||||||
final client = ElectrumX(
|
final client = ElectrumX(
|
||||||
host: "some server",
|
host: "some server",
|
||||||
|
@ -1712,7 +1717,7 @@ void main() {
|
||||||
verify(mockPrefs.useTor).called(1);
|
verify(mockPrefs.useTor).called(1);
|
||||||
verify(mockPrefs.torKillSwitch).called(1);
|
verify(mockPrefs.torKillSwitch).called(1);
|
||||||
verifyNoMoreInteractions(mockPrefs);
|
verifyNoMoreInteractions(mockPrefs);
|
||||||
verify(mockTorService.enabled).called(1);
|
verify(mockTorService.status).called(1);
|
||||||
verifyNoMoreInteractions(mockTorService);
|
verifyNoMoreInteractions(mockTorService);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1740,7 +1745,8 @@ void main() {
|
||||||
when(mockPrefs.torKillSwitch).thenAnswer((_) => false);
|
when(mockPrefs.torKillSwitch).thenAnswer((_) => false);
|
||||||
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
when(mockPrefs.wifiOnly).thenAnswer((_) => false);
|
||||||
final mockTorService = MockTorService();
|
final mockTorService = MockTorService();
|
||||||
when(mockTorService.enabled).thenAnswer((_) => false);
|
when(mockTorService.status)
|
||||||
|
.thenAnswer((_) => TorConnectionStatus.disconnected);
|
||||||
|
|
||||||
final client = ElectrumX(
|
final client = ElectrumX(
|
||||||
host: "some server",
|
host: "some server",
|
||||||
|
@ -1763,7 +1769,7 @@ void main() {
|
||||||
verify(mockPrefs.useTor).called(1);
|
verify(mockPrefs.useTor).called(1);
|
||||||
verify(mockPrefs.torKillSwitch).called(1);
|
verify(mockPrefs.torKillSwitch).called(1);
|
||||||
verifyNoMoreInteractions(mockPrefs);
|
verifyNoMoreInteractions(mockPrefs);
|
||||||
verify(mockTorService.enabled).called(1);
|
verify(mockTorService.status).called(1);
|
||||||
verifyNoMoreInteractions(mockTorService);
|
verifyNoMoreInteractions(mockTorService);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -9,13 +9,15 @@ import 'dart:ui' as _i10;
|
||||||
|
|
||||||
import 'package:mockito/mockito.dart' as _i1;
|
import 'package:mockito/mockito.dart' as _i1;
|
||||||
import 'package:stackwallet/electrumx_rpc/rpc.dart' as _i2;
|
import 'package:stackwallet/electrumx_rpc/rpc.dart' as _i2;
|
||||||
|
import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'
|
||||||
|
as _i12;
|
||||||
import 'package:stackwallet/services/tor_service.dart' as _i11;
|
import 'package:stackwallet/services/tor_service.dart' as _i11;
|
||||||
import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i8;
|
import 'package:stackwallet/utilities/amount/amount_unit.dart' as _i8;
|
||||||
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i7;
|
import 'package:stackwallet/utilities/enums/backup_frequency_type.dart' as _i7;
|
||||||
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9;
|
import 'package:stackwallet/utilities/enums/coin_enum.dart' as _i9;
|
||||||
import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i6;
|
import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i6;
|
||||||
import 'package:stackwallet/utilities/prefs.dart' as _i5;
|
import 'package:stackwallet/utilities/prefs.dart' as _i5;
|
||||||
import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i12;
|
import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i13;
|
||||||
|
|
||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
// ignore_for_file: avoid_redundant_argument_values
|
// ignore_for_file: avoid_redundant_argument_values
|
||||||
|
@ -659,27 +661,40 @@ class MockTorService extends _i1.Mock implements _i11.TorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get enabled => (super.noSuchMethod(
|
_i12.TorConnectionStatus get status => (super.noSuchMethod(
|
||||||
Invocation.getter(#enabled),
|
Invocation.getter(#status),
|
||||||
returnValue: false,
|
returnValue: _i12.TorConnectionStatus.disconnected,
|
||||||
) as bool);
|
) as _i12.TorConnectionStatus);
|
||||||
@override
|
@override
|
||||||
({_i3.InternetAddress host, int port}) get proxyInfo => (super.noSuchMethod(
|
({_i3.InternetAddress host, int port}) getProxyInfo() => (super.noSuchMethod(
|
||||||
Invocation.getter(#proxyInfo),
|
Invocation.method(
|
||||||
|
#getProxyInfo,
|
||||||
|
[],
|
||||||
|
),
|
||||||
returnValue: (
|
returnValue: (
|
||||||
host: _FakeInternetAddress_2(
|
host: _FakeInternetAddress_2(
|
||||||
this,
|
this,
|
||||||
Invocation.getter(#proxyInfo),
|
Invocation.method(
|
||||||
|
#getProxyInfo,
|
||||||
|
[],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
port: 0
|
port: 0
|
||||||
),
|
),
|
||||||
) as ({_i3.InternetAddress host, int port}));
|
) as ({_i3.InternetAddress host, int port}));
|
||||||
@override
|
@override
|
||||||
void init({_i12.Tor? mockableOverride}) => super.noSuchMethod(
|
void init({
|
||||||
|
required String? torDataDirPath,
|
||||||
|
_i13.Tor? mockableOverride,
|
||||||
|
}) =>
|
||||||
|
super.noSuchMethod(
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
#init,
|
#init,
|
||||||
[],
|
[],
|
||||||
{#mockableOverride: mockableOverride},
|
{
|
||||||
|
#torDataDirPath: torDataDirPath,
|
||||||
|
#mockableOverride: mockableOverride,
|
||||||
|
},
|
||||||
),
|
),
|
||||||
returnValueForMissingStub: null,
|
returnValueForMissingStub: null,
|
||||||
);
|
);
|
||||||
|
@ -693,9 +708,9 @@ class MockTorService extends _i1.Mock implements _i11.TorService {
|
||||||
returnValueForMissingStub: _i4.Future<void>.value(),
|
returnValueForMissingStub: _i4.Future<void>.value(),
|
||||||
) as _i4.Future<void>);
|
) as _i4.Future<void>);
|
||||||
@override
|
@override
|
||||||
_i4.Future<void> stop() => (super.noSuchMethod(
|
_i4.Future<void> disable() => (super.noSuchMethod(
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
#stop,
|
#disable,
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
returnValue: _i4.Future<void>.value(),
|
returnValue: _i4.Future<void>.value(),
|
||||||
|
|
|
@ -12,6 +12,8 @@ import 'package:flutter_riverpod/flutter_riverpod.dart' as _i5;
|
||||||
import 'package:mockito/mockito.dart' as _i1;
|
import 'package:mockito/mockito.dart' as _i1;
|
||||||
import 'package:stackwallet/models/node_model.dart' as _i18;
|
import 'package:stackwallet/models/node_model.dart' as _i18;
|
||||||
import 'package:stackwallet/services/coins/manager.dart' as _i6;
|
import 'package:stackwallet/services/coins/manager.dart' as _i6;
|
||||||
|
import 'package:stackwallet/services/event_bus/events/global/tor_connection_status_changed_event.dart'
|
||||||
|
as _i20;
|
||||||
import 'package:stackwallet/services/node_service.dart' as _i3;
|
import 'package:stackwallet/services/node_service.dart' as _i3;
|
||||||
import 'package:stackwallet/services/tor_service.dart' as _i19;
|
import 'package:stackwallet/services/tor_service.dart' as _i19;
|
||||||
import 'package:stackwallet/services/wallets.dart' as _i9;
|
import 'package:stackwallet/services/wallets.dart' as _i9;
|
||||||
|
@ -23,7 +25,7 @@ import 'package:stackwallet/utilities/enums/sync_type_enum.dart' as _i15;
|
||||||
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'
|
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'
|
||||||
as _i7;
|
as _i7;
|
||||||
import 'package:stackwallet/utilities/prefs.dart' as _i13;
|
import 'package:stackwallet/utilities/prefs.dart' as _i13;
|
||||||
import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i20;
|
import 'package:tor_ffi_plugin/tor_ffi_plugin.dart' as _i21;
|
||||||
import 'package:tuple/tuple.dart' as _i11;
|
import 'package:tuple/tuple.dart' as _i11;
|
||||||
|
|
||||||
// ignore_for_file: type=lint
|
// ignore_for_file: type=lint
|
||||||
|
@ -1025,27 +1027,40 @@ class MockTorService extends _i1.Mock implements _i19.TorService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool get enabled => (super.noSuchMethod(
|
_i20.TorConnectionStatus get status => (super.noSuchMethod(
|
||||||
Invocation.getter(#enabled),
|
Invocation.getter(#status),
|
||||||
returnValue: false,
|
returnValue: _i20.TorConnectionStatus.disconnected,
|
||||||
) as bool);
|
) as _i20.TorConnectionStatus);
|
||||||
@override
|
@override
|
||||||
({_i8.InternetAddress host, int port}) get proxyInfo => (super.noSuchMethod(
|
({_i8.InternetAddress host, int port}) getProxyInfo() => (super.noSuchMethod(
|
||||||
Invocation.getter(#proxyInfo),
|
Invocation.method(
|
||||||
|
#getProxyInfo,
|
||||||
|
[],
|
||||||
|
),
|
||||||
returnValue: (
|
returnValue: (
|
||||||
host: _FakeInternetAddress_5(
|
host: _FakeInternetAddress_5(
|
||||||
this,
|
this,
|
||||||
Invocation.getter(#proxyInfo),
|
Invocation.method(
|
||||||
|
#getProxyInfo,
|
||||||
|
[],
|
||||||
|
),
|
||||||
),
|
),
|
||||||
port: 0
|
port: 0
|
||||||
),
|
),
|
||||||
) as ({_i8.InternetAddress host, int port}));
|
) as ({_i8.InternetAddress host, int port}));
|
||||||
@override
|
@override
|
||||||
void init({_i20.Tor? mockableOverride}) => super.noSuchMethod(
|
void init({
|
||||||
|
required String? torDataDirPath,
|
||||||
|
_i21.Tor? mockableOverride,
|
||||||
|
}) =>
|
||||||
|
super.noSuchMethod(
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
#init,
|
#init,
|
||||||
[],
|
[],
|
||||||
{#mockableOverride: mockableOverride},
|
{
|
||||||
|
#torDataDirPath: torDataDirPath,
|
||||||
|
#mockableOverride: mockableOverride,
|
||||||
|
},
|
||||||
),
|
),
|
||||||
returnValueForMissingStub: null,
|
returnValueForMissingStub: null,
|
||||||
);
|
);
|
||||||
|
@ -1059,9 +1074,9 @@ class MockTorService extends _i1.Mock implements _i19.TorService {
|
||||||
returnValueForMissingStub: _i12.Future<void>.value(),
|
returnValueForMissingStub: _i12.Future<void>.value(),
|
||||||
) as _i12.Future<void>);
|
) as _i12.Future<void>);
|
||||||
@override
|
@override
|
||||||
_i12.Future<void> stop() => (super.noSuchMethod(
|
_i12.Future<void> disable() => (super.noSuchMethod(
|
||||||
Invocation.method(
|
Invocation.method(
|
||||||
#stop,
|
#disable,
|
||||||
[],
|
[],
|
||||||
),
|
),
|
||||||
returnValue: _i12.Future<void>.value(),
|
returnValue: _i12.Future<void>.value(),
|
||||||
|
|
Loading…
Reference in a new issue