Merge remote-tracking branch 'origin/staging' into arti

This commit is contained in:
sneurlax 2023-09-07 13:12:20 -05:00
commit 622085ca5c
91 changed files with 2432 additions and 427 deletions

Binary file not shown.

Binary file not shown.

View file

@ -123,7 +123,7 @@ flutter run android
Note on Emulators: Only x86_64 emulators are supported, x86 emulators will not work
#### Linux
Plug in your android device or use the emulator available via Android Studio and then run the following commands:
Run the following commands or launch via Android Studio:
```
flutter pub get
flutter run linux

View file

@ -14,6 +14,7 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart';
import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart';
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart';
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart';
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
@ -336,46 +337,60 @@ class _NameYourWalletViewState extends ConsumerState<NameYourWalletView> {
ref.read(walletsServiceChangeNotifierProvider);
final name = textEditingController.text;
if (await walletsService.checkForDuplicate(name)) {
unawaited(showFloatingFlushBar(
type: FlushBarType.warning,
message: "Wallet name already in use.",
iconAsset: Assets.svg.circleAlert,
context: context,
));
} else {
// hide keyboard if has focus
if (FocusScope.of(context).hasFocus) {
FocusScope.of(context).unfocus();
await Future<void>.delayed(
const Duration(milliseconds: 50));
}
final hasDuplicateName =
await walletsService.checkForDuplicate(name);
if (mounted) {
switch (widget.addWalletType) {
case AddWalletType.New:
unawaited(Navigator.of(context).pushNamed(
NewWalletRecoveryPhraseWarningView.routeName,
arguments: Tuple2(
name,
coin,
),
));
break;
case AddWalletType.Restore:
ref
.read(mnemonicWordCountStateProvider.state)
.state = Constants.possibleLengthsForCoin(
coin)
.first;
unawaited(Navigator.of(context).pushNamed(
RestoreOptionsView.routeName,
arguments: Tuple2(
name,
coin,
),
));
break;
if (mounted) {
if (hasDuplicateName) {
unawaited(showFloatingFlushBar(
type: FlushBarType.warning,
message: "Wallet name already in use.",
iconAsset: Assets.svg.circleAlert,
context: context,
));
} else {
// hide keyboard if has focus
if (FocusScope.of(context).hasFocus) {
FocusScope.of(context).unfocus();
await Future<void>.delayed(
const Duration(milliseconds: 50));
}
if (mounted) {
ref
.read(mnemonicWordCountStateProvider.state)
.state =
Constants.possibleLengthsForCoin(coin).last;
ref.read(pNewWalletOptions.notifier).state = null;
switch (widget.addWalletType) {
case AddWalletType.New:
unawaited(
Navigator.of(context).pushNamed(
coin.hasMnemonicPassphraseSupport
? NewWalletOptionsView.routeName
: NewWalletRecoveryPhraseWarningView
.routeName,
arguments: Tuple2(
name,
coin,
),
),
);
break;
case AddWalletType.Restore:
unawaited(
Navigator.of(context).pushNamed(
RestoreOptionsView.routeName,
arguments: Tuple2(
name,
coin,
),
),
);
break;
}
}
}
}

View file

@ -0,0 +1,410 @@
import 'package:dropdown_button2/dropdown_button2.dart';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/sub_widgets/coin_image.dart';
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart';
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/sub_widgets/mobile_mnemonic_length_selector.dart';
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/sub_widgets/mnemonic_word_count_select_sheet.dart';
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
import 'package:stackwallet/providers/ui/verify_recovery_phrase/mnemonic_word_count_state_provider.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/background.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/custom_buttons/app_bar_icon_button.dart';
import 'package:stackwallet/widgets/desktop/desktop_app_bar.dart';
import 'package:stackwallet/widgets/desktop/desktop_scaffold.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'package:stackwallet/widgets/stack_text_field.dart';
import 'package:tuple/tuple.dart';
final pNewWalletOptions =
StateProvider<({String mnemonicPassphrase, int mnemonicWordsCount})?>(
(ref) => null);
enum NewWalletOptions {
Default,
Advanced;
}
class NewWalletOptionsView extends ConsumerStatefulWidget {
const NewWalletOptionsView({
Key? key,
required this.walletName,
required this.coin,
}) : super(key: key);
static const routeName = "/newWalletOptionsView";
final String walletName;
final Coin coin;
@override
ConsumerState<NewWalletOptionsView> createState() =>
_NewWalletOptionsViewState();
}
class _NewWalletOptionsViewState extends ConsumerState<NewWalletOptionsView> {
late final FocusNode passwordFocusNode;
late final TextEditingController passwordController;
bool hidePassword = true;
NewWalletOptions _selectedOptions = NewWalletOptions.Default;
@override
void initState() {
passwordController = TextEditingController();
passwordFocusNode = FocusNode();
super.initState();
}
@override
void dispose() {
passwordController.dispose();
passwordFocusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
final lengths = Constants.possibleLengthsForCoin(widget.coin).toList();
return ConditionalParent(
condition: Util.isDesktop,
builder: (child) => DesktopScaffold(
background: Theme.of(context).extension<StackColors>()!.background,
appBar: const DesktopAppBar(
isCompactHeight: false,
leading: AppBarBackButton(),
trailing: ExitToMyStackButton(),
),
body: SizedBox(
width: 480,
child: child,
),
),
child: ConditionalParent(
condition: !Util.isDesktop,
builder: (child) => Background(
child: Scaffold(
backgroundColor:
Theme.of(context).extension<StackColors>()!.background,
appBar: AppBar(
leading: const AppBarBackButton(),
title: Text(
"Wallet Options",
style: STextStyles.navBarTitle(context),
),
),
body: SafeArea(
child: LayoutBuilder(
builder: (context, constraints) {
return SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(
minHeight: constraints.maxHeight,
),
child: IntrinsicHeight(
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16),
child: child,
),
),
),
);
},
),
),
),
),
child: Column(
children: [
if (Util.isDesktop)
const Spacer(
flex: 10,
),
if (!Util.isDesktop)
const SizedBox(
height: 16,
),
if (!Util.isDesktop)
CoinImage(
coin: widget.coin,
height: 100,
width: 100,
),
if (Util.isDesktop)
Text(
"Wallet options",
textAlign: TextAlign.center,
style: Util.isDesktop
? STextStyles.desktopH2(context)
: STextStyles.pageTitleH1(context),
),
SizedBox(
height: Util.isDesktop ? 32 : 16,
),
DropdownButtonHideUnderline(
child: DropdownButton2<NewWalletOptions>(
value: _selectedOptions,
items: [
...NewWalletOptions.values.map(
(e) => DropdownMenuItem(
value: e,
child: Text(
e.name,
style: STextStyles.desktopTextMedium(context),
),
),
),
],
onChanged: (value) {
if (value is NewWalletOptions) {
setState(() {
_selectedOptions = value;
});
}
},
isExpanded: true,
iconStyleData: IconStyleData(
icon: SvgPicture.asset(
Assets.svg.chevronDown,
width: 12,
height: 6,
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveSearchIconRight,
),
),
dropdownStyleData: DropdownStyleData(
offset: const Offset(0, -10),
elevation: 0,
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
),
menuItemStyleData: const MenuItemStyleData(
padding: EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
),
),
),
),
const SizedBox(
height: 24,
),
if (_selectedOptions == NewWalletOptions.Advanced)
Column(
children: [
if (Util.isDesktop)
DropdownButtonHideUnderline(
child: DropdownButton2<int>(
value: ref
.watch(mnemonicWordCountStateProvider.state)
.state,
items: [
...lengths.map(
(e) => DropdownMenuItem(
value: e,
child: Text(
"$e word seed",
style: STextStyles.desktopTextMedium(context),
),
),
),
],
onChanged: (value) {
if (value is int) {
ref
.read(mnemonicWordCountStateProvider.state)
.state = value;
}
},
isExpanded: true,
iconStyleData: IconStyleData(
icon: SvgPicture.asset(
Assets.svg.chevronDown,
width: 12,
height: 6,
color: Theme.of(context)
.extension<StackColors>()!
.textFieldActiveSearchIconRight,
),
),
dropdownStyleData: DropdownStyleData(
offset: const Offset(0, -10),
elevation: 0,
decoration: BoxDecoration(
color: Theme.of(context)
.extension<StackColors>()!
.textFieldDefaultBG,
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
),
),
menuItemStyleData: const MenuItemStyleData(
padding: EdgeInsets.symmetric(
horizontal: 16,
vertical: 8,
),
),
),
),
if (!Util.isDesktop)
MobileMnemonicLengthSelector(
chooseMnemonicLength: () {
showModalBottomSheet<dynamic>(
backgroundColor: Colors.transparent,
context: context,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.vertical(
top: Radius.circular(20),
),
),
builder: (_) {
return MnemonicWordCountSelectSheet(
lengthOptions: lengths,
);
},
);
},
),
const SizedBox(
height: 24,
),
RoundedWhiteContainer(
child: Center(
child: Text(
"You may add a BIP39 passphrase. This is optional. "
"You will need BOTH you seed and your passphrase to recover the wallet.",
style: Util.isDesktop
? STextStyles.desktopTextExtraSmall(context)
.copyWith(
color: Theme.of(context)
.extension<StackColors>()!
.textSubtitle1,
)
: STextStyles.itemSubtitle(context),
),
),
),
const SizedBox(
height: 8,
),
ClipRRect(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
child: TextField(
key: const Key("mnemonicPassphraseFieldKey1"),
focusNode: passwordFocusNode,
controller: passwordController,
style: Util.isDesktop
? STextStyles.desktopTextMedium(context).copyWith(
height: 2,
)
: STextStyles.field(context),
obscureText: hidePassword,
enableSuggestions: false,
autocorrect: false,
decoration: standardInputDecoration(
"BIP39 passphrase",
passwordFocusNode,
context,
).copyWith(
suffixIcon: UnconstrainedBox(
child: ConditionalParent(
condition: Util.isDesktop,
builder: (child) => SizedBox(
height: 70,
child: child,
),
child: Row(
children: [
SizedBox(
width: Util.isDesktop ? 24 : 16,
),
GestureDetector(
key: const Key(
"mnemonicPassphraseFieldShowPasswordButtonKey"),
onTap: () async {
setState(() {
hidePassword = !hidePassword;
});
},
child: SvgPicture.asset(
hidePassword
? Assets.svg.eye
: Assets.svg.eyeSlash,
color: Theme.of(context)
.extension<StackColors>()!
.textDark3,
width: Util.isDesktop ? 24 : 16,
height: Util.isDesktop ? 24 : 16,
),
),
const SizedBox(
width: 12,
),
],
),
),
),
),
),
),
],
),
if (!Util.isDesktop) const Spacer(),
SizedBox(
height: Util.isDesktop ? 32 : 16,
),
PrimaryButton(
label: "Continue",
onPressed: () {
if (_selectedOptions == NewWalletOptions.Advanced) {
ref.read(pNewWalletOptions.notifier).state = (
mnemonicWordsCount:
ref.read(mnemonicWordCountStateProvider.state).state,
mnemonicPassphrase: passwordController.text,
);
} else {
ref.read(pNewWalletOptions.notifier).state = null;
}
Navigator.of(context).pushNamed(
NewWalletRecoveryPhraseWarningView.routeName,
arguments: Tuple2(
widget.walletName,
widget.coin,
),
);
},
),
if (!Util.isDesktop)
const SizedBox(
height: 16,
),
if (Util.isDesktop)
const Spacer(
flex: 15,
),
],
),
),
);
}
}

View file

@ -13,6 +13,7 @@ import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart';
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart';
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/recovery_phrase_explanation_dialog.dart';
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
@ -38,7 +39,7 @@ import 'package:stackwallet/widgets/rounded_container.dart';
import 'package:stackwallet/widgets/rounded_white_container.dart';
import 'package:tuple/tuple.dart';
class NewWalletRecoveryPhraseWarningView extends StatefulWidget {
class NewWalletRecoveryPhraseWarningView extends ConsumerStatefulWidget {
const NewWalletRecoveryPhraseWarningView({
Key? key,
required this.coin,
@ -51,12 +52,12 @@ class NewWalletRecoveryPhraseWarningView extends StatefulWidget {
final String walletName;
@override
State<NewWalletRecoveryPhraseWarningView> createState() =>
ConsumerState<NewWalletRecoveryPhraseWarningView> createState() =>
_NewWalletRecoveryPhraseWarningViewState();
}
class _NewWalletRecoveryPhraseWarningViewState
extends State<NewWalletRecoveryPhraseWarningView> {
extends ConsumerState<NewWalletRecoveryPhraseWarningView> {
late final Coin coin;
late final String walletName;
late final bool isDesktop;
@ -72,6 +73,10 @@ class _NewWalletRecoveryPhraseWarningViewState
@override
Widget build(BuildContext context) {
debugPrint("BUILD: $runtimeType");
final options = ref.read(pNewWalletOptions.state).state;
final seedCount = options?.mnemonicWordsCount ??
Constants.defaultSeedPhraseLengthFor(coin: coin);
return MasterScaffold(
isDesktop: isDesktop,
@ -172,7 +177,7 @@ class _NewWalletRecoveryPhraseWarningViewState
child: isDesktop
? Text(
"On the next screen you will see "
"${Constants.defaultSeedPhraseLengthFor(coin: coin)} "
"$seedCount "
"words that make up your recovery phrase.\n\nPlease "
"write it down. Keep it safe and never share it with "
"anyone. Your recovery phrase is the only way you can"
@ -216,9 +221,7 @@ class _NewWalletRecoveryPhraseWarningViewState
),
),
TextSpan(
text:
"${Constants.defaultSeedPhraseLengthFor(coin: coin)}"
" words",
text: "$seedCount words",
style: STextStyles.desktopH3(context).copyWith(
color: Theme.of(context)
.extension<StackColors>()!
@ -496,7 +499,24 @@ class _NewWalletRecoveryPhraseWarningViewState
final manager = Manager(wallet);
await manager.initializeNew();
if (coin.hasMnemonicPassphraseSupport &&
ref
.read(pNewWalletOptions.state)
.state !=
null) {
await manager.initializeNew((
mnemonicPassphrase: ref
.read(pNewWalletOptions.state)
.state!
.mnemonicPassphrase,
wordCount: ref
.read(pNewWalletOptions.state)
.state!
.mnemonicWordsCount,
));
} else {
await manager.initializeNew(null);
}
// pop progress dialog
if (mounted) {

View file

@ -535,7 +535,7 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
enableSuggestions: false,
autocorrect: false,
decoration: standardInputDecoration(
"Recovery phrase password",
"BIP39 passphrase",
passwordFocusNode,
context,
).copyWith(
@ -586,7 +586,9 @@ class _RestoreOptionsViewState extends ConsumerState<RestoreOptionsView> {
RoundedWhiteContainer(
child: Center(
child: Text(
"If the recovery phrase you are about to restore was created with an optional passphrase you can enter it here.",
"If the recovery phrase you are about to restore "
"was created with an optional BIP39 passphrase "
"you can enter it here.",
style: isDesktop
? STextStyles.desktopTextExtraSmall(context)
.copyWith(

View file

@ -0,0 +1,218 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart';
import 'package:stackwallet/themes/stack_colors.dart';
import 'package:stackwallet/utilities/assets.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog.dart';
import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart';
import 'package:stackwallet/widgets/desktop/primary_button.dart';
import 'package:stackwallet/widgets/desktop/secondary_button.dart';
import 'package:stackwallet/widgets/stack_dialog.dart';
import 'package:stackwallet/widgets/stack_text_field.dart';
class VerifyMnemonicPassphraseDialog extends ConsumerStatefulWidget {
const VerifyMnemonicPassphraseDialog({super.key});
@override
ConsumerState<VerifyMnemonicPassphraseDialog> createState() =>
_VerifyMnemonicPassphraseDialogState();
}
class _VerifyMnemonicPassphraseDialogState
extends ConsumerState<VerifyMnemonicPassphraseDialog> {
late final FocusNode passwordFocusNode;
late final TextEditingController passwordController;
bool hidePassword = true;
bool _verifyLock = false;
void _verify() {
if (_verifyLock) {
return;
}
_verifyLock = true;
if (passwordController.text ==
ref.read(pNewWalletOptions.state).state!.mnemonicPassphrase) {
Navigator.of(context, rootNavigator: Util.isDesktop).pop("verified");
} else {
showFloatingFlushBar(
type: FlushBarType.warning,
message: "Passphrase does not match",
context: context,
);
}
_verifyLock = false;
}
@override
void initState() {
passwordController = TextEditingController();
passwordFocusNode = FocusNode();
super.initState();
}
@override
void dispose() {
passwordController.dispose();
passwordFocusNode.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return ConditionalParent(
condition: Util.isDesktop,
builder: (child) => DesktopDialog(
maxHeight: double.infinity,
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Padding(
padding: const EdgeInsets.only(
left: 32,
),
child: Text(
"Verify mnemonic passphrase",
style: STextStyles.desktopH3(context),
),
),
const DesktopDialogCloseButton(),
],
),
Padding(
padding: const EdgeInsets.only(
left: 32,
right: 32,
bottom: 32,
),
child: child,
),
],
),
),
child: ConditionalParent(
condition: !Util.isDesktop,
builder: (child) => StackDialogBase(
keyboardPaddingAmount: MediaQuery.of(context).viewInsets.bottom,
child: child,
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
if (!Util.isDesktop)
Text(
"Verify BIP39 passphrase",
style: STextStyles.pageTitleH2(context),
),
const SizedBox(
height: 24,
),
ClipRRect(
borderRadius: BorderRadius.circular(
Constants.size.circularBorderRadius,
),
child: TextField(
key: const Key("mnemonicPassphraseFieldKey1"),
focusNode: passwordFocusNode,
controller: passwordController,
style: Util.isDesktop
? STextStyles.desktopTextMedium(context).copyWith(
height: 2,
)
: STextStyles.field(context),
obscureText: hidePassword,
enableSuggestions: false,
autocorrect: false,
decoration: standardInputDecoration(
"Enter your BIP39 passphrase",
passwordFocusNode,
context,
).copyWith(
suffixIcon: UnconstrainedBox(
child: ConditionalParent(
condition: Util.isDesktop,
builder: (child) => SizedBox(
height: 70,
child: child,
),
child: Row(
children: [
SizedBox(
width: Util.isDesktop ? 24 : 16,
),
GestureDetector(
key: const Key(
"mnemonicPassphraseFieldShowPasswordButtonKey"),
onTap: () async {
setState(() {
hidePassword = !hidePassword;
});
},
child: SvgPicture.asset(
hidePassword
? Assets.svg.eye
: Assets.svg.eyeSlash,
color: Theme.of(context)
.extension<StackColors>()!
.textDark3,
width: Util.isDesktop ? 24 : 16,
height: Util.isDesktop ? 24 : 16,
),
),
const SizedBox(
width: 12,
),
],
),
),
),
),
),
),
SizedBox(
height: Util.isDesktop ? 48 : 24,
),
ConditionalParent(
condition: !Util.isDesktop,
builder: (child) => Row(
children: [
Expanded(
child: SecondaryButton(
label: "Cancel",
onPressed: Navigator.of(
context,
rootNavigator: Util.isDesktop,
).pop,
),
),
const SizedBox(
width: 16,
),
Expanded(
child: child,
),
],
),
child: PrimaryButton(
label: "Verify",
onPressed: _verify,
),
),
],
),
),
);
}
}

View file

@ -16,9 +16,11 @@ import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:stackwallet/notifications/show_flush_bar.dart';
import 'package:stackwallet/pages/add_wallet_views/add_token_view/edit_wallet_tokens_view.dart';
import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart';
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart';
import 'package:stackwallet/pages/add_wallet_views/select_wallet_for_token_view.dart';
import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/sub_widgets/word_table.dart';
import 'package:stackwallet/pages/add_wallet_views/verify_recovery_phrase_view/verify_mnemonic_passphrase_dialog.dart';
import 'package:stackwallet/pages/home_view/home_view.dart';
import 'package:stackwallet/pages_desktop_specific/desktop_home_view.dart';
import 'package:stackwallet/pages_desktop_specific/my_stack_view/exit_to_my_stack_button.dart';
@ -98,8 +100,25 @@ class _VerifyRecoveryPhraseViewState
// }
// }
Future<bool> _verifyMnemonicPassphrase() async {
final result = await showDialog<String?>(
context: context,
builder: (_) => const VerifyMnemonicPassphraseDialog(),
);
return result == "verified";
}
Future<void> _continue(bool isMatch) async {
if (isMatch) {
if (ref.read(pNewWalletOptions.state).state != null) {
final passphraseVerified = await _verifyMnemonicPassphrase();
if (!passphraseVerified) {
return;
}
}
await ref.read(walletsServiceChangeNotifierProvider).setMnemonicVerified(
walletId: _manager.walletId,
);

View file

@ -307,14 +307,20 @@ class _ReceiveViewState extends ConsumerState<ReceiveView> {
if (coin != Coin.epicCash &&
coin != Coin.ethereum &&
coin != Coin.banano &&
coin != Coin.nano)
coin != Coin.nano &&
coin != Coin.stellar &&
coin != Coin.stellarTestnet &&
coin != Coin.tezos)
const SizedBox(
height: 12,
),
if (coin != Coin.epicCash &&
coin != Coin.ethereum &&
coin != Coin.banano &&
coin != Coin.nano)
coin != Coin.nano &&
coin != Coin.stellar &&
coin != Coin.stellarTestnet &&
coin != Coin.tezos)
TextButton(
onPressed: generateNewAddress,
style: Theme.of(context)

View file

@ -27,6 +27,7 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/test_epic_box_connection.dart';
import 'package:stackwallet/utilities/test_monero_node_connection.dart';
import 'package:stackwallet/utilities/test_stellar_node_connection.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/background.dart';
@ -193,13 +194,20 @@ class _AddEditNodeViewState extends ConsumerState<AddEditNodeView> {
try {
// await client.getSyncStatus();
} catch (_) {}
break;
case Coin.stellar:
case Coin.stellarTestnet:
try {
testPassed =
await testStellarNodeConnection(formData.host!, formData.port!);
} catch (_) {}
break;
case Coin.nano:
case Coin.banano:
case Coin.stellar:
case Coin.stellarTestnet:
case Coin.tezos:
throw UnimplementedError();
//TODO: check network/node
//TODO: check network/node
}
if (showFlushBar && mounted) {
@ -730,6 +738,7 @@ class _NodeFormState extends ConsumerState<NodeForm> {
case Coin.namecoin:
case Coin.bitcoincash:
case Coin.particl:
case Coin.tezos:
case Coin.bitcoinTestNet:
case Coin.litecoinTestNet:
case Coin.bitcoincashTestnet:

View file

@ -26,6 +26,7 @@ import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/test_epic_box_connection.dart';
import 'package:stackwallet/utilities/test_eth_node_connection.dart';
import 'package:stackwallet/utilities/test_monero_node_connection.dart';
import 'package:stackwallet/utilities/test_stellar_node_connection.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/background.dart';
@ -172,10 +173,17 @@ class _NodeDetailsViewState extends ConsumerState<NodeDetailsView> {
case Coin.nano:
case Coin.banano:
case Coin.tezos:
throw UnimplementedError();
//TODO: check network/node
case Coin.stellar:
case Coin.stellarTestnet:
throw UnimplementedError();
//TODO: check network/node
try {
testPassed = await testStellarNodeConnection(node!.host, node.port);
} catch (_) {
testPassed = false;
}
break;
}
if (testPassed) {

View file

@ -219,14 +219,20 @@ class _DesktopReceiveState extends ConsumerState<DesktopReceive> {
if (coin != Coin.epicCash &&
coin != Coin.ethereum &&
coin != Coin.banano &&
coin != Coin.nano)
coin != Coin.nano &&
coin != Coin.stellar &&
coin != Coin.stellarTestnet &&
coin != Coin.tezos)
const SizedBox(
height: 20,
),
if (coin != Coin.epicCash &&
coin != Coin.ethereum &&
coin != Coin.banano &&
coin != Coin.nano)
coin != Coin.nano &&
coin != Coin.stellar &&
coin != Coin.stellarTestnet &&
coin != Coin.tezos)
SecondaryButton(
buttonHeight: ButtonHeight.l,
onPressed: generateNewAddress,

View file

@ -27,6 +27,7 @@ import 'package:stackwallet/pages/add_wallet_views/add_token_view/edit_wallet_to
import 'package:stackwallet/pages/add_wallet_views/add_wallet_view/add_wallet_view.dart';
import 'package:stackwallet/pages/add_wallet_views/create_or_restore_wallet_view/create_or_restore_wallet_view.dart';
import 'package:stackwallet/pages/add_wallet_views/name_your_wallet_view/name_your_wallet_view.dart';
import 'package:stackwallet/pages/add_wallet_views/new_wallet_options/new_wallet_options_view.dart';
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_view/new_wallet_recovery_phrase_view.dart';
import 'package:stackwallet/pages/add_wallet_views/new_wallet_recovery_phrase_warning_view/new_wallet_recovery_phrase_warning_view.dart';
import 'package:stackwallet/pages/add_wallet_views/restore_wallet_view/restore_options_view/restore_options_view.dart';
@ -1101,6 +1102,21 @@ class RouteGenerator {
}
return _routeError("${settings.name} invalid args: ${args.toString()}");
case NewWalletOptionsView.routeName:
if (args is Tuple2<String, Coin>) {
return getRoute(
shouldUseMaterialRoute: useMaterialPageRoute,
builder: (_) => NewWalletOptionsView(
walletName: args.item1,
coin: args.item2,
),
settings: RouteSettings(
name: settings.name,
),
);
}
return _routeError("${settings.name} invalid args: ${args.toString()}");
case RestoreWalletView.routeName:
if (args is Tuple5<String, Coin, int, DateTime, String>) {
return getRoute(

View file

@ -600,7 +600,9 @@ class BananoWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
if ((await mnemonicString) != null || (await mnemonicPassphrase) != null) {
throw Exception(
"Attempted to overwrite mnemonic on generate new wallet!");

View file

@ -1290,7 +1290,9 @@ class BitcoinWallet extends CoinServiceAPI
bool get isConnected => _isConnected;
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info);
@ -1301,7 +1303,7 @@ class BitcoinWallet extends CoinServiceAPI
await _prefs.init();
try {
await _generateNewWallet();
await _generateNewWallet(data);
} catch (e, s) {
Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s",
level: LogLevel.Fatal);
@ -1499,7 +1501,9 @@ class BitcoinWallet extends CoinServiceAPI
}
}
Future<void> _generateNewWallet() async {
Future<void> _generateNewWallet(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
if (!integrationTestFlag) {
@ -1533,10 +1537,21 @@ class BitcoinWallet extends CoinServiceAPI
throw Exception(
"Attempted to overwrite mnemonic on generate new wallet!");
}
final int strength;
if (data == null || data.wordCount == 12) {
strength = 128;
} else if (data.wordCount == 24) {
strength = 256;
} else {
throw Exception("Invalid word count");
}
await _secureStore.write(
key: '${_walletId}_mnemonic',
value: bip39.generateMnemonic(strength: 128));
await _secureStore.write(key: '${_walletId}_mnemonicPassphrase', value: "");
value: bip39.generateMnemonic(strength: strength));
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: data?.mnemonicPassphrase ?? "",
);
// Generate and add addresses to relevant arrays
final initialAddresses = await Future.wait([

View file

@ -1161,7 +1161,9 @@ class BitcoinCashWallet extends CoinServiceAPI
bool get isConnected => _isConnected;
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info);
@ -1171,7 +1173,7 @@ class BitcoinCashWallet extends CoinServiceAPI
}
await _prefs.init();
try {
await _generateNewWallet();
await _generateNewWallet(data);
} catch (e, s) {
Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s",
level: LogLevel.Fatal);
@ -1402,7 +1404,9 @@ class BitcoinCashWallet extends CoinServiceAPI
}
}
Future<void> _generateNewWallet() async {
Future<void> _generateNewWallet(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
if (!integrationTestFlag) {
@ -1436,10 +1440,21 @@ class BitcoinCashWallet extends CoinServiceAPI
throw Exception(
"Attempted to overwrite mnemonic on generate new wallet!");
}
final int strength;
if (data == null || data.wordCount == 12) {
strength = 128;
} else if (data.wordCount == 24) {
strength = 256;
} else {
throw Exception("Invalid word count");
}
await _secureStore.write(
key: '${_walletId}_mnemonic',
value: bip39.generateMnemonic(strength: 128));
await _secureStore.write(key: '${_walletId}_mnemonicPassphrase', value: "");
value: bip39.generateMnemonic(strength: strength));
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: data?.mnemonicPassphrase ?? "",
);
// Generate and add addresses to relevant arrays
final initialAddresses = await Future.wait([

View file

@ -1,6 +1,6 @@
/*
/*
* This file is part of Stack Wallet.
*
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
@ -28,6 +28,7 @@ import 'package:stackwallet/services/coins/namecoin/namecoin_wallet.dart';
import 'package:stackwallet/services/coins/nano/nano_wallet.dart';
import 'package:stackwallet/services/coins/particl/particl_wallet.dart';
import 'package:stackwallet/services/coins/stellar/stellar_wallet.dart';
import 'package:stackwallet/services/coins/tezos/tezos_wallet.dart';
import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart';
import 'package:stackwallet/services/transaction_notification_tracker.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
@ -228,6 +229,24 @@ abstract class CoinServiceAPI {
tracker: tracker,
);
case Coin.stellarTestnet:
return StellarWallet(
walletId: walletId,
walletName: walletName,
coin: coin,
secureStore: secureStorageInterface,
tracker: tracker,
);
case Coin.tezos:
return TezosWallet(
walletId: walletId,
walletName: walletName,
coin: coin,
secureStore: secureStorageInterface,
tracker: tracker,
);
case Coin.wownero:
return WowneroWallet(
walletId: walletId,
@ -285,15 +304,6 @@ abstract class CoinServiceAPI {
cachedClient: cachedClient,
tracker: tracker,
);
case Coin.stellarTestnet:
return StellarWallet(
walletId: walletId,
walletName: walletName,
coin: coin,
secureStore: secureStorageInterface,
tracker: tracker,
);
}
}
@ -348,7 +358,9 @@ abstract class CoinServiceAPI {
required int height,
});
Future<void> initializeNew();
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
);
Future<void> initializeExisting();
Future<void> exit();

View file

@ -1147,7 +1147,9 @@ class DogecoinWallet extends CoinServiceAPI
bool get isConnected => _isConnected;
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info);
@ -1157,7 +1159,7 @@ class DogecoinWallet extends CoinServiceAPI
}
await _prefs.init();
try {
await _generateNewWallet();
await _generateNewWallet(data);
} catch (e, s) {
Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s",
level: LogLevel.Fatal);
@ -1349,7 +1351,9 @@ class DogecoinWallet extends CoinServiceAPI
}
}
Future<void> _generateNewWallet() async {
Future<void> _generateNewWallet(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
if (!integrationTestFlag) {
@ -1383,12 +1387,20 @@ class DogecoinWallet extends CoinServiceAPI
throw Exception(
"Attempted to overwrite mnemonic on generate new wallet!");
}
final int strength;
if (data == null || data.wordCount == 12) {
strength = 128;
} else if (data.wordCount == 24) {
strength = 256;
} else {
throw Exception("Invalid word count");
}
await _secureStore.write(
key: '${_walletId}_mnemonic',
value: bip39.generateMnemonic(strength: 128));
value: bip39.generateMnemonic(strength: strength));
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: "",
value: data?.mnemonicPassphrase ?? "",
);
// Generate and add addresses

View file

@ -506,7 +506,9 @@ class ECashWallet extends CoinServiceAPI
}
}
Future<void> _generateNewWallet() async {
Future<void> _generateNewWallet(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
if (!integrationTestFlag) {
@ -544,10 +546,21 @@ class ECashWallet extends CoinServiceAPI
throw Exception(
"Attempted to overwrite mnemonic on generate new wallet!");
}
final int strength;
if (data == null || data.wordCount == 12) {
strength = 128;
} else if (data.wordCount == 24) {
strength = 256;
} else {
throw Exception("Invalid word count");
}
await _secureStore.write(
key: '${_walletId}_mnemonic',
value: bip39.generateMnemonic(strength: 128));
await _secureStore.write(key: '${_walletId}_mnemonicPassphrase', value: "");
value: bip39.generateMnemonic(strength: strength));
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: data?.mnemonicPassphrase ?? "",
);
const int startingIndex = 0;
const int receiveChain = 0;
@ -2778,7 +2791,9 @@ class ECashWallet extends CoinServiceAPI
bool get isConnected => _isConnected;
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info);
@ -2789,7 +2804,7 @@ class ECashWallet extends CoinServiceAPI
await _prefs.init();
try {
await _generateNewWallet();
await _generateNewWallet(data);
} catch (e, s) {
Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s",
level: LogLevel.Fatal);

View file

@ -766,7 +766,9 @@ class EpicCashWallet extends CoinServiceAPI
}
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
await _prefs.init();
await updateNode(false);
final mnemonic = await _getMnemonicList();
@ -1738,7 +1740,6 @@ class EpicCashWallet extends CoinServiceAPI
final isIncoming = (tx["tx_type"] == "TxReceived" ||
tx["tx_type"] == "TxReceivedCancelled");
final txn = isar_models.Transaction(
walletId: walletId,
txid: commitId ?? tx["id"].toString(),
@ -1763,7 +1764,9 @@ class EpicCashWallet extends CoinServiceAPI
otherData: tx['onChainNote'].toString(),
inputs: [],
outputs: [],
numberOfMessages: ((tx["numberOfMessages"] == null) ? 0 : tx["numberOfMessages"]) as int,
numberOfMessages: ((tx["numberOfMessages"] == null)
? 0
: tx["numberOfMessages"]) as int,
);
// txn.address =

View file

@ -310,7 +310,9 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance.log(
"Generating new ${coin.prettyName} wallet.",
level: LogLevel.Info,
@ -324,7 +326,7 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
await _prefs.init();
try {
await _generateNewWallet();
await _generateNewWallet(data);
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from initializeNew(): $e\n$s",
@ -338,7 +340,9 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
]);
}
Future<void> _generateNewWallet() async {
Future<void> _generateNewWallet(
({String mnemonicPassphrase, int wordCount})? data,
) async {
// Logging.instance
// .log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
// if (!integrationTestFlag) {
@ -366,14 +370,23 @@ class EthereumWallet extends CoinServiceAPI with WalletCache, WalletDB {
"Attempted to overwrite mnemonic on generate new wallet!");
}
final String mnemonic = bip39.generateMnemonic(strength: 128);
final int strength;
if (data == null || data.wordCount == 12) {
strength = 128;
} else if (data.wordCount == 24) {
strength = 256;
} else {
throw Exception("Invalid word count");
}
final String mnemonic = bip39.generateMnemonic(strength: strength);
final String passphrase = data?.mnemonicPassphrase ?? "";
await _secureStore.write(key: '${_walletId}_mnemonic', value: mnemonic);
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: "",
value: passphrase,
);
await _generateAndSaveAddress(mnemonic, "");
await _generateAndSaveAddress(mnemonic, passphrase);
Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info);
}

View file

@ -1875,7 +1875,9 @@ class FiroWallet extends CoinServiceAPI
}
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info);
@ -1886,7 +1888,7 @@ class FiroWallet extends CoinServiceAPI
await _prefs.init();
try {
await _generateNewWallet();
await _generateNewWallet(data);
} catch (e, s) {
Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s",
level: LogLevel.Fatal);
@ -2124,7 +2126,9 @@ class FiroWallet extends CoinServiceAPI
}
/// Generates initial wallet values such as mnemonic, chain (receive/change) arrays and indexes.
Future<void> _generateNewWallet() async {
Future<void> _generateNewWallet(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
if (!integrationTestFlag) {
@ -2158,12 +2162,20 @@ class FiroWallet extends CoinServiceAPI
longMutex = false;
throw Exception("Attempted to overwrite mnemonic on initialize new!");
}
final int strength;
if (data == null || data.wordCount == 12) {
strength = 128;
} else if (data.wordCount == 24) {
strength = 256;
} else {
throw Exception("Invalid word count");
}
await _secureStore.write(
key: '${_walletId}_mnemonic',
value: bip39.generateMnemonic(strength: 128));
value: bip39.generateMnemonic(strength: strength));
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: "",
value: data?.mnemonicPassphrase ?? "",
);
// Generate and add addresses to relevant arrays

View file

@ -1285,7 +1285,9 @@ class LitecoinWallet extends CoinServiceAPI
bool get isConnected => _isConnected;
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info);
@ -1296,7 +1298,7 @@ class LitecoinWallet extends CoinServiceAPI
await _prefs.init();
try {
await _generateNewWallet();
await _generateNewWallet(data);
} catch (e, s) {
Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s",
level: LogLevel.Fatal);
@ -1535,7 +1537,9 @@ class LitecoinWallet extends CoinServiceAPI
}
}
Future<void> _generateNewWallet() async {
Future<void> _generateNewWallet(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
if (!integrationTestFlag) {
@ -1570,12 +1574,20 @@ class LitecoinWallet extends CoinServiceAPI
throw Exception(
"Attempted to overwrite mnemonic on generate new wallet!");
}
final int strength;
if (data == null || data.wordCount == 12) {
strength = 128;
} else if (data.wordCount == 24) {
strength = 256;
} else {
throw Exception("Invalid word count");
}
await _secureStore.write(
key: '${_walletId}_mnemonic',
value: bip39.generateMnemonic(strength: 128));
value: bip39.generateMnemonic(strength: strength));
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: "",
value: data?.mnemonicPassphrase ?? "",
);
// Generate and add addresses to relevant arrays

View file

@ -180,7 +180,9 @@ class Manager with ChangeNotifier {
Future<bool> testNetworkConnection() =>
_currentWallet.testNetworkConnection();
Future<void> initializeNew() => _currentWallet.initializeNew();
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
_currentWallet.initializeNew(data);
Future<void> initializeExisting() => _currentWallet.initializeExisting();
Future<void> recoverFromMnemonic({
required String mnemonic,

View file

@ -307,7 +307,9 @@ class MoneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
await _prefs.init();
// this should never fail

View file

@ -1268,7 +1268,9 @@ class NamecoinWallet extends CoinServiceAPI
bool get isConnected => _isConnected;
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info);
@ -1279,7 +1281,7 @@ class NamecoinWallet extends CoinServiceAPI
await _prefs.init();
try {
await _generateNewWallet();
await _generateNewWallet(data);
} catch (e, s) {
Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s",
level: LogLevel.Fatal);
@ -1517,7 +1519,9 @@ class NamecoinWallet extends CoinServiceAPI
}
}
Future<void> _generateNewWallet() async {
Future<void> _generateNewWallet(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
if (!integrationTestFlag) {
@ -1544,12 +1548,20 @@ class NamecoinWallet extends CoinServiceAPI
throw Exception(
"Attempted to overwrite mnemonic on generate new wallet!");
}
final int strength;
if (data == null || data.wordCount == 12) {
strength = 128;
} else if (data.wordCount == 24) {
strength = 256;
} else {
throw Exception("Invalid word count");
}
await _secureStore.write(
key: '${_walletId}_mnemonic',
value: bip39.generateMnemonic(strength: 128));
value: bip39.generateMnemonic(strength: strength));
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: "",
value: data?.mnemonicPassphrase ?? "",
);
// Generate and add addresses to relevant arrays

View file

@ -607,7 +607,9 @@ class NanoWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
if ((await mnemonicString) != null || (await mnemonicPassphrase) != null) {
throw Exception(
"Attempted to overwrite mnemonic on generate new wallet!");

View file

@ -1195,7 +1195,9 @@ class ParticlWallet extends CoinServiceAPI
bool get isConnected => _isConnected;
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("Generating new ${coin.prettyName} wallet.", level: LogLevel.Info);
@ -1206,7 +1208,7 @@ class ParticlWallet extends CoinServiceAPI
await _prefs.init();
try {
await _generateNewWallet();
await _generateNewWallet(data);
} catch (e, s) {
Logging.instance.log("Exception rethrown from initializeNew(): $e\n$s",
level: LogLevel.Fatal);
@ -1432,7 +1434,9 @@ class ParticlWallet extends CoinServiceAPI
}
}
Future<void> _generateNewWallet() async {
Future<void> _generateNewWallet(
({String mnemonicPassphrase, int wordCount})? data,
) async {
Logging.instance
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
if (!integrationTestFlag) {
@ -1459,12 +1463,20 @@ class ParticlWallet extends CoinServiceAPI
throw Exception(
"Attempted to overwrite mnemonic on generate new wallet!");
}
final int strength;
if (data == null || data.wordCount == 12) {
strength = 128;
} else if (data.wordCount == 24) {
strength = 256;
} else {
throw Exception("Invalid word count");
}
await _secureStore.write(
key: '${_walletId}_mnemonic',
value: bip39.generateMnemonic(strength: 128));
value: bip39.generateMnemonic(strength: strength));
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: "",
value: data?.mnemonicPassphrase ?? "",
);
// Generate and add addresses to relevant arrays

View file

@ -1,6 +1,6 @@
import 'dart:async';
import 'package:http/http.dart' as http;
import 'package:bip39/bip39.dart' as bip39;
import 'package:isar/isar.dart';
import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/models/balance.dart' as SWBalance;
@ -28,6 +28,7 @@ import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/prefs.dart';
import 'package:stackwallet/utilities/test_stellar_node_connection.dart';
import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart';
import 'package:tuple/tuple.dart';
@ -53,20 +54,25 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
if (coin.name == "stellarTestnet") {
stellarSdk = StellarSDK.TESTNET;
if (coin.isTestNet) {
stellarNetwork = Network.TESTNET;
} else {
stellarSdk = StellarSDK.PUBLIC;
stellarNetwork = Network.PUBLIC;
}
_updateNode();
}
void _updateNode() {
_xlmNode = NodeService(secureStorageInterface: _secureStore)
.getPrimaryNodeFor(coin: coin) ??
DefaultNodes.getNodeFor(coin);
stellarSdk = StellarSDK("${_xlmNode!.host}:${_xlmNode!.port}");
}
late final TransactionNotificationTracker txTracker;
late SecureStorageInterface _secureStore;
// final StellarSDK stellarSdk = StellarSDK.PUBLIC;
@override
bool get isFavorite => _isFavorite ??= getCachedIsFavorite();
bool? _isFavorite;
@ -205,11 +211,12 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
transaction.sign(senderKeyPair, stellarNetwork);
try {
SubmitTransactionResponse response =
await stellarSdk.submitTransaction(transaction);
SubmitTransactionResponse response = await stellarSdk
.submitTransaction(transaction)
.onError((error, stackTrace) => throw (error.toString()));
if (!response.success) {
throw ("Unable to send transaction");
throw ("${response.extras?.resultCodes?.transactionResultCode}"
" ::: ${response.extras?.resultCodes?.operationsResultCodes}");
}
return response.hash!;
} catch (e, s) {
@ -232,32 +239,15 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
(await _currentReceivingAddress)?.value ?? await getAddressSW();
Future<int> getBaseFee() async {
// final nodeURI = Uri.parse("${getCurrentNode().host}:${getCurrentNode().port}");
final nodeURI = Uri.parse(getCurrentNode().host);
final httpClient = http.Client();
FeeStatsResponse fsp =
await FeeStatsRequestBuilder(httpClient, nodeURI).execute();
return int.parse(fsp.lastLedgerBaseFee);
var fees = await stellarSdk.feeStats.execute();
return int.parse(fees.lastLedgerBaseFee);
}
@override
Future<Amount> estimateFeeFor(Amount amount, int feeRate) async {
var baseFee = await getBaseFee();
int fee = 100;
switch (feeRate) {
case 0:
fee = baseFee * 10;
case 1:
case 2:
fee = baseFee * 50;
case 3:
fee = baseFee * 100;
case 4:
fee = baseFee * 200;
default:
fee = baseFee * 50;
}
return Amount(rawValue: BigInt.from(fee), fractionDigits: coin.decimals);
return Amount(
rawValue: BigInt.from(baseFee), fractionDigits: coin.decimals);
}
@override
@ -285,34 +275,74 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
@override
Future<FeeObject> get fees async {
// final nodeURI = Uri.parse("${getCurrentNode().host}:${getCurrentNode().port}");
final nodeURI = Uri.parse(getCurrentNode().host);
final httpClient = http.Client();
FeeStatsResponse fsp =
await FeeStatsRequestBuilder(httpClient, nodeURI).execute();
int fee = await getBaseFee();
return FeeObject(
numberOfBlocksFast: 0,
numberOfBlocksAverage: 0,
numberOfBlocksSlow: 0,
fast: int.parse(fsp.lastLedgerBaseFee) * 100,
medium: int.parse(fsp.lastLedgerBaseFee) * 50,
slow: int.parse(fsp.lastLedgerBaseFee) * 10);
numberOfBlocksFast: 10,
numberOfBlocksAverage: 10,
numberOfBlocksSlow: 10,
fast: fee,
medium: fee,
slow: fee);
}
@override
Future<void> fullRescan(
int maxUnusedAddressGap, int maxNumberOfIndexesToCheck) async {
await _prefs.init();
await updateTransactions();
await updateChainHeight();
await updateBalance();
int maxUnusedAddressGap,
int maxNumberOfIndexesToCheck,
) async {
try {
Logging.instance.log("Starting full rescan!", level: LogLevel.Info);
longMutex = true;
GlobalEventBus.instance.fire(
WalletSyncStatusChangedEvent(
WalletSyncStatus.syncing,
walletId,
coin,
),
);
final _mnemonic = await mnemonicString;
final _mnemonicPassphrase = await mnemonicPassphrase;
await db.deleteWalletBlockchainData(walletId);
await _recoverWalletFromBIP32SeedPhrase(
mnemonic: _mnemonic!,
mnemonicPassphrase: _mnemonicPassphrase!,
isRescan: true,
);
await refresh();
Logging.instance.log("Full rescan complete!", level: LogLevel.Info);
GlobalEventBus.instance.fire(
WalletSyncStatusChangedEvent(
WalletSyncStatus.synced,
walletId,
coin,
),
);
} catch (e, s) {
GlobalEventBus.instance.fire(
WalletSyncStatusChangedEvent(
WalletSyncStatus.unableToSync,
walletId,
coin,
),
);
Logging.instance.log(
"Exception rethrown from fullRescan(): $e\n$s",
level: LogLevel.Error,
);
rethrow;
} finally {
longMutex = false;
}
}
@override
Future<bool> generateNewAddress() {
// TODO: implement generateNewAddress
// not used for stellar(?)
throw UnimplementedError();
}
@ -326,7 +356,9 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
@override
Future<void> initializeNew() async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
if ((await mnemonicString) != null || (await mnemonicPassphrase) != null) {
throw Exception(
"Attempted to overwrite mnemonic on generate new wallet!");
@ -334,11 +366,26 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
await _prefs.init();
String mnemonic = await Wallet.generate24WordsMnemonic();
final int strength;
if (data == null || data.wordCount == 12) {
strength = 128;
} else if (data.wordCount == 24) {
strength = 256;
} else {
throw Exception("Invalid word count");
}
final String mnemonic = bip39.generateMnemonic(strength: strength);
final String passphrase = data?.mnemonicPassphrase ?? "";
await _secureStore.write(key: '${_walletId}_mnemonic', value: mnemonic);
await _secureStore.write(key: '${_walletId}_mnemonicPassphrase', value: "");
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: passphrase,
);
Wallet wallet = await Wallet.from(mnemonic);
Wallet wallet = await Wallet.from(
mnemonic,
passphrase: passphrase,
);
KeyPair keyPair = await wallet.getKeyPair(index: 0);
String address = keyPair.accountId;
String secretSeed =
@ -428,44 +475,87 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
}
@override
Future<void> recoverFromMnemonic(
{required String mnemonic,
String? mnemonicPassphrase,
required int maxUnusedAddressGap,
required int maxNumberOfIndexesToCheck,
required int height}) async {
if ((await mnemonicString) != null ||
(await this.mnemonicPassphrase) != null) {
throw Exception("Attempted to overwrite mnemonic on restore!");
}
var wallet = await Wallet.from(mnemonic);
var keyPair = await wallet.getKeyPair(index: 0);
var address = keyPair.accountId;
var secretSeed = keyPair.secretSeed;
await _secureStore.write(
key: '${_walletId}_mnemonic', value: mnemonic.trim());
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: mnemonicPassphrase ?? "",
Future<void> _recoverWalletFromBIP32SeedPhrase({
required String mnemonic,
required String mnemonicPassphrase,
bool isRescan = false,
}) async {
final Wallet wallet = await Wallet.from(
mnemonic,
passphrase: mnemonicPassphrase,
);
final KeyPair keyPair = await wallet.getKeyPair(index: 0);
final String address = keyPair.accountId;
String secretSeed =
keyPair.secretSeed; //This will be required for sending a tx
await _secureStore.write(
key: '${_walletId}_secretSeed',
value: secretSeed,
);
await _secureStore.write(key: '${_walletId}_secretSeed', value: secretSeed);
final swAddress = SWAddress.Address(
walletId: walletId,
value: address,
publicKey: keyPair.publicKey,
derivationIndex: 0,
derivationPath: null,
type: SWAddress.AddressType.unknown, // TODO: set type
subType: SWAddress.AddressSubType.unknown);
walletId: walletId,
value: address,
publicKey: keyPair.publicKey,
derivationIndex: 0,
derivationPath: null,
type: SWAddress.AddressType.unknown,
subType: SWAddress.AddressSubType.unknown,
);
await db.putAddress(swAddress);
if (isRescan) {
await db.updateOrPutAddresses([swAddress]);
} else {
await db.putAddress(swAddress);
}
}
await Future.wait(
[updateCachedId(walletId), updateCachedIsFavorite(false)]);
bool longMutex = false;
@override
Future<void> recoverFromMnemonic({
required String mnemonic,
String? mnemonicPassphrase,
required int maxUnusedAddressGap,
required int maxNumberOfIndexesToCheck,
required int height,
}) async {
longMutex = true;
try {
if ((await mnemonicString) != null ||
(await this.mnemonicPassphrase) != null) {
throw Exception("Attempted to overwrite mnemonic on restore!");
}
await _secureStore.write(
key: '${_walletId}_mnemonic',
value: mnemonic.trim(),
);
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: mnemonicPassphrase ?? "",
);
await _recoverWalletFromBIP32SeedPhrase(
mnemonic: mnemonic,
mnemonicPassphrase: mnemonicPassphrase ?? "",
isRescan: false,
);
await Future.wait([
updateCachedId(walletId),
updateCachedIsFavorite(false),
]);
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from recoverFromMnemonic(): $e\n$s",
level: LogLevel.Error);
rethrow;
} finally {
longMutex = false;
}
}
Future<void> updateChainHeight() async {
@ -495,13 +585,6 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
if (response is PaymentOperationResponse) {
PaymentOperationResponse por = response;
Logging.instance.log(
"ALL TRANSACTIONS IS ${por.transactionSuccessful}",
level: LogLevel.Info);
Logging.instance.log("THIS TX HASH IS ${por.transactionHash}",
level: LogLevel.Info);
SWTransaction.TransactionType type;
if (por.sourceAccount == await getAddressSW()) {
type = SWTransaction.TransactionType.outgoing;
@ -628,6 +711,7 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
Logging.instance.log(
"Exception rethrown from updateTransactions(): $e\n$s",
level: LogLevel.Error);
rethrow;
}
}
@ -665,6 +749,7 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
"ERROR GETTING BALANCE $e\n$s",
level: LogLevel.Info,
);
rethrow;
}
}
@ -739,9 +824,8 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
int get storedChainHeight => getCachedChainHeight();
@override
Future<bool> testNetworkConnection() {
// TODO: implement testNetworkConnection
throw UnimplementedError();
Future<bool> testNetworkConnection() async {
return await testStellarNodeConnection(_xlmNode!.host, _xlmNode!.port);
}
@override
@ -750,10 +834,7 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
@override
Future<void> updateNode(bool shouldRefresh) async {
_xlmNode = NodeService(secureStorageInterface: _secureStore)
.getPrimaryNodeFor(coin: coin) ??
DefaultNodes.getNodeFor(coin);
_updateNode();
if (shouldRefresh) {
unawaited(refresh());
}
@ -795,7 +876,7 @@ class StellarWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
@override
// TODO: implement utxos
// not used
Future<List<UTXO>> get utxos => throw UnimplementedError();
@override

View file

@ -0,0 +1,741 @@
import 'dart:async';
import 'dart:convert';
import 'package:decimal/decimal.dart';
import 'package:http/http.dart';
import 'package:isar/isar.dart';
import 'package:stackwallet/db/isar/main_db.dart';
import 'package:stackwallet/models/balance.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/address.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/transaction.dart';
import 'package:stackwallet/models/isar/models/blockchain_data/utxo.dart';
import 'package:stackwallet/models/node_model.dart';
import 'package:stackwallet/models/paymint/fee_object_model.dart';
import 'package:stackwallet/services/coins/coin_service.dart';
import 'package:stackwallet/services/event_bus/events/global/node_connection_status_changed_event.dart';
import 'package:stackwallet/services/event_bus/events/global/updated_in_background_event.dart';
import 'package:stackwallet/services/event_bus/events/global/wallet_sync_status_changed_event.dart';
import 'package:stackwallet/services/event_bus/global_event_bus.dart';
import 'package:stackwallet/services/mixins/wallet_cache.dart';
import 'package:stackwallet/services/mixins/wallet_db.dart';
import 'package:stackwallet/services/node_service.dart';
import 'package:stackwallet/services/transaction_notification_tracker.dart';
import 'package:stackwallet/utilities/amount/amount.dart';
import 'package:stackwallet/utilities/constants.dart';
import 'package:stackwallet/utilities/default_nodes.dart';
import 'package:stackwallet/utilities/enums/coin_enum.dart';
import 'package:stackwallet/utilities/enums/fee_rate_type_enum.dart';
import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart';
import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/prefs.dart';
import 'package:tezart/tezart.dart';
import 'package:tuple/tuple.dart';
const int MINIMUM_CONFIRMATIONS = 1;
const int _gasLimit = 10200;
class TezosWallet extends CoinServiceAPI with WalletCache, WalletDB {
TezosWallet({
required String walletId,
required String walletName,
required Coin coin,
required SecureStorageInterface secureStore,
required TransactionNotificationTracker tracker,
MainDB? mockableOverride,
}) {
txTracker = tracker;
_walletId = walletId;
_walletName = walletName;
_coin = coin;
_secureStore = secureStore;
initCache(walletId, coin);
initWalletDB(mockableOverride: mockableOverride);
}
NodeModel? _xtzNode;
NodeModel getCurrentNode() {
return _xtzNode ??
NodeService(secureStorageInterface: _secureStore)
.getPrimaryNodeFor(coin: Coin.tezos) ??
DefaultNodes.getNodeFor(Coin.tezos);
}
Future<Keystore> getKeystore() async {
return Keystore.fromMnemonic((await mnemonicString).toString());
}
@override
String get walletId => _walletId;
late String _walletId;
@override
String get walletName => _walletName;
late String _walletName;
@override
set walletName(String name) => _walletName = name;
@override
set isFavorite(bool markFavorite) {
_isFavorite = markFavorite;
updateCachedIsFavorite(markFavorite);
}
@override
bool get isFavorite => _isFavorite ??= getCachedIsFavorite();
bool? _isFavorite;
@override
Coin get coin => _coin;
late Coin _coin;
late SecureStorageInterface _secureStore;
late final TransactionNotificationTracker txTracker;
final _prefs = Prefs.instance;
Timer? timer;
bool _shouldAutoSync = false;
Timer? _networkAliveTimer;
@override
bool get shouldAutoSync => _shouldAutoSync;
@override
set shouldAutoSync(bool shouldAutoSync) {
if (_shouldAutoSync != shouldAutoSync) {
_shouldAutoSync = shouldAutoSync;
if (!shouldAutoSync) {
timer?.cancel();
timer = null;
stopNetworkAlivePinging();
} else {
startNetworkAlivePinging();
refresh();
}
}
}
void startNetworkAlivePinging() {
// call once on start right away
_periodicPingCheck();
// then periodically check
_networkAliveTimer = Timer.periodic(
Constants.networkAliveTimerDuration,
(_) async {
_periodicPingCheck();
},
);
}
void stopNetworkAlivePinging() {
_networkAliveTimer?.cancel();
_networkAliveTimer = null;
}
void _periodicPingCheck() async {
bool hasNetwork = await testNetworkConnection();
if (_isConnected != hasNetwork) {
NodeConnectionStatus status = hasNetwork
? NodeConnectionStatus.connected
: NodeConnectionStatus.disconnected;
GlobalEventBus.instance.fire(
NodeConnectionStatusChangedEvent(
status,
walletId,
coin,
),
);
_isConnected = hasNetwork;
if (hasNetwork) {
unawaited(refresh());
}
}
}
@override
Balance get balance => _balance ??= getCachedBalance();
Balance? _balance;
@override
Future<Map<String, dynamic>> prepareSend(
{required String address,
required Amount amount,
Map<String, dynamic>? args}) async {
try {
if (amount.decimals != coin.decimals) {
throw Exception("Amount decimals do not match coin decimals!");
}
var fee = int.parse((await estimateFeeFor(
amount, (args!["feeRate"] as FeeRateType).index))
.raw
.toString());
Map<String, dynamic> txData = {
"fee": fee,
"address": address,
"recipientAmt": amount,
};
return Future.value(txData);
} catch (e) {
return Future.error(e);
}
}
@override
Future<String> confirmSend({required Map<String, dynamic> txData}) async {
try {
final amount = txData["recipientAmt"] as Amount;
final amountInMicroTez = amount.decimal * Decimal.fromInt(1000000);
final microtezToInt = int.parse(amountInMicroTez.toString());
final int feeInMicroTez = int.parse(txData["fee"].toString());
final String destinationAddress = txData["address"] as String;
final secretKey =
Keystore.fromMnemonic((await mnemonicString)!).secretKey;
Logging.instance.log(secretKey, level: LogLevel.Info);
final sourceKeyStore = Keystore.fromSecretKey(secretKey);
final client = TezartClient(getCurrentNode().host);
int? sendAmount = microtezToInt;
int gasLimit = _gasLimit;
int thisFee = feeInMicroTez;
if (balance.spendable == txData["recipientAmt"] as Amount) {
//Fee guides for emptying a tz account
// https://github.com/TezTech/eztz/blob/master/PROTO_004_FEES.md
thisFee = thisFee + 32;
sendAmount = microtezToInt - thisFee;
gasLimit = _gasLimit + 320;
}
final operation = await client.transferOperation(
source: sourceKeyStore,
destination: destinationAddress,
amount: sendAmount,
customFee: feeInMicroTez,
customGasLimit: gasLimit);
await operation.executeAndMonitor();
return operation.result.id as String;
} catch (e) {
Logging.instance.log(e.toString(), level: LogLevel.Error);
return Future.error(e);
}
}
@override
Future<String> get currentReceivingAddress async {
var mneString = await mnemonicString;
if (mneString == null) {
throw Exception("No mnemonic found!");
}
return Future.value((Keystore.fromMnemonic(mneString)).address);
}
@override
Future<Amount> estimateFeeFor(Amount amount, int feeRate) async {
var api = "https://api.tzstats.com/series/op?start_date=today&collapse=1d";
var response = jsonDecode((await get(Uri.parse(api))).body)[0];
double totalFees = response[4] as double;
int totalTxs = response[8] as int;
int feePerTx = (totalFees / totalTxs * 1000000).floor();
return Amount(
rawValue: BigInt.from(feePerTx),
fractionDigits: coin.decimals,
);
}
@override
Future<void> exit() {
_hasCalledExit = true;
return Future.value();
}
@override
Future<FeeObject> get fees async {
var api = "https://api.tzstats.com/series/op?start_date=today&collapse=10d";
var response = jsonDecode((await get(Uri.parse(api))).body);
double totalFees = response[0][4] as double;
int totalTxs = response[0][8] as int;
int feePerTx = (totalFees / totalTxs * 1000000).floor();
Logging.instance.log("feePerTx:$feePerTx", level: LogLevel.Info);
// TODO: fix numberOfBlocks - Since there is only one fee no need to set blocks
return FeeObject(
numberOfBlocksFast: 10,
numberOfBlocksAverage: 10,
numberOfBlocksSlow: 10,
fast: feePerTx,
medium: feePerTx,
slow: feePerTx,
);
}
@override
Future<bool> generateNewAddress() {
// TODO: implement generateNewAddress
throw UnimplementedError();
}
@override
bool get hasCalledExit => _hasCalledExit;
bool _hasCalledExit = false;
@override
Future<void> initializeExisting() async {
await _prefs.init();
}
@override
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) async {
if ((await mnemonicString) != null || (await mnemonicPassphrase) != null) {
throw Exception(
"Attempted to overwrite mnemonic on generate new wallet!");
}
await _prefs.init();
var newKeystore = Keystore.random();
await _secureStore.write(
key: '${_walletId}_mnemonic',
value: newKeystore.mnemonic,
);
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: "",
);
final address = Address(
walletId: walletId,
value: newKeystore.address,
publicKey: [],
derivationIndex: 0,
derivationPath: null,
type: AddressType.unknown,
subType: AddressSubType.receiving,
);
await db.putAddress(address);
await Future.wait([
updateCachedId(walletId),
updateCachedIsFavorite(false),
]);
}
@override
bool get isConnected => _isConnected;
bool _isConnected = false;
@override
bool get isRefreshing => refreshMutex;
bool refreshMutex = false;
@override
// TODO: implement maxFee
Future<int> get maxFee => throw UnimplementedError();
@override
Future<List<String>> get mnemonic async {
final mnemonic = await mnemonicString;
final mnemonicPassphrase = await this.mnemonicPassphrase;
if (mnemonic == null) {
throw Exception("No mnemonic found!");
}
if (mnemonicPassphrase == null) {
throw Exception("No mnemonic passphrase found!");
}
return mnemonic.split(" ");
}
@override
Future<String?> get mnemonicPassphrase =>
_secureStore.read(key: '${_walletId}_mnemonicPassphrase');
@override
Future<String?> get mnemonicString =>
_secureStore.read(key: '${_walletId}_mnemonic');
Future<void> _recoverWalletFromSeedPhrase({
required String mnemonic,
required String mnemonicPassphrase,
bool isRescan = false,
}) async {
final keystore = Keystore.fromMnemonic(
mnemonic,
password: mnemonicPassphrase,
);
final address = Address(
walletId: walletId,
value: keystore.address,
publicKey: [],
derivationIndex: 0,
derivationPath: null,
type: AddressType.unknown,
subType: AddressSubType.receiving,
);
if (isRescan) {
await db.updateOrPutAddresses([address]);
} else {
await db.putAddress(address);
}
}
bool longMutex = false;
@override
Future<void> fullRescan(
int maxUnusedAddressGap,
int maxNumberOfIndexesToCheck,
) async {
try {
Logging.instance.log("Starting full rescan!", level: LogLevel.Info);
longMutex = true;
GlobalEventBus.instance.fire(
WalletSyncStatusChangedEvent(
WalletSyncStatus.syncing,
walletId,
coin,
),
);
final _mnemonic = await mnemonicString;
final _mnemonicPassphrase = await mnemonicPassphrase;
await db.deleteWalletBlockchainData(walletId);
await _recoverWalletFromSeedPhrase(
mnemonic: _mnemonic!,
mnemonicPassphrase: _mnemonicPassphrase!,
isRescan: true,
);
await refresh();
Logging.instance.log("Full rescan complete!", level: LogLevel.Info);
GlobalEventBus.instance.fire(
WalletSyncStatusChangedEvent(
WalletSyncStatus.synced,
walletId,
coin,
),
);
} catch (e, s) {
GlobalEventBus.instance.fire(
WalletSyncStatusChangedEvent(
WalletSyncStatus.unableToSync,
walletId,
coin,
),
);
Logging.instance.log(
"Exception rethrown from fullRescan(): $e\n$s",
level: LogLevel.Error,
);
rethrow;
} finally {
longMutex = false;
}
}
@override
Future<void> recoverFromMnemonic({
required String mnemonic,
String? mnemonicPassphrase,
required int maxUnusedAddressGap,
required int maxNumberOfIndexesToCheck,
required int height,
}) async {
longMutex = true;
try {
if ((await mnemonicString) != null ||
(await this.mnemonicPassphrase) != null) {
throw Exception("Attempted to overwrite mnemonic on restore!");
}
await _secureStore.write(
key: '${_walletId}_mnemonic', value: mnemonic.trim());
await _secureStore.write(
key: '${_walletId}_mnemonicPassphrase',
value: mnemonicPassphrase ?? "",
);
await _recoverWalletFromSeedPhrase(
mnemonic: mnemonic,
mnemonicPassphrase: mnemonicPassphrase ?? "",
isRescan: false,
);
await Future.wait([
updateCachedId(walletId),
updateCachedIsFavorite(false),
]);
await refresh();
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from recoverFromMnemonic(): $e\n$s",
level: LogLevel.Error);
rethrow;
} finally {
longMutex = false;
}
}
Future<void> updateBalance() async {
try {
String balanceCall = "https://api.mainnet.tzkt.io/v1/accounts/"
"${await currentReceivingAddress}/balance";
var response = jsonDecode(
await get(Uri.parse(balanceCall)).then((value) => value.body));
Amount balanceInAmount = Amount(
rawValue: BigInt.parse(response.toString()),
fractionDigits: coin.decimals);
_balance = Balance(
total: balanceInAmount,
spendable: balanceInAmount,
blockedTotal:
Amount(rawValue: BigInt.parse("0"), fractionDigits: coin.decimals),
pendingSpendable:
Amount(rawValue: BigInt.parse("0"), fractionDigits: coin.decimals),
);
await updateCachedBalance(_balance!);
} catch (e, s) {
Logging.instance
.log("ERROR GETTING BALANCE ${e.toString()}", level: LogLevel.Error);
}
}
Future<void> updateTransactions() async {
String transactionsCall = "https://api.mainnet.tzkt.io/v1/accounts/"
"${await currentReceivingAddress}/operations";
var response = jsonDecode(
await get(Uri.parse(transactionsCall)).then((value) => value.body));
List<Tuple2<Transaction, Address>> txs = [];
for (var tx in response as List) {
if (tx["type"] == "transaction") {
TransactionType txType;
final String myAddress = await currentReceivingAddress;
final String senderAddress = tx["sender"]["address"] as String;
final String targetAddress = tx["target"]["address"] as String;
if (senderAddress == myAddress && targetAddress == myAddress) {
txType = TransactionType.sentToSelf;
} else if (senderAddress == myAddress) {
txType = TransactionType.outgoing;
} else if (targetAddress == myAddress) {
txType = TransactionType.incoming;
} else {
txType = TransactionType.unknown;
}
var theTx = Transaction(
walletId: walletId,
txid: tx["hash"].toString(),
timestamp: DateTime.parse(tx["timestamp"].toString())
.toUtc()
.millisecondsSinceEpoch ~/
1000,
type: txType,
subType: TransactionSubType.none,
amount: tx["amount"] as int,
amountString: Amount(
rawValue:
BigInt.parse((tx["amount"] as int).toInt().toString()),
fractionDigits: coin.decimals)
.toJsonString(),
fee: tx["bakerFee"] as int,
height: int.parse(tx["level"].toString()),
isCancelled: false,
isLelantus: false,
slateId: "",
otherData: "",
inputs: [],
outputs: [],
nonce: 0,
numberOfMessages: null,
);
final AddressSubType subType;
switch (txType) {
case TransactionType.incoming:
case TransactionType.sentToSelf:
subType = AddressSubType.receiving;
break;
case TransactionType.outgoing:
case TransactionType.unknown:
subType = AddressSubType.unknown;
break;
}
final theAddress = Address(
walletId: walletId,
value: targetAddress,
publicKey: [],
derivationIndex: 0,
derivationPath: null,
type: AddressType.unknown,
subType: subType,
);
txs.add(Tuple2(theTx, theAddress));
}
}
Logging.instance.log("Transactions: $txs", level: LogLevel.Info);
await db.addNewTransactionData(txs, walletId);
}
Future<void> updateChainHeight() async {
try {
var api = "${getCurrentNode().host}/chains/main/blocks/head/header/shell";
var jsonParsedResponse =
jsonDecode(await get(Uri.parse(api)).then((value) => value.body));
final int intHeight = int.parse(jsonParsedResponse["level"].toString());
Logging.instance.log("Chain height: $intHeight", level: LogLevel.Info);
await updateCachedChainHeight(intHeight);
} catch (e, s) {
Logging.instance
.log("GET CHAIN HEIGHT ERROR ${e.toString()}", level: LogLevel.Error);
}
}
@override
Future<void> refresh() async {
if (refreshMutex) {
Logging.instance.log(
"$walletId $walletName refreshMutex denied",
level: LogLevel.Info,
);
return;
} else {
refreshMutex = true;
}
try {
GlobalEventBus.instance.fire(
WalletSyncStatusChangedEvent(
WalletSyncStatus.syncing,
walletId,
coin,
),
);
await updateChainHeight();
await updateBalance();
await updateTransactions();
GlobalEventBus.instance.fire(
WalletSyncStatusChangedEvent(
WalletSyncStatus.synced,
walletId,
coin,
),
);
if (shouldAutoSync) {
timer ??= Timer.periodic(const Duration(seconds: 30), (timer) async {
Logging.instance.log(
"Periodic refresh check for $walletId $walletName in object instance: $hashCode",
level: LogLevel.Info);
await refresh();
GlobalEventBus.instance.fire(
UpdatedInBackgroundEvent(
"New data found in $walletId $walletName in background!",
walletId,
),
);
});
}
} catch (e, s) {
Logging.instance.log(
"Failed to refresh stellar wallet $walletId: '$walletName': $e\n$s",
level: LogLevel.Warning,
);
GlobalEventBus.instance.fire(
WalletSyncStatusChangedEvent(
WalletSyncStatus.unableToSync,
walletId,
coin,
),
);
}
refreshMutex = false;
}
@override
int get storedChainHeight => getCachedChainHeight();
@override
Future<bool> testNetworkConnection() async {
try {
await get(Uri.parse(
"${getCurrentNode().host}:${getCurrentNode().port}/chains/main/blocks/head/header/shell"));
return true;
} catch (e) {
return false;
}
}
@override
Future<List<Transaction>> get transactions =>
db.getTransactions(walletId).findAll();
@override
Future<void> updateNode(bool shouldRefresh) async {
_xtzNode = NodeService(secureStorageInterface: _secureStore)
.getPrimaryNodeFor(coin: coin) ??
DefaultNodes.getNodeFor(coin);
if (shouldRefresh) {
await refresh();
}
}
@override
Future<void> updateSentCachedTxData(Map<String, dynamic> txData) async {
final transaction = Transaction(
walletId: walletId,
txid: txData["txid"] as String,
timestamp: DateTime.now().millisecondsSinceEpoch ~/ 1000,
type: TransactionType.outgoing,
subType: TransactionSubType.none,
// precision may be lost here hence the following amountString
amount: (txData["recipientAmt"] as Amount).raw.toInt(),
amountString: (txData["recipientAmt"] as Amount).toJsonString(),
fee: txData["fee"] as int,
height: null,
isCancelled: false,
isLelantus: false,
otherData: null,
slateId: null,
nonce: null,
inputs: [],
outputs: [],
numberOfMessages: null,
);
final address = txData["address"] is String
? await db.getAddress(walletId, txData["address"] as String)
: null;
await db.addNewTransactionData(
[
Tuple2(transaction, address),
],
walletId,
);
}
@override
// TODO: implement utxos
Future<List<UTXO>> get utxos => throw UnimplementedError();
@override
bool validateAddress(String address) {
return RegExp(r"^tz[1-9A-HJ-NP-Za-km-z]{34}$").hasMatch(address);
}
}

View file

@ -333,7 +333,10 @@ class WowneroWallet extends CoinServiceAPI with WalletCache, WalletDB {
}
@override
Future<void> initializeNew({int seedWordsLength = 14}) async {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data, {
int seedWordsLength = 14,
}) async {
await _prefs.init();
// this should never fail

View file

@ -96,12 +96,12 @@ class PriceAPI {
}
Map<Coin, Tuple2<Decimal, double>> result = {};
try {
final uri =
Uri.parse("https://api.coingecko.com/api/v3/coins/markets?vs_currency"
"=${baseCurrency.toLowerCase()}"
"&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin,"
"bitcoin-cash,namecoin,wownero,ethereum,particl,nano,banano,stellar"
"&order=market_cap_desc&per_page=50&page=1&sparkline=false");
final uri = Uri.parse(
"https://api.coingecko.com/api/v3/coins/markets?vs_currency"
"=${baseCurrency.toLowerCase()}"
"&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin,"
"bitcoin-cash,namecoin,wownero,ethereum,particl,nano,banano,stellar,tezos"
"&order=market_cap_desc&per_page=50&page=1&sparkline=false");
final coinGeckoResponse = await client.get(
uri,

View file

@ -31,6 +31,7 @@ class CoinThemeColorDefault {
Color get stellar => const Color(0xFF6600FF);
Color get nano => const Color(0xFF209CE9);
Color get banano => const Color(0xFFFBDD11);
Color get tezos => const Color(0xFF0F61FF);
Color forCoin(Coin coin) {
switch (coin) {
@ -70,6 +71,8 @@ class CoinThemeColorDefault {
return nano;
case Coin.banano:
return banano;
case Coin.tezos:
return tezos;
}
}
}

View file

@ -1714,6 +1714,8 @@ class StackColors extends ThemeExtension<StackColors> {
return _coin.nano;
case Coin.banano:
return _coin.banano;
case Coin.tezos:
return _coin.tezos;
}
}

View file

@ -111,6 +111,8 @@ class AddressUtils {
return NanoAccounts.isValid(NanoAccountType.NANO, address);
case Coin.banano:
return NanoAccounts.isValid(NanoAccountType.BANANO, address);
case Coin.tezos:
return RegExp(r"^tz[1-9A-HJ-NP-Za-km-z]{34}$").hasMatch(address);
case Coin.bitcoinTestNet:
return Address.validateAddress(address, testnet);
case Coin.litecoinTestNet:

View file

@ -1,6 +1,6 @@
/*
/*
* This file is part of Stack Wallet.
*
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
@ -52,6 +52,7 @@ enum AmountUnit {
case Coin.epicCash:
case Coin.stellar: // TODO: check if this is correct
case Coin.stellarTestnet:
case Coin.tezos:
return AmountUnit.values.sublist(0, 4);
case Coin.monero:

View file

@ -1,6 +1,6 @@
/*
/*
* This file is part of Stack Wallet.
*
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
@ -62,6 +62,8 @@ Uri getDefaultBlockExplorerUrlFor({
return Uri.parse("https://www.bananolooker.com/block/$txid");
case Coin.stellarTestnet:
return Uri.parse("https://testnet.stellarchain.io/transactions/$txid");
case Coin.tezos:
return Uri.parse("https://tzstats.com/$txid");
}
}

View file

@ -1,6 +1,6 @@
/*
/*
* This file is part of Stack Wallet.
*
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
@ -34,7 +34,6 @@ abstract class Constants {
// just use enable exchange flag
// static bool enableBuy = enableExchange;
// // true; // true for development,
static final BigInt _satsPerCoinECash = BigInt.from(100);
static final BigInt _satsPerCoinEthereum = BigInt.from(1000000000000000000);
static final BigInt _satsPerCoinMonero = BigInt.from(1000000000000);
@ -43,8 +42,10 @@ abstract class Constants {
BigInt.parse("1000000000000000000000000000000"); // 1*10^30
static final BigInt _satsPerCoinBanano =
BigInt.parse("100000000000000000000000000000"); // 1*10^29
static final BigInt _satsPerCoinStellar = BigInt.from(10000000); // https://developers.stellar.org/docs/fundamentals-and-concepts/stellar-data-structures/assets#amount-precision
static final BigInt _satsPerCoinStellar = BigInt.from(
10000000); // https://developers.stellar.org/docs/fundamentals-and-concepts/stellar-data-structures/assets#amount-precision
static final BigInt _satsPerCoin = BigInt.from(100000000);
static final BigInt _satsPerCoinTezos = BigInt.from(1000000);
static const int _decimalPlaces = 8;
static const int _decimalPlacesNano = 30;
static const int _decimalPlacesBanano = 29;
@ -53,6 +54,7 @@ abstract class Constants {
static const int _decimalPlacesEthereum = 18;
static const int _decimalPlacesECash = 2;
static const int _decimalPlacesStellar = 7;
static const int _decimalPlacesTezos = 6;
static const int notificationsMax = 0xFFFFFFFF;
static const Duration networkAliveTimerDuration = Duration(seconds: 10);
@ -102,6 +104,9 @@ abstract class Constants {
case Coin.stellar:
case Coin.stellarTestnet:
return _satsPerCoinStellar;
case Coin.tezos:
return _satsPerCoinTezos;
}
}
@ -143,6 +148,9 @@ abstract class Constants {
case Coin.stellar:
case Coin.stellarTestnet:
return _decimalPlacesStellar;
case Coin.tezos:
return _decimalPlacesTezos;
}
}
@ -172,6 +180,8 @@ abstract class Constants {
case Coin.banano:
values.addAll([24, 12]);
break;
case Coin.tezos:
values.addAll([24, 12]);
case Coin.monero:
values.addAll([25]);
@ -230,6 +240,9 @@ abstract class Constants {
case Coin.stellar:
case Coin.stellarTestnet:
return 5;
case Coin.tezos:
return 60;
}
}
@ -259,6 +272,7 @@ abstract class Constants {
case Coin.banano:
case Coin.stellar:
case Coin.stellarTestnet:
case Coin.tezos:
return 24;
case Coin.monero:

View file

@ -1,6 +1,6 @@
/*
/*
* This file is part of Stack Wallet.
*
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
@ -191,8 +191,19 @@ abstract class DefaultNodes {
enabled: true,
coinName: Coin.stellar.name,
isFailover: true,
isDown: false
);
isDown: false);
static NodeModel get tezos => NodeModel(
// TODO: Change this to stack wallet one
host: "https://mainnet.api.tez.ie",
port: 443,
name: defaultName,
id: _nodeId(Coin.tezos),
useSSL: true,
enabled: true,
coinName: Coin.tezos.name,
isFailover: true,
isDown: false);
static NodeModel get nano => NodeModel(
host: "https://rainstorm.city/api",
@ -277,16 +288,16 @@ abstract class DefaultNodes {
);
static NodeModel get stellarTestnet => NodeModel(
host: "https://horizon-testnet.stellar.org/",
port: 50022,
name: defaultName,
id: _nodeId(Coin.stellarTestnet),
useSSL: true,
enabled: true,
coinName: Coin.stellarTestnet.name,
isFailover: true,
isDown: false,
);
host: "https://horizon-testnet.stellar.org/",
port: 50022,
name: defaultName,
id: _nodeId(Coin.stellarTestnet),
useSSL: true,
enabled: true,
coinName: Coin.stellarTestnet.name,
isFailover: true,
isDown: false,
);
static NodeModel getNodeFor(Coin coin) {
switch (coin) {
@ -335,6 +346,9 @@ abstract class DefaultNodes {
case Coin.banano:
return banano;
case Coin.tezos:
return tezos;
case Coin.bitcoinTestNet:
return bitcoinTestnet;

View file

@ -1,6 +1,6 @@
/*
/*
* This file is part of Stack Wallet.
*
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
@ -28,6 +28,7 @@ import 'package:stackwallet/services/coins/nano/nano_wallet.dart' as nano;
import 'package:stackwallet/services/coins/particl/particl_wallet.dart'
as particl;
import 'package:stackwallet/services/coins/stellar/stellar_wallet.dart' as xlm;
import 'package:stackwallet/services/coins/tezos/tezos_wallet.dart' as tezos;
import 'package:stackwallet/services/coins/wownero/wownero_wallet.dart' as wow;
import 'package:stackwallet/utilities/constants.dart';
@ -46,6 +47,7 @@ enum Coin {
nano,
particl,
stellar,
tezos,
wownero,
///
@ -61,7 +63,7 @@ enum Coin {
stellarTestnet,
}
final int kTestNetCoinCount = 4; // Util.isDesktop ? 5 : 4;
final int kTestNetCoinCount = 5; // Util.isDesktop ? 5 : 4;
// remove firotestnet for now
extension CoinExt on Coin {
@ -89,6 +91,8 @@ extension CoinExt on Coin {
return "Particl";
case Coin.stellar:
return "Stellar";
case Coin.tezos:
return "Tezos";
case Coin.wownero:
return "Wownero";
case Coin.namecoin:
@ -136,6 +140,8 @@ extension CoinExt on Coin {
return "PART";
case Coin.stellar:
return "XLM";
case Coin.tezos:
return "XTZ";
case Coin.wownero:
return "WOW";
case Coin.namecoin:
@ -184,6 +190,8 @@ extension CoinExt on Coin {
return "particl";
case Coin.stellar:
return "stellar";
case Coin.tezos:
return "tezos";
case Coin.wownero:
return "wownero";
case Coin.namecoin:
@ -227,6 +235,7 @@ extension CoinExt on Coin {
case Coin.epicCash:
case Coin.ethereum:
case Coin.monero:
case Coin.tezos:
case Coin.wownero:
case Coin.nano:
case Coin.banano:
@ -236,6 +245,36 @@ extension CoinExt on Coin {
}
}
bool get hasMnemonicPassphraseSupport {
switch (this) {
case Coin.bitcoin:
case Coin.bitcoinTestNet:
case Coin.litecoin:
case Coin.litecoinTestNet:
case Coin.bitcoincash:
case Coin.bitcoincashTestnet:
case Coin.dogecoin:
case Coin.dogecoinTestNet:
case Coin.firo:
case Coin.firoTestNet:
case Coin.namecoin:
case Coin.particl:
case Coin.ethereum:
case Coin.eCash:
case Coin.stellar:
case Coin.stellarTestnet:
return true;
case Coin.epicCash:
case Coin.monero:
case Coin.wownero:
case Coin.nano:
case Coin.banano:
case Coin.tezos:
return false;
}
}
bool get hasBuySupport {
switch (this) {
case Coin.bitcoin:
@ -251,6 +290,7 @@ extension CoinExt on Coin {
case Coin.eCash:
case Coin.epicCash:
case Coin.monero:
case Coin.tezos:
case Coin.wownero:
case Coin.dogecoinTestNet:
case Coin.bitcoinTestNet:
@ -277,6 +317,7 @@ extension CoinExt on Coin {
case Coin.epicCash:
case Coin.ethereum:
case Coin.monero:
case Coin.tezos:
case Coin.wownero:
case Coin.nano:
case Coin.banano:
@ -306,6 +347,7 @@ extension CoinExt on Coin {
case Coin.epicCash:
case Coin.ethereum:
case Coin.monero:
case Coin.tezos:
case Coin.wownero:
case Coin.nano:
case Coin.banano:
@ -374,6 +416,9 @@ extension CoinExt on Coin {
case Coin.stellarTestnet:
return xlm.MINIMUM_CONFIRMATIONS;
case Coin.tezos:
return tezos.MINIMUM_CONFIRMATIONS;
case Coin.wownero:
return wow.MINIMUM_CONFIRMATIONS;
@ -437,6 +482,10 @@ Coin coinFromPrettyName(String name) {
case "stellar":
return Coin.stellar;
case "Tezos":
case "tezos":
return Coin.tezos;
case "Namecoin":
case "namecoin":
return Coin.namecoin;
@ -483,6 +532,7 @@ Coin coinFromPrettyName(String name) {
case "Stellar Testnet":
case "stellarTestnet":
case "stellarTestNet":
case "tStellar":
return Coin.stellarTestnet;
@ -521,6 +571,8 @@ Coin coinFromTickerCaseInsensitive(String ticker) {
return Coin.particl;
case "xlm":
return Coin.stellar;
case "xtz":
return Coin.tezos;
case "tltc":
return Coin.litecoinTestNet;
case "tbtc":

View file

@ -1,6 +1,6 @@
/*
/*
* This file is part of Stack Wallet.
*
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
@ -51,6 +51,7 @@ extension DerivePathTypeExt on DerivePathType {
case Coin.banano:
case Coin.stellar:
case Coin.stellarTestnet:
case Coin.tezos: // TODO: Is this true?
throw UnsupportedError(
"$coin does not use bitcoin style derivation paths");
}

View file

@ -0,0 +1,34 @@
import 'dart:convert';
import 'package:http/http.dart' as http;
import 'package:stellar_flutter_sdk/stellar_flutter_sdk.dart';
Future<bool> testStellarNodeConnection(String host, int port) async {
final client = http.Client();
Uri uri = Uri.parse("$host:$port");
final response = await client.get(
uri,
headers: {'Content-Type': 'application/json'},
).timeout(const Duration(milliseconds: 2000),
onTimeout: () async => http.Response('Error', 408));
if (response.statusCode == 200) {
//Get chain height for sdk
StellarSDK stellarSdk = StellarSDK(host);
final height = await stellarSdk.ledgers
.order(RequestBuilderOrder.DESC)
.limit(1)
.execute()
.then((value) => value.records!.first.sequence)
.onError((error, stackTrace) => throw ("Error getting chain height"));
if (height > 0) {
return true;
} else {
return false;
}
} else {
return false;
}
}

View file

@ -29,6 +29,7 @@ import 'package:stackwallet/utilities/logger.dart';
import 'package:stackwallet/utilities/test_epic_box_connection.dart';
import 'package:stackwallet/utilities/test_eth_node_connection.dart';
import 'package:stackwallet/utilities/test_monero_node_connection.dart';
import 'package:stackwallet/utilities/test_stellar_node_connection.dart';
import 'package:stackwallet/utilities/text_styles.dart';
import 'package:stackwallet/utilities/util.dart';
import 'package:stackwallet/widgets/conditional_parent.dart';
@ -194,10 +195,17 @@ class _NodeCardState extends ConsumerState<NodeCard> {
case Coin.nano:
case Coin.banano:
case Coin.tezos:
//TODO: check network/node
throw UnimplementedError();
case Coin.stellar:
case Coin.stellarTestnet:
throw UnimplementedError();
//TODO: check network/node
try {
testPassed = await testStellarNodeConnection(node.host, node.port);
} catch (_) {
testPassed = false;
}
break;
}
if (testPassed) {

View file

@ -1,6 +1,6 @@
/*
/*
* This file is part of Stack Wallet.
*
*
* Copyright (c) 2023 Cypher Stack
* All Rights Reserved.
* The code is distributed under GPLv3 license, see LICENSE file for details.
@ -177,10 +177,11 @@ class NodeOptionsSheet extends ConsumerWidget {
case Coin.nano:
case Coin.banano:
case Coin.tezos:
case Coin.stellar:
case Coin.stellarTestnet:
throw UnimplementedError();
//TODO: check network/node
//TODO: check network/node
}
if (testPassed) {

View file

@ -18,15 +18,22 @@ class StackDialogBase extends StatelessWidget {
Key? key,
this.child,
this.padding = const EdgeInsets.all(24),
this.keyboardPaddingAmount = 0,
}) : super(key: key);
final EdgeInsets padding;
final Widget? child;
final double keyboardPaddingAmount;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(16),
padding: EdgeInsets.only(
top: 16,
left: 16,
right: 16,
bottom: 16 + keyboardPaddingAmount,
),
child: Column(
mainAxisAlignment:
!Util.isDesktop ? MainAxisAlignment.end : MainAxisAlignment.center,

View file

@ -25,6 +25,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.12.30"
ansicolor:
dependency: transitive
description:
name: ansicolor
sha256: "607f8fa9786f392043f169898923e6c59b4518242b68b8862eb8a8b7d9c30b4a"
url: "https://pub.dev"
source: hosted
version: "2.0.1"
archive:
dependency: "direct main"
description:
@ -298,10 +306,10 @@ packages:
dependency: "direct main"
description:
name: crypto
sha256: ff625774173754681d66daaf4a448684fb04b78f902da9cb3d308c19cc5e8bab
sha256: aa274aa7774f8964e4f4f38cc994db7b6158dd36e9187aaceaddc994b35c6c67
url: "https://pub.dev"
source: hosted
version: "3.0.3"
version: "3.0.2"
cryptography:
dependency: transitive
description:
@ -454,10 +462,10 @@ packages:
dependency: transitive
description:
name: dio
sha256: "3866d67f93523161b643187af65f5ac08bc991a5bcdaf41a2d587fe4ccb49993"
sha256: "7d328c4d898a61efc3cd93655a0955858e29a0aa647f0f9e02d59b3bb275e2e8"
url: "https://pub.dev"
source: hosted
version: "5.3.0"
version: "4.0.6"
dropdown_button2:
dependency: "direct main"
description:
@ -942,6 +950,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.0.2"
json_serializable:
dependency: transitive
description:
name: json_serializable
sha256: aa1f5a8912615733e0fdc7a02af03308933c93235bdc8d50d0b0c8a8ccb0b969
url: "https://pub.dev"
source: hosted
version: "6.7.1"
keyboard_dismisser:
dependency: "direct main"
description:
@ -1005,6 +1021,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.2.0"
memoize:
dependency: transitive
description:
name: memoize
sha256: "51481d328c86cbdc59711369179bac88551ca0556569249be5317e66fc796cac"
url: "https://pub.dev"
source: hosted
version: "3.0.0"
meta:
dependency: transitive
description:
@ -1230,13 +1254,13 @@ packages:
source: hosted
version: "5.4.0"
pinenacl:
dependency: transitive
dependency: "direct overridden"
description:
name: pinenacl
sha256: "3a5503637587d635647c93ea9a8fecf48a420cc7deebe6f1fc85c2a5637ab327"
sha256: e5fb0bce1717b7f136f35ee98b5c02b3e6383211f8a77ca882fa7812232a07b9
url: "https://pub.dev"
source: hosted
version: "0.5.1"
version: "0.3.4"
platform:
dependency: transitive
description:
@ -1269,6 +1293,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.5.1"
pretty_dio_logger:
dependency: transitive
description:
name: pretty_dio_logger
sha256: "948f7eeb36e7aa0760b51c1a8e3331d4b21e36fabd39efca81f585ed93893544"
url: "https://pub.dev"
source: hosted
version: "1.2.0-beta-1"
process:
dependency: transitive
description:
@ -1317,6 +1349,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "4.1.0"
quiver:
dependency: transitive
description:
name: quiver
sha256: b1c1ac5ce6688d77f65f3375a9abb9319b3cb32486bdc7a1e0fdf004d7ba4e47
url: "https://pub.dev"
source: hosted
version: "3.2.1"
rational:
dependency: transitive
description:
@ -1325,6 +1365,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "2.2.2"
retry:
dependency: transitive
description:
name: retry
sha256: "822e118d5b3aafed083109c72d5f484c6dc66707885e07c0fbcb8b986bba7efc"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
riverpod:
dependency: transitive
description:
@ -1479,10 +1527,10 @@ packages:
dependency: "direct main"
description:
name: stellar_flutter_sdk
sha256: "7a9b7dc76018bbd0b9c828045cf0e26e07ec44208fb1a1733273de2390205475"
sha256: "4c55b1b6dfbde7f89bba59a422754280715fa3b5726cff5e7eeaed454d2c4b89"
url: "https://pub.dev"
source: hosted
version: "1.6.0"
version: "1.5.3"
stream_channel:
dependency: transitive
description:
@ -1555,6 +1603,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.5.1"
tezart:
dependency: "direct main"
description:
name: tezart
sha256: "35d526f2e6ca250c64461ebfb4fa9f64b6599fab8c4242c8e89ae27d4ac2e15a"
url: "https://pub.dev"
source: hosted
version: "2.0.5"
time:
dependency: transitive
description:

View file

@ -11,7 +11,7 @@ description: Stack Wallet
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.7.18+186
version: 1.7.19+187
environment:
sdk: ">=3.0.2 <4.0.0"
@ -141,7 +141,8 @@ dependencies:
desktop_drop: ^0.4.1
nanodart: ^2.0.0
basic_utils: ^5.5.4
stellar_flutter_sdk: ^1.6.0
stellar_flutter_sdk: ^1.5.3
tezart: ^2.0.5
socks5_proxy: ^1.0.3+dev.3
dev_dependencies:
@ -203,7 +204,9 @@ dependency_overrides:
url: https://github.com/cypherstack/stack-bip39.git
ref: 0cd6d54e2860bea68fc50c801cb9db2a760192fb
crypto: 3.0.2
analyzer: ^5.2.0
pinenacl: ^0.3.3
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec

View file

@ -1283,10 +1283,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet {
returnValueForMissingStub: null,
);
@override
_i23.Future<void> initializeNew() => (super.noSuchMethod(
_i23.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i23.Future<void>.value(),
returnValueForMissingStub: _i23.Future<void>.value(),
@ -3062,10 +3064,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i23.Future<bool>.value(false),
) as _i23.Future<bool>);
@override
_i23.Future<void> initializeNew() => (super.noSuchMethod(
_i23.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i23.Future<void>.value(),
returnValueForMissingStub: _i23.Future<void>.value(),
@ -3415,10 +3419,12 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI {
returnValueForMissingStub: _i23.Future<void>.value(),
) as _i23.Future<void>);
@override
_i23.Future<void> initializeNew() => (super.noSuchMethod(
_i23.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i23.Future<void>.value(),
returnValueForMissingStub: _i23.Future<void>.value(),

View file

@ -28,7 +28,8 @@ void main() {
Uri.parse(
"https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids"
"=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin,bitcoin-cash"
",namecoin,wownero,ethereum,particl,nano,banano,stellar&order=market_cap_desc&per_page=50"
",namecoin,wownero,ethereum,particl,nano,banano,stellar,tezos"
"&order=market_cap_desc&per_page=50"
"&page=1&sparkline=false"),
headers: {
'Content-Type': 'application/json'
@ -114,6 +115,7 @@ void main() {
'Coin.nano: [0, 0.0], '
'Coin.particl: [0, 0.0], '
'Coin.stellar: [0, 0.0], '
'Coin.tezos: [0, 0.0], '
'Coin.wownero: [0, 0.0], '
'Coin.bitcoinTestNet: [0, 0.0], '
'Coin.bitcoincashTestnet: [0, 0.0], '
@ -128,6 +130,7 @@ void main() {
"https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc"
"&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin,"
"bitcoin-cash,namecoin,wownero,ethereum,particl,nano,banano,stellar"
",tezos"
"&order=market_cap_desc&per_page=50&page=1&sparkline=false",
),
headers: {'Content-Type': 'application/json'})).called(1);
@ -143,6 +146,7 @@ void main() {
"https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&"
"ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin,"
"bitcoin-cash,namecoin,wownero,ethereum,particl,nano,banano,stellar"
",tezos"
"&order=market_cap_desc&per_page=50&page=1&sparkline=false"),
headers: {
'Content-Type': 'application/json'
@ -228,7 +232,10 @@ void main() {
'Coin.firo: [0.0001096, -0.89304], '
'Coin.litecoin: [0, 0.0], '
'Coin.namecoin: [0, 0.0], '
'Coin.nano: [0, 0.0], Coin.particl: [0, 0.0], Coin.stellar: [0, 0.0], '
'Coin.nano: [0, 0.0], '
'Coin.particl: [0, 0.0], '
'Coin.stellar: [0, 0.0], '
'Coin.tezos: [0, 0.0], '
'Coin.wownero: [0, 0.0], '
'Coin.bitcoinTestNet: [0, 0.0], '
'Coin.bitcoincashTestnet: [0, 0.0], Coin.dogecoinTestNet: [0, 0.0], '
@ -244,6 +251,7 @@ void main() {
"https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc&ids"
"=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin,"
"bitcoin-cash,namecoin,wownero,ethereum,particl,nano,banano,stellar"
",tezos"
"&order=market_cap_desc&per_page=50&page=1&sparkline=false"),
headers: {'Content-Type': 'application/json'})).called(1);
@ -258,6 +266,7 @@ void main() {
"https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc"
"&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin,"
"bitcoin-cash,namecoin,wownero,ethereum,particl,nano,banano,stellar"
",tezos"
"&order=market_cap_desc&per_page=50&page=1&sparkline=false"),
headers: {
'Content-Type': 'application/json'
@ -343,6 +352,7 @@ void main() {
'Coin.nano: [0, 0.0], '
'Coin.particl: [0, 0.0], '
'Coin.stellar: [0, 0.0], '
'Coin.tezos: [0, 0.0], '
'Coin.wownero: [0, 0.0], '
'Coin.bitcoinTestNet: [0, 0.0], '
'Coin.bitcoincashTestnet: [0, 0.0], '
@ -362,6 +372,7 @@ void main() {
"https://api.coingecko.com/api/v3/coins/markets?vs_currency=btc"
"&ids=monero,bitcoin,litecoin,ecash,epic-cash,zcoin,dogecoin,"
"bitcoin-cash,namecoin,wownero,ethereum,particl,nano,banano,stellar"
",tezos"
"&order=market_cap_desc&per_page=50&page=1&sparkline=false"),
headers: {
'Content-Type': 'application/json'
@ -390,6 +401,7 @@ void main() {
'Coin.nano: [0, 0.0], '
'Coin.particl: [0, 0.0], '
'Coin.stellar: [0, 0.0], '
'Coin.tezos: [0, 0.0], '
'Coin.wownero: [0, 0.0], '
'Coin.bitcoinTestNet: [0, 0.0], '
'Coin.bitcoincashTestnet: [0, 0.0], '

View file

@ -492,10 +492,12 @@ class MockManager extends _i1.Mock implements _i12.Manager {
returnValue: _i9.Future<bool>.value(false),
) as _i9.Future<bool>);
@override
_i9.Future<void> initializeNew() => (super.noSuchMethod(
_i9.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),

View file

@ -453,10 +453,12 @@ class MockManager extends _i1.Mock implements _i10.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -451,10 +451,12 @@ class MockManager extends _i1.Mock implements _i10.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -771,10 +771,12 @@ class MockManager extends _i1.Mock implements _i13.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -558,10 +558,12 @@ class MockManager extends _i1.Mock implements _i10.Manager {
returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
@override
_i7.Future<void> initializeNew() => (super.noSuchMethod(
_i7.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i7.Future<void>.value(),

View file

@ -558,10 +558,12 @@ class MockManager extends _i1.Mock implements _i10.Manager {
returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
@override
_i7.Future<void> initializeNew() => (super.noSuchMethod(
_i7.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i7.Future<void>.value(),

View file

@ -558,10 +558,12 @@ class MockManager extends _i1.Mock implements _i10.Manager {
returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
@override
_i7.Future<void> initializeNew() => (super.noSuchMethod(
_i7.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i7.Future<void>.value(),

View file

@ -325,10 +325,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -556,10 +556,12 @@ class MockManager extends _i1.Mock implements _i10.Manager {
returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
@override
_i7.Future<void> initializeNew() => (super.noSuchMethod(
_i7.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i7.Future<void>.value(),

View file

@ -771,10 +771,12 @@ class MockManager extends _i1.Mock implements _i13.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -612,10 +612,12 @@ class MockManager extends _i1.Mock implements _i13.Manager {
returnValue: _i9.Future<bool>.value(false),
) as _i9.Future<bool>);
@override
_i9.Future<void> initializeNew() => (super.noSuchMethod(
_i9.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),

View file

@ -325,10 +325,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -325,10 +325,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -540,10 +540,12 @@ class MockManager extends _i1.Mock implements _i12.Manager {
returnValue: _i9.Future<bool>.value(false),
) as _i9.Future<bool>);
@override
_i9.Future<void> initializeNew() => (super.noSuchMethod(
_i9.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),

View file

@ -540,10 +540,12 @@ class MockManager extends _i1.Mock implements _i12.Manager {
returnValue: _i9.Future<bool>.value(false),
) as _i9.Future<bool>);
@override
_i9.Future<void> initializeNew() => (super.noSuchMethod(
_i9.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i9.Future<void>.value(),
returnValueForMissingStub: _i9.Future<void>.value(),

View file

@ -325,10 +325,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -325,10 +325,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -556,10 +556,12 @@ class MockManager extends _i1.Mock implements _i10.Manager {
returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
@override
_i7.Future<void> initializeNew() => (super.noSuchMethod(
_i7.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i7.Future<void>.value(),

View file

@ -154,18 +154,12 @@ class MockCachedElectrumX extends _i1.Mock implements _i7.CachedElectrumX {
_i8.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i8.Future<Map<String, dynamic>>);
@override
_i8.Future<List<String>> getUsedCoinSerials({
required _i9.Coin? coin,
int? startNumber = 0,
}) =>
_i8.Future<List<String>> getUsedCoinSerials({required _i9.Coin? coin}) =>
(super.noSuchMethod(
Invocation.method(
#getUsedCoinSerials,
[],
{
#coin: coin,
#startNumber: startNumber,
},
{#coin: coin},
),
returnValue: _i8.Future<List<String>>.value(<String>[]),
) as _i8.Future<List<String>>);
@ -792,10 +786,12 @@ class MockManager extends _i1.Mock implements _i15.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -556,10 +556,12 @@ class MockManager extends _i1.Mock implements _i10.Manager {
returnValue: _i7.Future<bool>.value(false),
) as _i7.Future<bool>);
@override
_i7.Future<void> initializeNew() => (super.noSuchMethod(
_i7.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i7.Future<void>.value(),
returnValueForMissingStub: _i7.Future<void>.value(),

View file

@ -327,10 +327,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -326,10 +326,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -325,10 +325,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -367,10 +367,12 @@ class MockManager extends _i1.Mock implements _i9.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -327,10 +327,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i8.Future<bool>.value(false),
) as _i8.Future<bool>);
@override
_i8.Future<void> initializeNew() => (super.noSuchMethod(
_i8.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i8.Future<void>.value(),
returnValueForMissingStub: _i8.Future<void>.value(),

View file

@ -485,18 +485,12 @@ class MockCachedElectrumX extends _i1.Mock implements _i5.CachedElectrumX {
_i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i4.Future<Map<String, dynamic>>);
@override
_i4.Future<List<String>> getUsedCoinSerials({
required _i6.Coin? coin,
int? startNumber = 0,
}) =>
_i4.Future<List<String>> getUsedCoinSerials({required _i6.Coin? coin}) =>
(super.noSuchMethod(
Invocation.method(
#getUsedCoinSerials,
[],
{
#coin: coin,
#startNumber: startNumber,
},
{#coin: coin},
),
returnValue: _i4.Future<List<String>>.value(<String>[]),
) as _i4.Future<List<String>>);

View file

@ -626,7 +626,8 @@ void main() async {
await Hive.openBox<dynamic>(testWalletId);
await Hive.openBox<dynamic>(DB.boxNamePrefs);
await expectLater(() => bch?.initializeNew(), throwsA(isA<Exception>()))
await expectLater(
() => bch?.initializeNew(null), throwsA(isA<Exception>()))
.then((_) {
expect(secureStore.interactions, 2);
verifyNever(client?.ping()).called(0);

View file

@ -485,18 +485,12 @@ class MockCachedElectrumX extends _i1.Mock implements _i5.CachedElectrumX {
_i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i4.Future<Map<String, dynamic>>);
@override
_i4.Future<List<String>> getUsedCoinSerials({
required _i6.Coin? coin,
int? startNumber = 0,
}) =>
_i4.Future<List<String>> getUsedCoinSerials({required _i6.Coin? coin}) =>
(super.noSuchMethod(
Invocation.method(
#getUsedCoinSerials,
[],
{
#coin: coin,
#startNumber: startNumber,
},
{#coin: coin},
),
returnValue: _i4.Future<List<String>>.value(<String>[]),
) as _i4.Future<List<String>>);

View file

@ -483,7 +483,8 @@ void main() {
await Hive.openBox<dynamic>(testWalletId);
await Hive.openBox<dynamic>(DB.boxNamePrefs);
await expectLater(() => doge?.initializeNew(), throwsA(isA<Exception>()))
await expectLater(
() => doge?.initializeNew(null), throwsA(isA<Exception>()))
.then((_) {
expect(secureStore.interactions, 2);
verifyNever(client?.ping()).called(0);

View file

@ -485,18 +485,12 @@ class MockCachedElectrumX extends _i1.Mock implements _i5.CachedElectrumX {
_i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i4.Future<Map<String, dynamic>>);
@override
_i4.Future<List<String>> getUsedCoinSerials({
required _i6.Coin? coin,
int? startNumber = 0,
}) =>
_i4.Future<List<String>> getUsedCoinSerials({required _i6.Coin? coin}) =>
(super.noSuchMethod(
Invocation.method(
#getUsedCoinSerials,
[],
{
#coin: coin,
#startNumber: startNumber,
},
{#coin: coin},
),
returnValue: _i4.Future<List<String>>.value(<String>[]),
) as _i4.Future<List<String>>);

View file

@ -88,7 +88,9 @@ class FakeCoinServiceAPI extends CoinServiceAPI {
}
@override
Future<void> initializeNew() {
Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data,
) {
// TODO: implement initializeNew
throw UnimplementedError();
}

View file

@ -512,18 +512,12 @@ class MockCachedElectrumX extends _i1.Mock implements _i6.CachedElectrumX {
_i5.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i5.Future<Map<String, dynamic>>);
@override
_i5.Future<List<String>> getUsedCoinSerials({
required _i7.Coin? coin,
int? startNumber = 0,
}) =>
_i5.Future<List<String>> getUsedCoinSerials({required _i7.Coin? coin}) =>
(super.noSuchMethod(
Invocation.method(
#getUsedCoinSerials,
[],
{
#coin: coin,
#startNumber: startNumber,
},
{#coin: coin},
),
returnValue: _i5.Future<List<String>>.value(<String>[]),
) as _i5.Future<List<String>>);

View file

@ -304,6 +304,11 @@ class MockFiroWallet extends _i1.Mock implements _i10.FiroWallet {
),
) as _i5.CachedElectrumX);
@override
bool get lelantusCoinIsarRescanRequired => (super.noSuchMethod(
Invocation.getter(#lelantusCoinIsarRescanRequired),
returnValue: false,
) as bool);
@override
bool get isRefreshing => (super.noSuchMethod(
Invocation.getter(#isRefreshing),
returnValue: false,
@ -552,15 +557,35 @@ class MockFiroWallet extends _i1.Mock implements _i10.FiroWallet {
returnValueForMissingStub: _i11.Future<void>.value(),
) as _i11.Future<void>);
@override
_i11.Future<void> initializeNew() => (super.noSuchMethod(
_i11.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[data],
),
returnValue: _i11.Future<void>.value(),
returnValueForMissingStub: _i11.Future<void>.value(),
) as _i11.Future<void>);
@override
_i11.Future<void> setLelantusCoinIsarRescanRequiredDone() =>
(super.noSuchMethod(
Invocation.method(
#setLelantusCoinIsarRescanRequiredDone,
[],
),
returnValue: _i11.Future<void>.value(),
returnValueForMissingStub: _i11.Future<void>.value(),
) as _i11.Future<void>);
@override
_i11.Future<bool> firoRescanRecovery() => (super.noSuchMethod(
Invocation.method(
#firoRescanRecovery,
[],
),
returnValue: _i11.Future<bool>.value(false),
) as _i11.Future<bool>);
@override
_i11.Future<void> initializeExisting() => (super.noSuchMethod(
Invocation.method(
#initializeExisting,

View file

@ -485,18 +485,12 @@ class MockCachedElectrumX extends _i1.Mock implements _i5.CachedElectrumX {
_i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i4.Future<Map<String, dynamic>>);
@override
_i4.Future<List<String>> getUsedCoinSerials({
required _i6.Coin? coin,
int? startNumber = 0,
}) =>
_i4.Future<List<String>> getUsedCoinSerials({required _i6.Coin? coin}) =>
(super.noSuchMethod(
Invocation.method(
#getUsedCoinSerials,
[],
{
#coin: coin,
#startNumber: startNumber,
},
{#coin: coin},
),
returnValue: _i4.Future<List<String>>.value(<String>[]),
) as _i4.Future<List<String>>);

View file

@ -485,18 +485,12 @@ class MockCachedElectrumX extends _i1.Mock implements _i5.CachedElectrumX {
_i4.Future<Map<String, dynamic>>.value(<String, dynamic>{}),
) as _i4.Future<Map<String, dynamic>>);
@override
_i4.Future<List<String>> getUsedCoinSerials({
required _i6.Coin? coin,
int? startNumber = 0,
}) =>
_i4.Future<List<String>> getUsedCoinSerials({required _i6.Coin? coin}) =>
(super.noSuchMethod(
Invocation.method(
#getUsedCoinSerials,
[],
{
#coin: coin,
#startNumber: startNumber,
},
{#coin: coin},
),
returnValue: _i4.Future<List<String>>.value(<String>[]),
) as _i4.Future<List<String>>);

View file

@ -1078,10 +1078,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet {
returnValueForMissingStub: null,
);
@override
_i23.Future<void> initializeNew() => (super.noSuchMethod(
_i23.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i23.Future<void>.value(),
returnValueForMissingStub: _i23.Future<void>.value(),
@ -3056,10 +3058,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i23.Future<bool>.value(false),
) as _i23.Future<bool>);
@override
_i23.Future<void> initializeNew() => (super.noSuchMethod(
_i23.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i23.Future<void>.value(),
returnValueForMissingStub: _i23.Future<void>.value(),
@ -3409,10 +3413,12 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI {
returnValueForMissingStub: _i23.Future<void>.value(),
) as _i23.Future<void>);
@override
_i23.Future<void> initializeNew() => (super.noSuchMethod(
_i23.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i23.Future<void>.value(),
returnValueForMissingStub: _i23.Future<void>.value(),

View file

@ -1162,10 +1162,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i28.BitcoinWallet {
returnValueForMissingStub: null,
);
@override
_i22.Future<void> initializeNew() => (super.noSuchMethod(
_i22.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i22.Future<void>.value(),
returnValueForMissingStub: _i22.Future<void>.value(),
@ -2302,10 +2304,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i22.Future<bool>.value(false),
) as _i22.Future<bool>);
@override
_i22.Future<void> initializeNew() => (super.noSuchMethod(
_i22.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i22.Future<void>.value(),
returnValueForMissingStub: _i22.Future<void>.value(),
@ -2655,10 +2659,12 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI {
returnValueForMissingStub: _i22.Future<void>.value(),
) as _i22.Future<void>);
@override
_i22.Future<void> initializeNew() => (super.noSuchMethod(
_i22.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i22.Future<void>.value(),
returnValueForMissingStub: _i22.Future<void>.value(),

View file

@ -689,10 +689,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i19.Future<bool>.value(false),
) as _i19.Future<bool>);
@override
_i19.Future<void> initializeNew() => (super.noSuchMethod(
_i19.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i19.Future<void>.value(),
returnValueForMissingStub: _i19.Future<void>.value(),
@ -1046,10 +1048,12 @@ class MockCoinServiceAPI extends _i1.Mock implements _i7.CoinServiceAPI {
returnValueForMissingStub: _i19.Future<void>.value(),
) as _i19.Future<void>);
@override
_i19.Future<void> initializeNew() => (super.noSuchMethod(
_i19.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i19.Future<void>.value(),
returnValueForMissingStub: _i19.Future<void>.value(),
@ -1313,6 +1317,11 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet {
),
) as _i13.CachedElectrumX);
@override
bool get lelantusCoinIsarRescanRequired => (super.noSuchMethod(
Invocation.getter(#lelantusCoinIsarRescanRequired),
returnValue: false,
) as bool);
@override
bool get isRefreshing => (super.noSuchMethod(
Invocation.getter(#isRefreshing),
returnValue: false,
@ -1561,15 +1570,35 @@ class MockFiroWallet extends _i1.Mock implements _i23.FiroWallet {
returnValueForMissingStub: _i19.Future<void>.value(),
) as _i19.Future<void>);
@override
_i19.Future<void> initializeNew() => (super.noSuchMethod(
_i19.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[data],
),
returnValue: _i19.Future<void>.value(),
returnValueForMissingStub: _i19.Future<void>.value(),
) as _i19.Future<void>);
@override
_i19.Future<void> setLelantusCoinIsarRescanRequiredDone() =>
(super.noSuchMethod(
Invocation.method(
#setLelantusCoinIsarRescanRequiredDone,
[],
),
returnValue: _i19.Future<void>.value(),
returnValueForMissingStub: _i19.Future<void>.value(),
) as _i19.Future<void>);
@override
_i19.Future<bool> firoRescanRecovery() => (super.noSuchMethod(
Invocation.method(
#firoRescanRecovery,
[],
),
returnValue: _i19.Future<bool>.value(false),
) as _i19.Future<bool>);
@override
_i19.Future<void> initializeExisting() => (super.noSuchMethod(
Invocation.method(
#initializeExisting,

View file

@ -817,10 +817,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet {
returnValueForMissingStub: null,
);
@override
_i21.Future<void> initializeNew() => (super.noSuchMethod(
_i21.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i21.Future<void>.value(),
returnValueForMissingStub: _i21.Future<void>.value(),

View file

@ -1072,10 +1072,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet {
returnValueForMissingStub: null,
);
@override
_i23.Future<void> initializeNew() => (super.noSuchMethod(
_i23.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i23.Future<void>.value(),
returnValueForMissingStub: _i23.Future<void>.value(),
@ -2411,10 +2413,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i23.Future<bool>.value(false),
) as _i23.Future<bool>);
@override
_i23.Future<void> initializeNew() => (super.noSuchMethod(
_i23.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i23.Future<void>.value(),
returnValueForMissingStub: _i23.Future<void>.value(),
@ -2764,10 +2768,12 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI {
returnValueForMissingStub: _i23.Future<void>.value(),
) as _i23.Future<void>);
@override
_i23.Future<void> initializeNew() => (super.noSuchMethod(
_i23.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i23.Future<void>.value(),
returnValueForMissingStub: _i23.Future<void>.value(),

View file

@ -1174,10 +1174,12 @@ class MockBitcoinWallet extends _i1.Mock implements _i29.BitcoinWallet {
returnValueForMissingStub: null,
);
@override
_i23.Future<void> initializeNew() => (super.noSuchMethod(
_i23.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i23.Future<void>.value(),
returnValueForMissingStub: _i23.Future<void>.value(),
@ -2514,10 +2516,12 @@ class MockManager extends _i1.Mock implements _i6.Manager {
returnValue: _i23.Future<bool>.value(false),
) as _i23.Future<bool>);
@override
_i23.Future<void> initializeNew() => (super.noSuchMethod(
_i23.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i23.Future<void>.value(),
returnValueForMissingStub: _i23.Future<void>.value(),
@ -2867,10 +2871,12 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI {
returnValueForMissingStub: _i23.Future<void>.value(),
) as _i23.Future<void>);
@override
_i23.Future<void> initializeNew() => (super.noSuchMethod(
_i23.Future<void> initializeNew(
({String mnemonicPassphrase, int wordCount})? data) =>
(super.noSuchMethod(
Invocation.method(
#initializeNew,
[],
[data],
),
returnValue: _i23.Future<void>.value(),
returnValueForMissingStub: _i23.Future<void>.value(),