diff --git a/assets/lottie/arrow_rotate.json b/assets/lottie/arrow_rotate.json new file mode 100644 index 000000000..c729d2e7a --- /dev/null +++ b/assets/lottie/arrow_rotate.json @@ -0,0 +1 @@ +{"v":"5.10.2","fr":30,"ip":0,"op":60,"w":30,"h":30,"nm":"arrow-rotate","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"arrow-rotate","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":44,"s":[200]},{"t":60,"s":[360]}],"ix":10},"p":{"a":0,"k":[15,15,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[100,100,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"ind":0,"ty":"sh","ix":1,"ks":{"a":0,"k":{"i":[[0,-0.828],[0,0],[3.389,0],[1.441,-4.074],[-0.781,-0.277],[-0.276,0.778],[-3.22,0],[-1.369,-1.823],[0,0],[0,-0.83],[-0.83,0],[0,0],[-0.023,0],[0,0],[0,0.83],[0,0],[0.83,0]],"o":[[0,0],[-1.964,-2.437],[-4.533,0],[-0.276,0.741],[0.781,0.277],[1.031,-2.916],[2.494,0],[0,0],[-0.83,0],[0,0.83],[0,0],[0.023,0],[0,0],[0.83,0],[0,0],[0,-0.828],[-0.83,0]],"v":[[8.25,-8.25],[8.25,-6.497],[-0.042,-10.5],[-9.902,-3.502],[-8.988,-1.584],[-7.073,-2.498],[-0.042,-7.5],[6,-4.5],[4.5,-4.5],[3,-3],[4.5,-1.5],[8.452,-1.5],[8.522,-1.5],[9.75,-1.5],[11.25,-3],[11.25,-8.25],[9.75,-9.75]],"c":true},"ix":2},"nm":"Path 1","mn":"ADBE Vector Shape - Group","hd":false},{"ind":1,"ty":"sh","ix":2,"ks":{"a":0,"k":{"i":[[0,0],[-0.828,0],[0,0.83],[0,0],[-3.347,0],[-1.439,4.073],[0.783,0.277],[0.277,-0.778],[3.262,0],[1.411,1.823],[0,0],[0,0.83],[0.83,0],[0,0],[0,-0.83]],"o":[[0,0.83],[0.828,0],[0,0],[1.922,2.438],[4.575,0],[0.277,-0.783],[-0.778,-0.277],[-1.031,2.916],[-2.452,0],[0,0],[0.83,0],[0,-0.83],[0,0],[-0.828,0],[0,0]],"v":[[-11.25,8.25],[-9.75,9.75],[-8.25,8.25],[-8.25,6.497],[0,10.5],[9.9,3.502],[8.986,1.584],[7.073,2.498],[0,7.5],[-6.042,4.5],[-4.5,4.5],[-3,3],[-4.5,1.5],[-9.75,1.5],[-11.25,3]],"c":true},"ix":2},"nm":"Path 2","mn":"ADBE Vector Shape - Group","hd":false},{"ty":"mm","mm":1,"nm":"Merge Paths 1","mn":"ADBE Vector Filter - Merge","hd":false},{"ty":"fl","c":{"a":0,"k":[0.137254908681,0.137254908681,0.137254908681,1],"ix":4},"o":{"a":0,"k":100,"ix":5},"r":1,"bm":0,"nm":"Fill 1","mn":"ADBE Vector Graphic - Fill","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Vector","np":4,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":60,"st":0,"ct":1,"bm":0}],"markers":[]} \ No newline at end of file diff --git a/assets/svg/rotate-exclamation.svg b/assets/svg/rotate-exclamation.svg deleted file mode 100644 index 6b6064125..000000000 --- a/assets/svg/rotate-exclamation.svg +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/docs/building.md b/docs/building.md index a2de91aa9..879008f09 100644 --- a/docs/building.md +++ b/docs/building.md @@ -9,7 +9,7 @@ Here you will find instructions on how to install the necessary tools for buildi The following prerequisites can be installed with the setup script [`scripts/setup.sh`](./../scripts/setup.sh) or manually as described below: -- Flutter 3.7.6 [(install manually or with git, do not install with snap)](https://docs.flutter.dev/get-started/install) +- Flutter 3.7.11 [(install manually or with git, do not install with snap)](https://docs.flutter.dev/get-started/install) - Dart SDK Requirement (>=2.19.0, up until <3.0.0) (normally included with a flutter install) - Android setup ([Android Studio](https://developer.android.com/studio) and subsequent dependencies) @@ -41,11 +41,17 @@ sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2- Install [Rust](https://www.rust-lang.org/tools/install) with command: ``` curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh +rustup install 1.67.1 +rustup default 1.67.1 ``` Install the additional components for Rust: ``` -cargo install cargo-ndk +cargo install cargo-ndk --version 2.12.7 +``` +Android specific dependencies: +``` +sudo apt-get install libc6-dev-i386 rustup target add aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android ``` Linux desktop specific dependencies: @@ -134,4 +140,4 @@ Use Tools > SDK Manager to install the SDK Tools > Android SDK (API 30), SDK Too Then install the Flutter plugin and restart the IDE. In Android Studio's options for the Flutter language, enable auto format on save to match the project's code style. If you have problems with the Dart SDK, make sure to run `flutter` in a terminal to download it (use `source ~/.bashrc` to update your environment variables if you're still using the same terminal from which you ran `setup.sh`) -Make a Pixel 4 (API 30) x86_64 emulator with 2GB of storage space for emulation \ No newline at end of file +Make a Pixel 4 (API 30) x86_64 emulator with 2GB of storage space for emulation diff --git a/lib/models/paynym/paynym_account.dart b/lib/models/paynym/paynym_account.dart index 4be59dc0c..133edc25d 100644 --- a/lib/models/paynym/paynym_account.dart +++ b/lib/models/paynym/paynym_account.dart @@ -4,6 +4,7 @@ import 'package:stackwallet/models/paynym/paynym_code.dart'; class PaynymAccount { final String nymID; final String nymName; + final bool segwit; final List codes; @@ -13,9 +14,13 @@ class PaynymAccount { /// list of nymId final List following; + PaynymCode get nonSegwitPaymentCode => + codes.firstWhere((element) => !element.segwit); + PaynymAccount( this.nymID, this.nymName, + this.segwit, this.codes, this.followers, this.following, @@ -24,6 +29,7 @@ class PaynymAccount { PaynymAccount.fromMap(Map map) : nymID = map["nymID"] as String, nymName = map["nymName"] as String, + segwit = map["segwit"] as bool, codes = (map["codes"] as List) .map((e) => PaynymCode.fromMap(Map.from(e as Map))) .toList(), @@ -39,6 +45,7 @@ class PaynymAccount { PaynymAccount copyWith({ String? nymID, String? nymName, + bool? segwit, List? codes, List? followers, List? following, @@ -46,6 +53,7 @@ class PaynymAccount { return PaynymAccount( nymID ?? this.nymID, nymName ?? this.nymName, + segwit ?? this.segwit, codes ?? this.codes, followers ?? this.followers, following ?? this.following, @@ -55,6 +63,7 @@ class PaynymAccount { Map toMap() => { "nymID": nymID, "nymName": nymName, + "segwit": segwit, "codes": codes.map((e) => e.toMap()), "followers": followers.map((e) => e.toMap()), "following": followers.map((e) => e.toMap()), diff --git a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart index e3630b922..79cdcd34f 100644 --- a/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart +++ b/lib/pages/add_wallet_views/restore_wallet_view/sub_widgets/restoring_dialog.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart'; @@ -21,37 +20,15 @@ class RestoringDialog extends StatefulWidget { State createState() => _RestoringDialogState(); } -class _RestoringDialogState extends State - with TickerProviderStateMixin { - late AnimationController? _spinController; - late Animation _spinAnimation; - +class _RestoringDialogState extends State { late final Future Function() onCancel; @override void initState() { onCancel = widget.onCancel; - _spinController = AnimationController( - duration: const Duration(seconds: 2), - vsync: this, - )..repeat(); - - _spinAnimation = CurvedAnimation( - parent: _spinController!, - curve: Curves.linear, - ); - super.initState(); } - @override - void dispose() { - _spinController?.dispose(); - _spinController = null; - - super.dispose(); - } - @override Widget build(BuildContext context) { if (Util.isDesktop) { @@ -69,14 +46,9 @@ class _RestoringDialogState extends State const Spacer( flex: 1, ), - RotationTransition( - turns: _spinAnimation, - child: SvgPicture.asset(Assets.svg.arrowRotate3, - width: 40, - height: 40, - color: Theme.of(context) - .extension()! - .accentColorDark), + const RotatingArrows( + width: 40, + height: 40, ), const Spacer( flex: 2, @@ -127,14 +99,9 @@ class _RestoringDialogState extends State child: StackDialog( title: "Restoring wallet", message: "This may take a while. Please do not exit this screen.", - icon: RotationTransition( - turns: _spinAnimation, - child: SvgPicture.asset(Assets.svg.arrowRotate3, - width: 24, - height: 24, - color: Theme.of(context) - .extension()! - .accentColorDark), + icon: const RotatingArrows( + width: 24, + height: 24, ), rightButton: TextButton( style: Theme.of(context) diff --git a/lib/pages/exchange_view/confirm_change_now_send.dart b/lib/pages/exchange_view/confirm_change_now_send.dart index 6a13e0b63..fff02cb7d 100644 --- a/lib/pages/exchange_view/confirm_change_now_send.dart +++ b/lib/pages/exchange_view/confirm_change_now_send.dart @@ -109,7 +109,7 @@ class _ConfirmChangeNowSendViewState time, ]); - sendProgressController.triggerSuccess(); + sendProgressController.triggerSuccess?.call(); await Future.delayed(const Duration(seconds: 5)); txid = results.first as String; diff --git a/lib/pages/paynym/add_new_paynym_follow_view.dart b/lib/pages/paynym/add_new_paynym_follow_view.dart index 68473fc7c..d89c3db92 100644 --- a/lib/pages/paynym/add_new_paynym_follow_view.dart +++ b/lib/pages/paynym/add_new_paynym_follow_view.dart @@ -447,7 +447,7 @@ class _AddNewPaynymFollowViewState child: PaynymCard( key: UniqueKey(), label: _searchResult!.nymName, - paymentCodeString: _searchResult!.codes.first.code, + paymentCodeString: _searchResult!.nonSegwitPaymentCode.code, walletId: widget.walletId, ), ), diff --git a/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart b/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart index 2a24fd4c8..7d42a35d4 100644 --- a/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart +++ b/lib/pages/paynym/dialogs/claiming_paynym_dialog.dart @@ -1,9 +1,8 @@ import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog_close_button.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart'; @@ -18,34 +17,7 @@ class ClaimingPaynymDialog extends StatefulWidget { State createState() => _RestoringDialogState(); } -class _RestoringDialogState extends State - with TickerProviderStateMixin { - late AnimationController? _spinController; - late Animation _spinAnimation; - - @override - void initState() { - _spinController = AnimationController( - duration: const Duration(seconds: 2), - vsync: this, - )..repeat(); - - _spinAnimation = CurvedAnimation( - parent: _spinController!, - curve: Curves.linear, - ); - - super.initState(); - } - - @override - void dispose() { - _spinController?.dispose(); - _spinController = null; - - super.dispose(); - } - +class _RestoringDialogState extends State { @override Widget build(BuildContext context) { if (Util.isDesktop) { @@ -62,15 +34,9 @@ class _RestoringDialogState extends State ), ], ), - RotationTransition( - turns: _spinAnimation, - child: SvgPicture.asset( - Assets.svg.arrowRotate, - color: - Theme.of(context).extension()!.accentColorDark, - width: 40, - height: 40, - ), + const RotatingArrows( + width: 40, + height: 40, ), Padding( padding: const EdgeInsets.all(40), @@ -115,15 +81,9 @@ class _RestoringDialogState extends State child: StackDialog( title: "Claiming PayNym", message: "We are generating your PayNym", - icon: RotationTransition( - turns: _spinAnimation, - child: SvgPicture.asset( - Assets.svg.arrowRotate, - color: - Theme.of(context).extension()!.accentColorDark, - width: 24, - height: 24, - ), + icon: const RotatingArrows( + width: 24, + height: 24, ), rightButton: SecondaryButton( label: "Cancel", diff --git a/lib/pages/paynym/dialogs/paynym_qr_popup.dart b/lib/pages/paynym/dialogs/paynym_qr_popup.dart index 3ad985472..0f36436fa 100644 --- a/lib/pages/paynym/dialogs/paynym_qr_popup.dart +++ b/lib/pages/paynym/dialogs/paynym_qr_popup.dart @@ -55,7 +55,7 @@ class PaynymQrPopup extends StatelessWidget { child: Row( children: [ PayNymBot( - paymentCodeString: paynymAccount.codes.first.code, + paymentCodeString: paynymAccount.nonSegwitPaymentCode.code, size: isDesktop ? 56 : 36, ), const SizedBox( @@ -108,7 +108,7 @@ class PaynymQrPopup extends StatelessWidget { height: 6, ), Text( - paynymAccount.codes.first.code, + paynymAccount.nonSegwitPaymentCode.code, style: isDesktop ? STextStyles.desktopTextSmall(context) : STextStyles.infoSmall(context).copyWith( @@ -127,7 +127,7 @@ class PaynymQrPopup extends StatelessWidget { onTap: () async { await Clipboard.setData( ClipboardData( - text: paynymAccount.codes.first.code, + text: paynymAccount.nonSegwitPaymentCode.code, ), ); unawaited( @@ -150,7 +150,7 @@ class PaynymQrPopup extends StatelessWidget { QrImage( padding: const EdgeInsets.all(0), size: 130, - data: paynymAccount.codes.first.code, + data: paynymAccount.nonSegwitPaymentCode.code, foregroundColor: Theme.of(context).extension()!.textDark, ), diff --git a/lib/pages/paynym/paynym_claim_view.dart b/lib/pages/paynym/paynym_claim_view.dart index 8a66aa26d..7944688da 100644 --- a/lib/pages/paynym/paynym_claim_view.dart +++ b/lib/pages/paynym/paynym_claim_view.dart @@ -3,6 +3,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/models/paynym/paynym_account.dart'; import 'package:stackwallet/pages/paynym/dialogs/claiming_paynym_dialog.dart'; import 'package:stackwallet/pages/paynym/paynym_home_view.dart'; import 'package:stackwallet/pages/wallet_view/wallet_view.dart'; @@ -11,7 +12,6 @@ import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart'; import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; @@ -36,6 +36,29 @@ class PaynymClaimView extends ConsumerStatefulWidget { } class _PaynymClaimViewState extends ConsumerState { + Future _addSegwitCode(PaynymAccount myAccount) async { + final manager = + ref.read(walletsChangeNotifierProvider).getManager(widget.walletId); + + // get wallet to access paynym calls + final wallet = manager.wallet as PaynymWalletInterface; + + final token = await ref + .read(paynymAPIProvider) + .token(myAccount.nonSegwitPaymentCode.code); + final signature = await wallet.signStringWithNotificationKey(token.value!); + + final pCodeSegwit = await wallet.getPaymentCode(isSegwit: true); + final addResult = await ref.read(paynymAPIProvider).add( + token.value!, + signature, + myAccount.nymID, + pCodeSegwit.toString(), + ); + + return addResult.value ?? false; + } + @override Widget build(BuildContext context) { debugPrint("BUILD: $runtimeType"); @@ -169,8 +192,7 @@ class _PaynymClaimViewState extends ConsumerState { if (shouldCancel) return; // get payment code - final pCode = await wallet.getPaymentCode( - DerivePathTypeExt.primaryFor(manager.coin)); + final pCode = await wallet.getPaymentCode(isSegwit: false); if (shouldCancel) return; @@ -185,6 +207,18 @@ class _PaynymClaimViewState extends ConsumerState { if (created.value!.claimed) { // payment code already claimed debugPrint("pcode already claimed!!"); + + final account = + await ref.read(paynymAPIProvider).nym(pCode.toString()); + if (!account.value!.segwit) { + for (int i = 0; i < 100; i++) { + final result = await _addSegwitCode(account.value!); + if (result == true) { + break; + } + } + } + if (mounted) { if (isDesktop) { Navigator.of(context, rootNavigator: true).pop(); @@ -223,6 +257,14 @@ class _PaynymClaimViewState extends ConsumerState { if (claim.value?.claimed == pCode.toString()) { final account = await ref.read(paynymAPIProvider).nym(pCode.toString()); + if (!account.value!.segwit) { + for (int i = 0; i < 100; i++) { + final result = await _addSegwitCode(account.value!); + if (result == true) { + break; + } + } + } ref.read(myPaynymAccountStateProvider.state).state = account.value!; diff --git a/lib/pages/paynym/paynym_home_view.dart b/lib/pages/paynym/paynym_home_view.dart index b989ba9c5..f0cb108cb 100644 --- a/lib/pages/paynym/paynym_home_view.dart +++ b/lib/pages/paynym/paynym_home_view.dart @@ -275,8 +275,7 @@ class _PaynymHomeViewState extends ConsumerState { paymentCodeString: ref .watch(myPaynymAccountStateProvider.state) .state! - .codes - .first + .nonSegwitPaymentCode .code, ), ), @@ -298,8 +297,7 @@ class _PaynymHomeViewState extends ConsumerState { ref .watch(myPaynymAccountStateProvider.state) .state! - .codes - .first + .nonSegwitPaymentCode .code, 12, 5), @@ -330,8 +328,7 @@ class _PaynymHomeViewState extends ConsumerState { text: ref .read(myPaynymAccountStateProvider.state) .state! - .codes - .first + .nonSegwitPaymentCode .code, ), ); @@ -376,8 +373,7 @@ class _PaynymHomeViewState extends ConsumerState { ref .read(myPaynymAccountStateProvider.state) .state! - .codes - .first + .nonSegwitPaymentCode .code, sharePositionOrigin: sharePositionOrigin); }, @@ -447,8 +443,7 @@ class _PaynymHomeViewState extends ConsumerState { paymentCodeString: ref .watch(myPaynymAccountStateProvider.state) .state! - .codes - .first + .nonSegwitPaymentCode .code, ), ), @@ -473,8 +468,7 @@ class _PaynymHomeViewState extends ConsumerState { ref .watch(myPaynymAccountStateProvider.state) .state! - .codes - .first + .nonSegwitPaymentCode .code, 12, 5), @@ -501,8 +495,7 @@ class _PaynymHomeViewState extends ConsumerState { text: ref .read(myPaynymAccountStateProvider.state) .state! - .codes - .first + .nonSegwitPaymentCode .code, ), ); diff --git a/lib/pages/paynym/subwidgets/paynym_followers_list.dart b/lib/pages/paynym/subwidgets/paynym_followers_list.dart index d8583954d..1237b2c4a 100644 --- a/lib/pages/paynym/subwidgets/paynym_followers_list.dart +++ b/lib/pages/paynym/subwidgets/paynym_followers_list.dart @@ -8,7 +8,6 @@ import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart'; import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; @@ -75,7 +74,7 @@ class _PaynymFollowersListState extends ConsumerState { // get payment code final pCode = await wallet.getPaymentCode( - DerivePathTypeExt.primaryFor(manager.coin), + isSegwit: false, ); // get account from api diff --git a/lib/pages/paynym/subwidgets/paynym_following_list.dart b/lib/pages/paynym/subwidgets/paynym_following_list.dart index 4d9df16ac..f12d30cdf 100644 --- a/lib/pages/paynym/subwidgets/paynym_following_list.dart +++ b/lib/pages/paynym/subwidgets/paynym_following_list.dart @@ -8,7 +8,6 @@ import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart'; import 'package:stackwallet/utilities/constants.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; @@ -75,7 +74,7 @@ class _PaynymFollowingListState extends ConsumerState { // get payment code final pCode = await wallet.getPaymentCode( - DerivePathTypeExt.primaryFor(manager.coin), + isSegwit: false, ); // get account from api diff --git a/lib/pages/receive_view/receive_view.dart b/lib/pages/receive_view/receive_view.dart index e46badfd3..b74dc5a33 100644 --- a/lib/pages/receive_view/receive_view.dart +++ b/lib/pages/receive_view/receive_view.dart @@ -233,6 +233,7 @@ class _ReceiveViewState extends ConsumerState { children: [ GestureDetector( onTap: () { + HapticFeedback.lightImpact(); clipboard.setData( ClipboardData(text: receivingAddress), ); diff --git a/lib/pages/send_view/confirm_transaction_view.dart b/lib/pages/send_view/confirm_transaction_view.dart index d54b7b8cf..a6dd1bcc0 100644 --- a/lib/pages/send_view/confirm_transaction_view.dart +++ b/lib/pages/send_view/confirm_transaction_view.dart @@ -135,7 +135,7 @@ class _ConfirmTransactionViewState time, ]); - sendProgressController.triggerSuccess(); + sendProgressController.triggerSuccess?.call(); await Future.delayed(const Duration(seconds: 5)); txid = results.first as String; diff --git a/lib/pages/send_view/send_view.dart b/lib/pages/send_view/send_view.dart index 12896b87a..479c931ae 100644 --- a/lib/pages/send_view/send_view.dart +++ b/lib/pages/send_view/send_view.dart @@ -453,11 +453,12 @@ class _SendViewState extends ConsumerState { final wallet = manager.wallet as PaynymWalletInterface; final paymentCode = PaymentCode.fromPaymentCode( widget.accountLite!.code, - wallet.networkType, + networkType: wallet.networkType, ); final feeRate = ref.read(feeRateTypeStateProvider); txDataFuture = wallet.preparePaymentCodeSend( paymentCode: paymentCode, + isSegwit: widget.accountLite!.segwit, amount: amount, args: { "feeRate": feeRate, diff --git a/lib/pages/send_view/sub_widgets/building_transaction_dialog.dart b/lib/pages/send_view/sub_widgets/building_transaction_dialog.dart index 8bd800cad..f95fe7bed 100644 --- a/lib/pages/send_view/sub_widgets/building_transaction_dialog.dart +++ b/lib/pages/send_view/sub_widgets/building_transaction_dialog.dart @@ -1,11 +1,11 @@ import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/color_theme.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; import 'package:stackwallet/widgets/desktop/secondary_button.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; @@ -23,38 +23,16 @@ class BuildingTransactionDialog extends StatefulWidget { State createState() => _RestoringDialogState(); } -class _RestoringDialogState extends State - with TickerProviderStateMixin { - late AnimationController? _spinController; - late Animation _spinAnimation; - +class _RestoringDialogState extends State { late final VoidCallback onCancel; @override void initState() { onCancel = widget.onCancel; - _spinController = AnimationController( - duration: const Duration(seconds: 2), - vsync: this, - )..repeat(); - - _spinAnimation = CurvedAnimation( - parent: _spinController!, - curve: Curves.linear, - ); - super.initState(); } - @override - void dispose() { - _spinController?.dispose(); - _spinController = null; - - super.dispose(); - } - @override Widget build(BuildContext context) { final isChans = Theme.of(context).extension()!.themeType == @@ -80,15 +58,9 @@ class _RestoringDialogState extends State ), ), if (!isChans) - RotationTransition( - turns: _spinAnimation, - child: SvgPicture.asset( - Assets.svg.arrowRotate, - color: - Theme.of(context).extension()!.accentColorDark, - width: 24, - height: 24, - ), + const RotatingArrows( + width: 40, + height: 40, ), const SizedBox( height: 40, @@ -151,16 +123,9 @@ class _RestoringDialogState extends State ) : StackDialog( title: "Generating transaction", - icon: RotationTransition( - turns: _spinAnimation, - child: SvgPicture.asset( - Assets.svg.arrowRotate, - color: Theme.of(context) - .extension()! - .accentColorDark, - width: 24, - height: 24, - ), + icon: const RotatingArrows( + width: 24, + height: 24, ), rightButton: TextButton( style: Theme.of(context) diff --git a/lib/pages/send_view/sub_widgets/sending_transaction_dialog.dart b/lib/pages/send_view/sub_widgets/sending_transaction_dialog.dart index 4b0c56728..85dc6fc6f 100644 --- a/lib/pages/send_view/sub_widgets/sending_transaction_dialog.dart +++ b/lib/pages/send_view/sub_widgets/sending_transaction_dialog.dart @@ -113,7 +113,7 @@ class _RestoringDialogState extends State { } class ProgressAndSuccessController { - late VoidCallback triggerSuccess; + VoidCallback? triggerSuccess; } class ProgressAndSuccess extends StatefulWidget { diff --git a/lib/pages/settings_views/global_settings_view/global_settings_view.dart b/lib/pages/settings_views/global_settings_view/global_settings_view.dart index 627961bed..ded2dd325 100644 --- a/lib/pages/settings_views/global_settings_view/global_settings_view.dart +++ b/lib/pages/settings_views/global_settings_view/global_settings_view.dart @@ -162,7 +162,7 @@ class GlobalSettingsView extends StatelessWidget { height: 8, ), SettingsListButton( - iconAssetName: Assets.svg.arrowRotate3, + iconAssetName: Assets.svg.arrowRotate, iconSize: 18, title: "Syncing preferences", onPressed: () { diff --git a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart index 5172144be..3a286d6d2 100644 --- a/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart +++ b/lib/pages/settings_views/global_settings_view/stack_backup_views/sub_views/stack_restore_progress_view.dart @@ -214,7 +214,7 @@ class _StackRestoreProgressViewState @override void initState() { WidgetsBinding.instance.addPostFrameCallback((_) async { - _restore(); + unawaited(_restore()); }); super.initState(); } @@ -325,7 +325,7 @@ class _StackRestoreProgressViewState : null, ) : RoundedContainer( - padding: EdgeInsets.all(0), + padding: EdgeInsets.zero, color: Theme.of(context) .extension()! .popupBG, @@ -411,7 +411,7 @@ class _StackRestoreProgressViewState : null, ) : RoundedContainer( - padding: EdgeInsets.all(0), + padding: EdgeInsets.zero, color: Theme.of(context) .extension()! .popupBG, @@ -497,7 +497,7 @@ class _StackRestoreProgressViewState : null, ) : RoundedContainer( - padding: EdgeInsets.all(0), + padding: EdgeInsets.zero, color: Theme.of(context) .extension()! .popupBG, @@ -548,44 +548,42 @@ class _StackRestoreProgressViewState final state = ref.watch(stackRestoringUIStateProvider .select((value) => value.trades)); return !isDesktop - ? Container( - child: RestoringItemCard( - left: SizedBox( - width: 32, - height: 32, - child: RoundedContainer( - padding: const EdgeInsets.all(0), - color: Theme.of(context) - .extension()! - .buttonBackSecondary, - child: Center( - child: SvgPicture.asset( - Assets.svg.arrowRotate2, - width: 16, - height: 16, - color: Theme.of(context) - .extension()! - .accentColorDark, - ), + ? RestoringItemCard( + left: SizedBox( + width: 32, + height: 32, + child: RoundedContainer( + padding: const EdgeInsets.all(0), + color: Theme.of(context) + .extension()! + .buttonBackSecondary, + child: Center( + child: SvgPicture.asset( + Assets.svg.arrowsTwoWay, + width: 16, + height: 16, + color: Theme.of(context) + .extension()! + .accentColorDark, ), ), ), - right: SizedBox( - width: 20, - height: 20, - child: _getIconForState(state), - ), - title: "Exchange history", - subTitle: state == StackRestoringStatus.failed - ? Text( - "Something went wrong", - style: STextStyles.errorSmall(context), - ) - : null, ), + right: SizedBox( + width: 20, + height: 20, + child: _getIconForState(state), + ), + title: "Exchange history", + subTitle: state == StackRestoringStatus.failed + ? Text( + "Something went wrong", + style: STextStyles.errorSmall(context), + ) + : null, ) : RoundedContainer( - padding: EdgeInsets.all(0), + padding: EdgeInsets.zero, color: Theme.of(context) .extension()! .popupBG, @@ -603,7 +601,7 @@ class _StackRestoreProgressViewState .buttonBackSecondary, child: Center( child: SvgPicture.asset( - Assets.svg.arrowRotate2, + Assets.svg.arrowsTwoWay, width: 16, height: 16, color: Theme.of(context) diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart index 0435d023b..ac30cb5e7 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_network_settings_view/sub_widgets/rescanning_dialog.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; import 'package:stackwallet/widgets/conditional_parent.dart'; import 'package:stackwallet/widgets/desktop/desktop_dialog.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; @@ -66,18 +64,12 @@ class _RescanningDialogState extends State maxWidth: 500, child: child, ), - child: StackDialog( + child: const StackDialog( title: "Rescanning blockchain", message: "This may take a while. Please do not exit this screen.", - icon: RotationTransition( - turns: _spinAnimation, - child: SvgPicture.asset( - Assets.svg.arrowRotate3, - width: 24, - height: 24, - color: - Theme.of(context).extension()!.accentColorDark, - ), + icon: RotatingArrows( + width: 24, + height: 24, ), // rightButton: TextButton( // style: Theme.of(context).textButtonTheme.style?.copyWith( diff --git a/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart b/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart index 592630b12..9df35cb7c 100644 --- a/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart +++ b/lib/pages/settings_views/wallet_settings_view/wallet_settings_view.dart @@ -269,7 +269,7 @@ class _WalletSettingsViewState extends State { height: 8, ), SettingsListButton( - iconAssetName: Assets.svg.arrowRotate3, + iconAssetName: Assets.svg.arrowRotate, title: "Syncing preferences", onPressed: () { Navigator.of(context).pushNamed( diff --git a/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart b/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart index b1541617c..a4b6a34de 100644 --- a/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart +++ b/lib/pages/wallet_view/sub_widgets/wallet_refresh_button.dart @@ -3,15 +3,14 @@ import 'dart:async'; import 'package:event_bus/event_bus.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; -import 'package:flutter_svg/svg.dart'; import 'package:stackwallet/pages/token_view/token_view.dart'; import 'package:stackwallet/providers/global/wallets_provider.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/utilities/assets.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; +import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; /// [eventBus] should only be set during testing class WalletRefreshButton extends ConsumerStatefulWidget { @@ -36,30 +35,16 @@ class WalletRefreshButton extends ConsumerStatefulWidget { ConsumerState createState() => _RefreshButtonState(); } -class _RefreshButtonState extends ConsumerState - with TickerProviderStateMixin { +class _RefreshButtonState extends ConsumerState { late final EventBus eventBus; - late AnimationController? _spinController; - late Animation _spinAnimation; + late RotatingArrowsController _spinController; late StreamSubscription _syncStatusSubscription; @override void initState() { - _spinController = AnimationController( - duration: const Duration(seconds: 2), - vsync: this, - ); - - _spinAnimation = CurvedAnimation( - parent: _spinController!, - curve: Curves.linear, - ); - - if (widget.initialSyncStatus == WalletSyncStatus.syncing) { - _spinController?.repeat(); - } + _spinController = RotatingArrowsController(); eventBus = widget.eventBus != null ? widget.eventBus! : GlobalEventBus.instance; @@ -71,26 +56,26 @@ class _RefreshButtonState extends ConsumerState widget.tokenContractAddress == null) { switch (event.newStatus) { case WalletSyncStatus.unableToSync: - _spinController?.stop(); + _spinController.stop?.call(); break; case WalletSyncStatus.synced: - _spinController?.stop(); + _spinController.stop?.call(); break; case WalletSyncStatus.syncing: - unawaited(_spinController?.repeat()); + _spinController.repeat?.call(); break; } } else if (widget.tokenContractAddress != null && event.walletId == widget.walletId + widget.tokenContractAddress!) { switch (event.newStatus) { case WalletSyncStatus.unableToSync: - _spinController?.stop(); + _spinController.stop?.call(); break; case WalletSyncStatus.synced: - _spinController?.stop(); + _spinController.stop?.call(); break; case WalletSyncStatus.syncing: - unawaited(_spinController?.repeat()); + _spinController.repeat?.call(); break; } } @@ -102,9 +87,6 @@ class _RefreshButtonState extends ConsumerState @override void dispose() { - _spinController?.dispose(); - _spinController = null; - _syncStatusSubscription.cancel(); super.dispose(); @@ -117,62 +99,56 @@ class _RefreshButtonState extends ConsumerState return SizedBox( height: isDesktop ? 22 : 36, width: isDesktop ? 22 : 36, - child: Semantics( - label: "Refresh Button. Refreshes The Values In Page.", - excludeSemantics: true, - child: MaterialButton( - color: isDesktop - ? Theme.of(context).extension()!.buttonBackSecondary - : null, - splashColor: Theme.of(context).extension()!.highlight, - onPressed: () { - if (widget.tokenContractAddress == null) { - final managerProvider = ref - .read(walletsChangeNotifierProvider) - .getManagerProvider(widget.walletId); - final isRefreshing = ref.read(managerProvider).isRefreshing; - if (!isRefreshing) { - _spinController?.repeat(); - ref - .read(managerProvider) - .refresh() - .then((_) => _spinController?.stop()); - } - } else { - if (!ref.read(tokenServiceProvider)!.isRefreshing) { - ref.read(tokenServiceProvider)!.refresh(); - } + child: MaterialButton( + color: isDesktop + ? Theme.of(context).extension()!.buttonBackSecondary + : null, + splashColor: Theme.of(context).extension()!.highlight, + onPressed: () { + if (widget.tokenContractAddress == null) { + final managerProvider = ref + .read(walletsChangeNotifierProvider) + .getManagerProvider(widget.walletId); + final isRefreshing = ref.read(managerProvider).isRefreshing; + if (!isRefreshing) { + _spinController.repeat?.call(); + ref + .read(managerProvider) + .refresh() + .then((_) => _spinController.stop?.call()); } - }, - elevation: 0, - highlightElevation: 0, - hoverElevation: 0, - padding: EdgeInsets.zero, - materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular( - Constants.size.circularBorderRadius, - ), - ), - child: RotationTransition( - turns: _spinAnimation, - child: SvgPicture.asset( - Assets.svg.arrowRotate, - width: isDesktop ? 12 : 24, - height: isDesktop ? 12 : 24, - color: widget.overrideIconColor != null - ? widget.overrideIconColor! - : isDesktop - ? Theme.of(context) - .extension()! - .textFieldDefaultSearchIconRight - : Theme.of(context) - .extension()! - .textFavoriteCard, - ), + } else { + if (!ref.read(tokenServiceProvider)!.isRefreshing) { + ref.read(tokenServiceProvider)!.refresh(); + } + } + }, + elevation: 0, + highlightElevation: 0, + hoverElevation: 0, + padding: EdgeInsets.zero, + materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, + shape: RoundedRectangleBorder( + borderRadius: BorderRadius.circular( + Constants.size.circularBorderRadius, ), ), - ) + child: RotatingArrows( + spinByDefault: widget.initialSyncStatus == WalletSyncStatus.syncing, + width: isDesktop ? 12 : 24, + height: isDesktop ? 12 : 24, + controller: _spinController, + color: widget.overrideIconColor != null + ? widget.overrideIconColor! + : isDesktop + ? Theme.of(context) + .extension()! + .textFieldDefaultSearchIconRight + : Theme.of(context) + .extension()! + .textFavoriteCard, + ), + ), ); } } diff --git a/lib/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart b/lib/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart index 7d737ab41..810579e6c 100644 --- a/lib/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart +++ b/lib/pages/wallet_view/transaction_views/dialogs/cancelling_transaction_progress_dialog.dart @@ -1,7 +1,5 @@ import 'package:flutter/material.dart'; -import 'package:flutter_svg/svg.dart'; -import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/theme/stack_colors.dart'; +import 'package:stackwallet/widgets/animated_widgets/rotating_arrows.dart'; import 'package:stackwallet/widgets/stack_dialog.dart'; class CancellingTransactionProgressDialog extends StatefulWidget { @@ -13,51 +11,19 @@ class CancellingTransactionProgressDialog extends StatefulWidget { } class _CancellingTransactionProgressDialogState - extends State - with TickerProviderStateMixin { - late AnimationController? _spinController; - late Animation _spinAnimation; - - @override - void initState() { - _spinController = AnimationController( - duration: const Duration(seconds: 2), - vsync: this, - )..repeat(); - - _spinAnimation = CurvedAnimation( - parent: _spinController!, - curve: Curves.linear, - ); - - super.initState(); - } - - @override - void dispose() { - _spinController?.dispose(); - _spinController = null; - - super.dispose(); - } - + extends State { @override Widget build(BuildContext context) { return WillPopScope( onWillPop: () async { return false; }, - child: StackDialog( + child: const StackDialog( title: "Cancelling transaction", message: "This may take a while. Please do not exit this screen.", - icon: RotationTransition( - turns: _spinAnimation, - child: SvgPicture.asset( - Assets.svg.arrowRotate3, - width: 24, - height: 24, - color: Theme.of(context).extension()!.accentColorDark, - ), + icon: RotatingArrows( + width: 24, + height: 24, ), // rightButton: TextButton( // style: Theme.of(context).textButtonTheme.style?.copyWith( diff --git a/lib/pages/wallet_view/wallet_view.dart b/lib/pages/wallet_view/wallet_view.dart index 7d43acfbd..649464722 100644 --- a/lib/pages/wallet_view/wallet_view.dart +++ b/lib/pages/wallet_view/wallet_view.dart @@ -43,7 +43,6 @@ import 'package:stackwallet/utilities/clipboard_interface.dart'; import 'package:stackwallet/utilities/constants.dart'; import 'package:stackwallet/utilities/enums/backup_frequency_type.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/utilities/enums/wallet_balance_toggle_state.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/show_loading.dart'; @@ -912,7 +911,8 @@ class _WalletViewState extends ConsumerState { manager.wallet as PaynymWalletInterface; final code = await paynymInterface.getPaymentCode( - DerivePathTypeExt.primaryFor(manager.coin)); + isSegwit: false, + ); final account = await ref .read(paynymAPIProvider) @@ -928,7 +928,8 @@ class _WalletViewState extends ConsumerState { // check if account exists and for matching code to see if claimed if (account.value != null && - account.value!.codes.first.claimed) { + account.value!.nonSegwitPaymentCode.claimed && + account.value!.segwit) { ref.read(myPaynymAccountStateProvider.state).state = account.value!; diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart index 664fe0103..cf2ca1582 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_send.dart @@ -262,11 +262,12 @@ class _DesktopSendState extends ConsumerState { final wallet = manager.wallet as PaynymWalletInterface; final paymentCode = PaymentCode.fromPaymentCode( widget.accountLite!.code, - wallet.networkType, + networkType: wallet.networkType, ); final feeRate = ref.read(feeRateTypeStateProvider); txDataFuture = wallet.preparePaymentCodeSend( paymentCode: paymentCode, + isSegwit: widget.accountLite!.segwit, amount: amount, args: { "feeRate": feeRate, diff --git a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart index 089c0e19f..aef5b8f00 100644 --- a/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart +++ b/lib/pages_desktop_specific/my_stack_view/wallet_view/sub_widgets/desktop_wallet_features.dart @@ -21,7 +21,6 @@ import 'package:stackwallet/utilities/amount/amount.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/enums/derive_path_type_enum.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:stackwallet/utilities/text_styles.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; @@ -271,8 +270,7 @@ class _DesktopWalletFeaturesState extends ConsumerState { final wallet = manager.wallet as PaynymWalletInterface; - final code = - await wallet.getPaymentCode(DerivePathTypeExt.primaryFor(manager.coin)); + final code = await wallet.getPaymentCode(isSegwit: false); final account = await ref.read(paynymAPIProvider).nym(code.toString()); @@ -285,7 +283,9 @@ class _DesktopWalletFeaturesState extends ConsumerState { Navigator.of(context, rootNavigator: true).pop(); // check if account exists and for matching code to see if claimed - if (account.value != null && account.value!.codes.first.claimed) { + if (account.value != null && + account.value!.nonSegwitPaymentCode.claimed && + account.value!.segwit) { ref.read(myPaynymAccountStateProvider.state).state = account.value!; await Navigator.of(context).pushNamed( diff --git a/lib/services/coins/bitcoin/bitcoin_wallet.dart b/lib/services/coins/bitcoin/bitcoin_wallet.dart index 0625957f6..ba49eefc0 100644 --- a/lib/services/coins/bitcoin/bitcoin_wallet.dart +++ b/lib/services/coins/bitcoin/bitcoin_wallet.dart @@ -164,6 +164,7 @@ class BitcoinWallet extends CoinServiceAPI // _checkP2PKHChangeAddressForTransactions, dustLimitP2PKH: DUST_LIMIT_P2PKH.raw.toInt(), minConfirms: MINIMUM_CONFIRMATIONS, + dustLimit: DUST_LIMIT.raw.toInt(), ); } @@ -422,7 +423,7 @@ class BitcoinWallet extends CoinServiceAPI level: LogLevel.Info); } - Future, DerivePathType>> _checkGaps( + Future, DerivePathType, int>> _checkGaps( int maxNumberOfIndexesToCheck, int maxUnusedAddressGap, int txCountBatchSize, @@ -432,6 +433,8 @@ class BitcoinWallet extends CoinServiceAPI ) async { List addressArray = []; int gapCounter = 0; + int highestIndexWithHistory = 0; + for (int index = 0; index < maxNumberOfIndexesToCheck && gapCounter < maxUnusedAddressGap; index += txCountBatchSize) { @@ -505,6 +508,9 @@ class BitcoinWallet extends CoinServiceAPI if (count > 0) { iterationsAddressArray.add(txCountCallArgs["${_id}_$k"]!); + // update highest + highestIndexWithHistory = index + k; + // reset counter gapCounter = 0; } @@ -517,7 +523,7 @@ class BitcoinWallet extends CoinServiceAPI // cache all the transactions while waiting for the current function to finish. unawaited(getTransactionCacheEarly(iterationsAddressArray)); } - return Tuple2(addressArray, type); + return Tuple3(addressArray, type, highestIndexWithHistory); } Future getTransactionCacheEarly(List allAddresses) async { @@ -561,9 +567,9 @@ class BitcoinWallet extends CoinServiceAPI DerivePathType.bip84, ]; - final List, DerivePathType>>> + final List, DerivePathType, int>>> receiveFutures = []; - final List, DerivePathType>>> + final List, DerivePathType, int>>> changeFutures = []; const receiveChain = 0; @@ -622,6 +628,7 @@ class BitcoinWallet extends CoinServiceAPI final List addressesToStore = []; + int highestReceivingIndexWithHistory = 0; // If restoring a wallet that never received any funds, then set receivingArray manually // If we didn't do this, it'd store an empty array for (final tuple in receiveResults) { @@ -633,10 +640,13 @@ class BitcoinWallet extends CoinServiceAPI ); addressesToStore.add(address); } else { + highestReceivingIndexWithHistory = + max(tuple.item3, highestReceivingIndexWithHistory); addressesToStore.addAll(tuple.item1); } } + int highestChangeIndexWithHistory = 0; // If restoring a wallet that never sent any funds with change, then set changeArray // manually. If we didn't do this, it'd store an empty array. for (final tuple in changeResults) { @@ -648,10 +658,20 @@ class BitcoinWallet extends CoinServiceAPI ); addressesToStore.add(address); } else { + highestChangeIndexWithHistory = + max(tuple.item3, highestChangeIndexWithHistory); addressesToStore.addAll(tuple.item1); } } + // remove extra addresses to help minimize risk of creating a large gap + addressesToStore.removeWhere((e) => + e.subType == isar_models.AddressSubType.change && + e.derivationIndex > highestChangeIndexWithHistory); + addressesToStore.removeWhere((e) => + e.subType == isar_models.AddressSubType.receiving && + e.derivationIndex > highestReceivingIndexWithHistory); + if (isRescan) { await db.updateOrPutAddresses(addressesToStore); } else { @@ -659,10 +679,11 @@ class BitcoinWallet extends CoinServiceAPI } // get own payment code - final myCode = await getPaymentCode(DerivePathType.bip44, root); + // isSegwit does not matter here at all + final myCode = await getPaymentCode(isSegwit: false); // refresh transactions to pick up any received notification transactions - await _refreshTransactions(); + await _refreshNotificationAddressTransactions(); try { final Set codesToCheck = {}; @@ -691,7 +712,10 @@ class BitcoinWallet extends CoinServiceAPI ); } - await _updateUTXOs(); + await Future.wait([ + _refreshTransactions(), + _updateUTXOs(), + ]); await Future.wait([ updateCachedId(walletId), @@ -915,7 +939,8 @@ class BitcoinWallet extends CoinServiceAPI GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.0, walletId)); GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.1, walletId)); - final myCode = await getPaymentCode(DerivePathType.bip44); + // isSegwit does not matter here at all + final myCode = await getPaymentCode(isSegwit: false); final Set codesToCheck = {}; final nym = await PaynymIsApi().nym(myCode.toString()); if (nym.value != null) { @@ -1221,6 +1246,11 @@ class BitcoinWallet extends CoinServiceAPI } await _prefs.init(); + + // this will add the notification address to the db if it isn't + // already there for older wallets + await getMyNotificationAddress(); + // await _checkCurrentChangeAddressesForTransactions(); // await _checkCurrentReceivingAddressesForTransactions(); } @@ -1346,10 +1376,12 @@ class BitcoinWallet extends CoinServiceAPI .getAddresses(walletId) .filter() .not() - .typeEqualTo(isar_models.AddressType.nonWallet) - .and() - .not() - .subTypeEqualTo(isar_models.AddressSubType.nonWallet) + .group( + (q) => q + .typeEqualTo(isar_models.AddressType.nonWallet) + .or() + .subTypeEqualTo(isar_models.AddressSubType.nonWallet), + ) .findAll(); return allAddresses; } @@ -1444,6 +1476,10 @@ class BitcoinWallet extends CoinServiceAPI _generateAddressForChain(1, 0, DerivePathType.bip49), ]); + // this will add the notification address to the db if it isn't + // already there so it can be watched + await getMyNotificationAddress(); + await db.putAddresses(initialAddresses); Logging.instance.log("_generateNewWalletFinished", level: LogLevel.Info); @@ -1517,42 +1553,6 @@ class BitcoinWallet extends CoinServiceAPI ); } - /// Returns the latest receiving/change (external/internal) address for the wallet depending on [chain] - /// and - /// [chain] - Use 0 for receiving (external), 1 for change (internal). Should not be any other value! - Future _getCurrentAddressForChain( - int chain, - DerivePathType derivePathType, - ) async { - final subType = chain == 0 // Here, we assume that chain == 1 if it isn't 0 - ? isar_models.AddressSubType.receiving - : isar_models.AddressSubType.change; - - isar_models.AddressType type; - isar_models.Address? address; - switch (derivePathType) { - case DerivePathType.bip44: - type = isar_models.AddressType.p2pkh; - break; - case DerivePathType.bip49: - type = isar_models.AddressType.p2sh; - break; - case DerivePathType.bip84: - type = isar_models.AddressType.p2wpkh; - break; - default: - throw Exception("DerivePathType unsupported"); - } - address = await db - .getAddresses(walletId) - .filter() - .typeEqualTo(type) - .subTypeEqualTo(subType) - .sortByDerivationIndexDesc() - .findFirst(); - return address!.value; - } - String _buildDerivationStorageKey({ required int chain, required DerivePathType derivePathType, @@ -2020,6 +2020,60 @@ class BitcoinWallet extends CoinServiceAPI return false; } + Future _refreshNotificationAddressTransactions() async { + final address = await getMyNotificationAddress(); + final hashes = await _fetchHistory([address.value]); + + List> allTransactions = []; + + final currentHeight = await chainHeight; + + for (final txHash in hashes) { + final storedTx = await db + .getTransactions(walletId) + .filter() + .txidEqualTo(txHash["tx_hash"] as String) + .findFirst(); + + // TODO: remove bip47Notification type check sometime after Q2 2023 + if (storedTx == null || + storedTx.subType == + isar_models.TransactionSubType.bip47Notification || + !storedTx.isConfirmed(currentHeight, MINIMUM_CONFIRMATIONS)) { + final tx = await cachedElectrumXClient.getTransaction( + txHash: txHash["tx_hash"] as String, + verbose: true, + coin: coin, + ); + + tx["address"] = await db + .getAddresses(walletId) + .filter() + .valueEqualTo(txHash["address"] as String) + .findFirst(); + tx["height"] = txHash["height"]; + allTransactions.add(tx); + } + } + + final List> txnsData = + []; + + for (final txObject in allTransactions) { + final data = await parseTransaction( + txObject, + cachedElectrumXClient, + [address], + coin, + MINIMUM_CONFIRMATIONS, + walletId, + ); + + txnsData.add(data); + } + await db.addNewTransactionData(txnsData, walletId); + } + Future _refreshTransactions() async { final List allAddresses = await _fetchAllOwnAddresses(); @@ -2282,8 +2336,7 @@ class BitcoinWallet extends CoinServiceAPI utxoSigningData: utxoSigningData, recipients: [ recipientAddress, - await _getCurrentAddressForChain( - 1, DerivePathTypeExt.primaryFor(coin)), + await currentChangeAddress, ], satoshiAmounts: [ satoshiAmountToSend, @@ -2326,8 +2379,7 @@ class BitcoinWallet extends CoinServiceAPI feeForTwoOutputs) { // generate new change address if current change address has been used await _checkChangeAddressForTransactions(); - final String newChangeAddress = await _getCurrentAddressForChain( - 1, DerivePathTypeExt.primaryFor(coin)); + final String newChangeAddress = await currentChangeAddress; int feeBeingPaid = satoshisBeingUsed - satoshiAmountToSend - changeOutputSize; @@ -2554,43 +2606,67 @@ class BitcoinWallet extends CoinServiceAPI String? pubKey; String? wif; - // fetch receiving derivations if null - receiveDerivations[sd.derivePathType] ??= await _fetchDerivations( - chain: 0, - derivePathType: sd.derivePathType, - ); - final receiveDerivation = - receiveDerivations[sd.derivePathType]![sd.utxo.address!]; + final address = await db.getAddress(walletId, sd.utxo.address!); + if (address?.derivationPath != null) { + final bip32.BIP32 node; + if (address!.subType == isar_models.AddressSubType.paynymReceive) { + final code = await paymentCodeStringByKey(address.otherData!); - if (receiveDerivation != null) { - pubKey = receiveDerivation["pubKey"] as String; - wif = receiveDerivation["wif"] as String; - } else { - // fetch change derivations if null - changeDerivations[sd.derivePathType] ??= await _fetchDerivations( - chain: 1, - derivePathType: sd.derivePathType, - ); - final changeDerivation = - changeDerivations[sd.derivePathType]![sd.utxo.address!]; - if (changeDerivation != null) { - pubKey = changeDerivation["pubKey"] as String; - wif = changeDerivation["wif"] as String; - } - } + final bip47base = await getBip47BaseNode(); - if (wif == null || pubKey == null) { - final address = await db.getAddress(walletId, sd.utxo.address!); - if (address?.derivationPath != null) { - final node = await Bip32Utils.getBip32Node( + final privateKey = await getPrivateKeyForPaynymReceivingAddress( + paymentCodeString: code!, + index: address.derivationIndex, + ); + + node = bip32.BIP32.fromPrivateKey( + privateKey, + bip47base.chainCode, + bip32.NetworkType( + wif: _network.wif, + bip32: bip32.Bip32Type( + public: _network.bip32.public, + private: _network.bip32.private, + ), + ), + ); + } else { + node = await Bip32Utils.getBip32Node( (await mnemonicString)!, (await mnemonicPassphrase)!, _network, - address!.derivationPath!.value, + address.derivationPath!.value, ); + } - wif = node.toWIF(); - pubKey = Format.uint8listToString(node.publicKey); + wif = node.toWIF(); + pubKey = Format.uint8listToString(node.publicKey); + } + + if (wif == null || pubKey == null) { + // fetch receiving derivations if null + receiveDerivations[sd.derivePathType] ??= await _fetchDerivations( + chain: 0, + derivePathType: sd.derivePathType, + ); + final receiveDerivation = + receiveDerivations[sd.derivePathType]![sd.utxo.address!]; + + if (receiveDerivation != null) { + pubKey = receiveDerivation["pubKey"] as String; + wif = receiveDerivation["wif"] as String; + } else { + // fetch change derivations if null + changeDerivations[sd.derivePathType] ??= await _fetchDerivations( + chain: 1, + derivePathType: sd.derivePathType, + ); + final changeDerivation = + changeDerivations[sd.derivePathType]![sd.utxo.address!]; + if (changeDerivation != null) { + pubKey = changeDerivation["pubKey"] as String; + wif = changeDerivation["wif"] as String; + } } } diff --git a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart index cd263f0db..8c9d4d911 100644 --- a/lib/services/coins/bitcoincash/bitcoincash_wallet.dart +++ b/lib/services/coins/bitcoincash/bitcoincash_wallet.dart @@ -2733,7 +2733,9 @@ class BitcoinCashWallet extends CoinServiceAPI required List recipients, required List satoshiAmounts, }) async { - final builder = bitbox.Bitbox.transactionBuilder(); + final builder = bitbox.Bitbox.transactionBuilder( + testnet: coin == Coin.bitcoincashTestnet, + ); // retrieve address' utxos from the rest api List _utxos = diff --git a/lib/services/mixins/paynym_wallet_interface.dart b/lib/services/mixins/paynym_wallet_interface.dart index 22f9db6bf..a6902fd2b 100644 --- a/lib/services/mixins/paynym_wallet_interface.dart +++ b/lib/services/mixins/paynym_wallet_interface.dart @@ -20,19 +20,28 @@ import 'package:stackwallet/utilities/amount/amount.dart'; import 'package:stackwallet/utilities/bip32_utils.dart'; import 'package:stackwallet/utilities/bip47_utils.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; import 'package:stackwallet/utilities/format.dart'; import 'package:stackwallet/utilities/logger.dart'; import 'package:tuple/tuple.dart'; -const kPaynymDerivePath = "m/47'/0'/0'"; +const String kPCodeKeyPrefix = "pCode_key_"; -const kPaynymNotificationDerivationPath = "$kPaynymDerivePath/0"; +String _basePaynymDerivePath({required bool testnet}) => + "m/47'/${testnet ? "1" : "0"}'/0'"; +String _notificationDerivationPath({required bool testnet}) => + "${_basePaynymDerivePath(testnet: testnet)}/0"; -String _receivingPaynymAddressDerivationPath(int index) { - return "$kPaynymDerivePath/$index/0"; -} +String _receivingPaynymAddressDerivationPath( + int index, { + required bool testnet, +}) => + "${_basePaynymDerivePath(testnet: testnet)}/$index/0"; +String _sendPaynymAddressDerivationPath( + int index, { + required bool testnet, +}) => + "${_basePaynymDerivePath(testnet: testnet)}/0/$index"; mixin PaynymWalletInterface { // passed in wallet data @@ -43,6 +52,7 @@ mixin PaynymWalletInterface { late final MainDB _db; late final ElectrumX _electrumXClient; late final SecureStorageInterface _secureStorage; + late final int _dustLimit; late final int _dustLimitP2PKH; late final int _minConfirms; @@ -78,6 +88,7 @@ mixin PaynymWalletInterface { required MainDB db, required ElectrumX electrumXClient, required SecureStorageInterface secureStorage, + required int dustLimit, required int dustLimitP2PKH, required int minConfirms, required Future Function() getMnemonicString, @@ -113,6 +124,7 @@ mixin PaynymWalletInterface { _db = db; _electrumXClient = electrumXClient; _secureStorage = secureStorage; + _dustLimit = dustLimit; _dustLimitP2PKH = dustLimitP2PKH; _minConfirms = minConfirms; _getMnemonicString = getMnemonicString; @@ -130,19 +142,69 @@ mixin PaynymWalletInterface { // convenience getter btc_dart.NetworkType get networkType => _network; - Future
currentReceivingPaynymAddress(PaymentCode sender) async { + Future getBip47BaseNode() async { + final root = await _getRootNode(); + final node = root.derivePath( + _basePaynymDerivePath( + testnet: _coin.isTestNet, + ), + ); + return node; + } + + Future getPrivateKeyForPaynymReceivingAddress({ + required String paymentCodeString, + required int index, + }) async { + final bip47base = await getBip47BaseNode(); + + final paymentAddress = PaymentAddress( + bip32Node: bip47base.derive(index), + paymentCode: PaymentCode.fromPaymentCode( + paymentCodeString, + networkType: networkType, + ), + networkType: networkType, + index: 0, + ); + + final pair = paymentAddress.getReceiveAddressKeyPair(); + + return pair.privateKey!; + } + + Future
currentReceivingPaynymAddress({ + required PaymentCode sender, + required bool isSegwit, + }) async { final keys = await lookupKey(sender.toString()); + final address = await _db .getAddresses(_walletId) .filter() .subTypeEqualTo(AddressSubType.paynymReceive) .and() + .group((q) { + if (isSegwit) { + return q + .typeEqualTo(AddressType.p2sh) + .or() + .typeEqualTo(AddressType.p2wpkh); + } else { + return q.typeEqualTo(AddressType.p2pkh); + } + }) + .and() .anyOf(keys, (q, String e) => q.otherDataEqualTo(e)) .sortByDerivationIndexDesc() .findFirst(); if (address == null) { - final generatedAddress = await _generatePaynymReceivingAddress(sender, 0); + final generatedAddress = await _generatePaynymReceivingAddress( + sender: sender, + index: 0, + generateSegwitAddress: isSegwit, + ); final existing = await _db .getAddresses(_walletId) @@ -158,47 +220,109 @@ mixin PaynymWalletInterface { await _db.updateAddress(existing, generatedAddress); } - return currentReceivingPaynymAddress(sender); + return currentReceivingPaynymAddress( + isSegwit: isSegwit, + sender: sender, + ); } else { return address; } } - Future
_generatePaynymReceivingAddress( - PaymentCode sender, - int index, - ) async { - final myPrivateKeyNode = await deriveReceivingPrivateKeyNode( - mnemonic: (await _getMnemonicString())!, - mnemonicPassphrase: (await _getMnemonicPassphrase())!, - index: index, + Future
_generatePaynymReceivingAddress({ + required PaymentCode sender, + required int index, + required bool generateSegwitAddress, + }) async { + final root = await _getRootNode(); + final node = root.derivePath( + _basePaynymDerivePath( + testnet: _coin.isTestNet, + ), ); final paymentAddress = PaymentAddress( - bip32Node: myPrivateKeyNode, + bip32Node: node.derive(index), paymentCode: sender, networkType: networkType, + index: 0, ); - final pair = paymentAddress.getReceiveAddressKeyPair(); - final address = await generatePaynymReceivingAddressFromKeyPair( - pair: pair, + final addressString = generateSegwitAddress + ? paymentAddress.getReceiveAddressP2WPKH() + : paymentAddress.getReceiveAddressP2PKH(); + + final address = Address( + walletId: _walletId, + value: addressString, + publicKey: [], derivationIndex: index, - derivePathType: DerivePathType.bip44, - fromPaymentCode: sender, + derivationPath: DerivationPath() + ..value = _receivingPaynymAddressDerivationPath( + index, + testnet: _coin.isTestNet, + ), + type: generateSegwitAddress ? AddressType.p2wpkh : AddressType.p2pkh, + subType: AddressSubType.paynymReceive, + otherData: await storeCode(sender.toString()), ); + return address; } - Future checkCurrentPaynymReceivingAddressForTransactions( - PaymentCode sender) async { - final address = await currentReceivingPaynymAddress(sender); + Future
_generatePaynymSendAddress({ + required PaymentCode other, + required int index, + required bool generateSegwitAddress, + bip32.BIP32? mySendBip32Node, + }) async { + final node = mySendBip32Node ?? await deriveNotificationBip32Node(); + + final paymentAddress = PaymentAddress( + bip32Node: node, + paymentCode: other, + networkType: networkType, + index: index, + ); + + final addressString = generateSegwitAddress + ? paymentAddress.getSendAddressP2WPKH() + : paymentAddress.getSendAddressP2PKH(); + + final address = Address( + walletId: _walletId, + value: addressString, + publicKey: [], + derivationIndex: index, + derivationPath: DerivationPath() + ..value = _sendPaynymAddressDerivationPath( + index, + testnet: _coin.isTestNet, + ), + type: AddressType.nonWallet, + subType: AddressSubType.paynymSend, + otherData: await storeCode(other.toString()), + ); + + return address; + } + + Future checkCurrentPaynymReceivingAddressForTransactions({ + required PaymentCode sender, + required bool isSegwit, + }) async { + final address = await currentReceivingPaynymAddress( + sender: sender, + isSegwit: isSegwit, + ); + final txCount = await _getTxCount(address: address.value); if (txCount > 0) { // generate next address and add to db final nextAddress = await _generatePaynymReceivingAddress( - sender, - address.derivationIndex + 1, + sender: sender, + index: address.derivationIndex + 1, + generateSegwitAddress: isSegwit, ); final existing = await _db @@ -215,7 +339,10 @@ mixin PaynymWalletInterface { await _db.updateAddress(existing, nextAddress); } // keep checking until address with no tx history is set as current - await checkCurrentPaynymReceivingAddressForTransactions(sender); + await checkCurrentPaynymReceivingAddressForTransactions( + sender: sender, + isSegwit: isSegwit, + ); } } @@ -223,68 +350,58 @@ mixin PaynymWalletInterface { final codes = await getAllPaymentCodesFromNotificationTransactions(); final List> futures = []; for (final code in codes) { - futures.add(checkCurrentPaynymReceivingAddressForTransactions(code)); + futures.add(checkCurrentPaynymReceivingAddressForTransactions( + sender: code, + isSegwit: true, + )); + futures.add(checkCurrentPaynymReceivingAddressForTransactions( + sender: code, + isSegwit: false, + )); } await Future.wait(futures); } // generate bip32 payment code root - Future _getRootNode({ - required String mnemonic, - required String mnemonicPassphrase, - }) async { - final root = await Bip32Utils.getBip32Root( - mnemonic, - mnemonicPassphrase, + Future _getRootNode() async { + return _cachedRootNode ??= await Bip32Utils.getBip32Root( + (await _getMnemonicString())!, + (await _getMnemonicPassphrase())!, _network, ); - return root; } - Future deriveNotificationBip32Node({ - required String mnemonic, - required String mnemonicPassphrase, - }) async { - final root = await _getRootNode( - mnemonic: mnemonic, - mnemonicPassphrase: mnemonicPassphrase, - ); - final node = root.derivePath(kPaynymDerivePath).derive(0); - return node; - } + bip32.BIP32? _cachedRootNode; - Future deriveReceivingPrivateKeyNode({ - required String mnemonic, - required String mnemonicPassphrase, - required int index, - }) async { - final root = await _getRootNode( - mnemonic: mnemonic, - mnemonicPassphrase: mnemonicPassphrase, - ); - final node = root.derivePath(kPaynymDerivePath).derive(index); + Future deriveNotificationBip32Node() async { + final root = await _getRootNode(); + final node = root + .derivePath( + _basePaynymDerivePath( + testnet: _coin.isTestNet, + ), + ) + .derive(0); return node; } /// fetch or generate this wallet's bip47 payment code - Future getPaymentCode( - DerivePathType derivePathType, [ - bip32.BIP32? bip32Root, - ]) async { - final address = await getMyNotificationAddress(derivePathType, bip32Root); - final pCodeString = await paymentCodeStringByKey(address.otherData!); - final paymentCode = PaymentCode.fromPaymentCode( - pCodeString!, - _network, + Future getPaymentCode({ + required bool isSegwit, + }) async { + final node = await _getRootNode(); + + final paymentCode = PaymentCode.fromBip32Node( + node.derivePath(_basePaynymDerivePath(testnet: _coin.isTestNet)), + networkType: networkType, + shouldSetSegwitBit: isSegwit, ); + return paymentCode; } Future signWithNotificationKey(Uint8List data) async { - final myPrivateKeyNode = await deriveNotificationBip32Node( - mnemonic: (await _getMnemonicString())!, - mnemonicPassphrase: (await _getMnemonicPassphrase())!, - ); + final myPrivateKeyNode = await deriveNotificationBip32Node(); final pair = btc_dart.ECPair.fromPrivateKey(myPrivateKeyNode.privateKey!, network: _network); final signed = pair.sign(SHA256Digest().process(data)); @@ -299,6 +416,7 @@ mixin PaynymWalletInterface { Future> preparePaymentCodeSend({ required PaymentCode paymentCode, + required bool isSegwit, required Amount amount, Map? args, }) async { @@ -306,13 +424,11 @@ mixin PaynymWalletInterface { throw PaynymSendException( "No notification transaction sent to $paymentCode"); } else { - final myPrivateKeyNode = await deriveNotificationBip32Node( - mnemonic: (await _getMnemonicString())!, - mnemonicPassphrase: (await _getMnemonicPassphrase())!, - ); + final myPrivateKeyNode = await deriveNotificationBip32Node(); final sendToAddress = await nextUnusedSendAddressFrom( pCode: paymentCode, privateKeyNode: myPrivateKeyNode, + isSegwit: isSegwit, ); return _prepareSend( @@ -327,6 +443,7 @@ mixin PaynymWalletInterface { /// and your own private key Future
nextUnusedSendAddressFrom({ required PaymentCode pCode, + required bool isSegwit, required bip32.BIP32 privateKeyNode, int startIndex = 0, }) async { @@ -352,19 +469,11 @@ mixin PaynymWalletInterface { return address; } } else { - final pair = PaymentAddress( - bip32Node: privateKeyNode, - index: i, // index to use - paymentCode: pCode, - networkType: networkType, - ).getSendAddressKeyPair(); - - // add address to local db - final address = await generatePaynymSendAddressFromKeyPair( - pair: pair, - derivationIndex: i, - derivePathType: DerivePathType.bip44, - toPaymentCode: pCode, + final address = await _generatePaynymSendAddress( + other: pCode, + index: i, + generateSegwitAddress: isSegwit, + mySendBip32Node: privateKeyNode, ); final storedAddress = await _db.getAddress(_walletId, address.value); @@ -449,8 +558,8 @@ mixin PaynymWalletInterface { targetPaymentCodeString: targetPaymentCodeString, utxoSigningData: utxoSigningData, change: 0, - dustLimit: - satoshisBeingUsed, // override amount to get around absurd fees error + // override amount to get around absurd fees error + overrideAmountForTesting: satoshisBeingUsed, )) .item2; @@ -513,7 +622,9 @@ mixin PaynymWalletInterface { Map transactionObject = { "hex": txn.item1, "recipientPaynym": targetPaymentCodeString, - "amount": amountToSend, + "amount": amountToSend.toAmountAsRaw( + fractionDigits: _coin.decimals, + ), "fee": feeBeingPaid, "vSize": txn.item2, "usedUTXOs": utxoSigningData.map((e) => e.utxo).toList(), @@ -533,7 +644,8 @@ mixin PaynymWalletInterface { Map transactionObject = { "hex": txn.item1, "recipientPaynym": targetPaymentCodeString, - "amount": amountToSend, + "amount": + amountToSend.toAmountAsRaw(fractionDigits: _coin.decimals), "fee": feeBeingPaid, "vSize": txn.item2, "usedUTXOs": utxoSigningData.map((e) => e.utxo).toList(), @@ -554,7 +666,7 @@ mixin PaynymWalletInterface { Map transactionObject = { "hex": txn.item1, "recipientPaynym": targetPaymentCodeString, - "amount": amountToSend, + "amount": amountToSend.toAmountAsRaw(fractionDigits: _coin.decimals), "fee": feeBeingPaid, "vSize": txn.item2, "usedUTXOs": utxoSigningData.map((e) => e.utxo).toList(), @@ -585,12 +697,14 @@ mixin PaynymWalletInterface { required String targetPaymentCodeString, required List utxoSigningData, required int change, - int? dustLimit, + int? overrideAmountForTesting, }) async { try { - final targetPaymentCode = - PaymentCode.fromPaymentCode(targetPaymentCodeString, _network); - final myCode = await getPaymentCode(DerivePathType.bip44); + final targetPaymentCode = PaymentCode.fromPaymentCode( + targetPaymentCodeString, + networkType: _network, + ); + final myCode = await getPaymentCode(isSegwit: false); final utxo = utxoSigningData.first.utxo; final txPoint = utxo.txid.fromHex.reversed.toList(); @@ -642,11 +756,12 @@ mixin PaynymWalletInterface { utxoSigningData[i].output!, ); } + final String notificationAddress = + targetPaymentCode.notificationAddressP2PKH(); - // todo: modify address once segwit support is in our bip47 txb.addOutput( - targetPaymentCode.notificationAddressP2PKH(), - dustLimit ?? _dustLimitP2PKH, + notificationAddress, + overrideAmountForTesting ?? _dustLimitP2PKH, ); txb.addOutput(opReturnScript, 0); @@ -687,8 +802,9 @@ mixin PaynymWalletInterface { } } - Future broadcastNotificationTx( - {required Map preparedTx}) async { + Future broadcastNotificationTx({ + required Map preparedTx, + }) async { try { Logging.instance.log("confirmNotificationTx txData: $preparedTx", level: LogLevel.Info); @@ -749,8 +865,7 @@ mixin PaynymWalletInterface { // q.anyOf(keys, (q, e) => q.otherDataEqualTo(e))) // .findAll(); - final myNotificationAddress = - await getMyNotificationAddress(DerivePathTypeExt.primaryFor(_coin)); + final myNotificationAddress = await getMyNotificationAddress(); final txns = await _db .getTransactions(_walletId) @@ -763,7 +878,6 @@ mixin PaynymWalletInterface { tx.address.value?.value == myNotificationAddress.value) { final unBlindedPaymentCode = await unBlindedPaymentCodeFromTransaction( transaction: tx, - myNotificationAddress: myNotificationAddress, ); if (unBlindedPaymentCode != null && @@ -775,7 +889,6 @@ mixin PaynymWalletInterface { final unBlindedPaymentCodeBad = await unBlindedPaymentCodeFromTransactionBad( transaction: tx, - myNotificationAddress: myNotificationAddress, ); if (unBlindedPaymentCodeBad != null && @@ -820,13 +933,7 @@ mixin PaynymWalletInterface { Future unBlindedPaymentCodeFromTransaction({ required Transaction transaction, - required Address myNotificationAddress, }) async { - if (transaction.address.value != null && - transaction.address.value!.value != myNotificationAddress.value) { - return null; - } - try { final blindedCodeBytes = Bip47Utils.getBlindedPaymentCodeBytesFrom(transaction); @@ -848,11 +955,7 @@ mixin PaynymWalletInterface { final pubKey = _pubKeyFromInput(designatedInput)!; - final myPrivateKey = (await deriveNotificationBip32Node( - mnemonic: (await _getMnemonicString())!, - mnemonicPassphrase: (await _getMnemonicPassphrase())!, - )) - .privateKey!; + final myPrivateKey = (await deriveNotificationBip32Node()).privateKey!; final S = SecretPoint(myPrivateKey, pubKey); @@ -864,12 +967,15 @@ mixin PaynymWalletInterface { unBlind: true, ); - final unBlindedPaymentCode = PaymentCode.fromPayload(unBlindedPayload); + final unBlindedPaymentCode = PaymentCode.fromPayload( + unBlindedPayload, + networkType: _network, + ); return unBlindedPaymentCode; } catch (e) { Logging.instance.log( - "unBlindedPaymentCodeFromTransaction() failed: $e", + "unBlindedPaymentCodeFromTransaction() failed: $e\nFor tx: $transaction", level: LogLevel.Warning, ); return null; @@ -878,13 +984,7 @@ mixin PaynymWalletInterface { Future unBlindedPaymentCodeFromTransactionBad({ required Transaction transaction, - required Address myNotificationAddress, }) async { - if (transaction.address.value != null && - transaction.address.value!.value != myNotificationAddress.value) { - return null; - } - try { final blindedCodeBytes = Bip47Utils.getBlindedPaymentCodeBytesFrom(transaction); @@ -906,11 +1006,7 @@ mixin PaynymWalletInterface { final pubKey = _pubKeyFromInput(designatedInput)!; - final myPrivateKey = (await deriveNotificationBip32Node( - mnemonic: (await _getMnemonicString())!, - mnemonicPassphrase: (await _getMnemonicPassphrase())!, - )) - .privateKey!; + final myPrivateKey = (await deriveNotificationBip32Node()).privateKey!; final S = SecretPoint(myPrivateKey, pubKey); @@ -922,12 +1018,15 @@ mixin PaynymWalletInterface { unBlind: true, ); - final unBlindedPaymentCode = PaymentCode.fromPayload(unBlindedPayload); + final unBlindedPaymentCode = PaymentCode.fromPayload( + unBlindedPayload, + networkType: _network, + ); return unBlindedPaymentCode; } catch (e) { Logging.instance.log( - "unBlindedPaymentCodeFromTransaction() failed: $e", + "unBlindedPaymentCodeFromTransactionBad() failed: $e\nFor tx: $transaction", level: LogLevel.Warning, ); return null; @@ -936,8 +1035,6 @@ mixin PaynymWalletInterface { Future> getAllPaymentCodesFromNotificationTransactions() async { - final myAddress = - await getMyNotificationAddress(DerivePathTypeExt.primaryFor(_coin)); final txns = await _db .getTransactions(_walletId) .filter() @@ -954,13 +1051,17 @@ mixin PaynymWalletInterface { await paymentCodeStringByKey(tx.address.value!.otherData!); if (codeString != null && codes.where((e) => e.toString() == codeString).isEmpty) { - codes.add(PaymentCode.fromPaymentCode(codeString, _network)); + codes.add( + PaymentCode.fromPaymentCode( + codeString, + networkType: _network, + ), + ); } } else { // otherwise we need to un blind the code final unBlinded = await unBlindedPaymentCodeFromTransaction( transaction: tx, - myNotificationAddress: myAddress, ); if (unBlinded != null && codes.where((e) => e.toString() == unBlinded.toString()).isEmpty) { @@ -969,7 +1070,6 @@ mixin PaynymWalletInterface { final unBlindedBad = await unBlindedPaymentCodeFromTransactionBad( transaction: tx, - myNotificationAddress: myAddress, ); if (unBlindedBad != null && codes @@ -995,7 +1095,7 @@ mixin PaynymWalletInterface { final List codes = []; for (final codeString in otherCodeStrings) { - codes.add(PaymentCode.fromPaymentCode(codeString, _network)); + codes.add(PaymentCode.fromPaymentCode(codeString, networkType: _network)); } for (final tx in sentNotificationTransactions) { @@ -1031,7 +1131,10 @@ mixin PaynymWalletInterface { final List extraCodes = []; for (final codeString in paymentCodeStrings) { if (codes.where((e) => e.toString() == codeString).isEmpty) { - final extraCode = PaymentCode.fromPaymentCode(codeString, _network); + final extraCode = PaymentCode.fromPaymentCode( + codeString, + networkType: _network, + ); if (extraCode.isValid()) { extraCodes.add(extraCode); } @@ -1044,9 +1147,10 @@ mixin PaynymWalletInterface { for (final code in codes) { futures.add( restoreHistoryWith( - code, - maxUnusedAddressGap, - maxNumberOfIndexesToCheck, + other: code, + maxUnusedAddressGap: maxUnusedAddressGap, + maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, + checkSegwitAsWell: code.isSegWitEnabled(), ), ); } @@ -1054,77 +1158,34 @@ mixin PaynymWalletInterface { await Future.wait(futures); } - Future restoreHistoryWith( - PaymentCode other, - int maxUnusedAddressGap, - int maxNumberOfIndexesToCheck, - ) async { + Future restoreHistoryWith({ + required PaymentCode other, + required bool checkSegwitAsWell, + required int maxUnusedAddressGap, + required int maxNumberOfIndexesToCheck, + }) async { // https://en.bitcoin.it/wiki/BIP_0047#Path_levels const maxCount = 2147483647; assert(maxNumberOfIndexesToCheck < maxCount); - final mnemonic = (await _getMnemonicString())!; - final mnemonicPassphrase = (await _getMnemonicPassphrase())!; - - final mySendBip32Node = await deriveNotificationBip32Node( - mnemonic: mnemonic, - mnemonicPassphrase: mnemonicPassphrase, - ); - final receivingNode = (await _getRootNode( - mnemonic: mnemonic, - mnemonicPassphrase: mnemonicPassphrase, - )) - .derivePath(kPaynymDerivePath); + final mySendBip32Node = await deriveNotificationBip32Node(); List
addresses = []; int receivingGapCounter = 0; int outgoingGapCounter = 0; + // non segwit receiving for (int i = 0; i < maxNumberOfIndexesToCheck && - (receivingGapCounter < maxUnusedAddressGap || - outgoingGapCounter < maxUnusedAddressGap); + receivingGapCounter < maxUnusedAddressGap; i++) { - if (outgoingGapCounter < maxUnusedAddressGap) { - final paymentAddressSending = PaymentAddress( - paymentCode: other, - bip32Node: mySendBip32Node, - index: i, - networkType: networkType, - ); - final pair = paymentAddressSending.getSendAddressKeyPair(); - final address = await generatePaynymSendAddressFromKeyPair( - pair: pair, - derivationIndex: i, - derivePathType: DerivePathType.bip44, - toPaymentCode: other, - ); - addresses.add(address); - - final count = await _getTxCount(address: address.value); - - if (count > 0) { - outgoingGapCounter = 0; - } else { - outgoingGapCounter++; - } - } - if (receivingGapCounter < maxUnusedAddressGap) { - final paymentAddressReceiving = PaymentAddress( - paymentCode: other, - bip32Node: receivingNode.derive(i), - index: 0, - networkType: networkType, + final address = await _generatePaynymReceivingAddress( + sender: other, + index: i, + generateSegwitAddress: false, ); - final pair = paymentAddressReceiving.getReceiveAddressKeyPair(); - final address = await generatePaynymReceivingAddressFromKeyPair( - pair: pair, - derivationIndex: i, - derivePathType: DerivePathType.bip44, - fromPaymentCode: other, - ); addresses.add(address); final count = await _getTxCount(address: address.value); @@ -1136,182 +1197,94 @@ mixin PaynymWalletInterface { } } } + + // non segwit sends + for (int i = 0; + i < maxNumberOfIndexesToCheck && + outgoingGapCounter < maxUnusedAddressGap; + i++) { + if (outgoingGapCounter < maxUnusedAddressGap) { + final address = await _generatePaynymSendAddress( + other: other, + index: i, + generateSegwitAddress: false, + mySendBip32Node: mySendBip32Node, + ); + + addresses.add(address); + + final count = await _getTxCount(address: address.value); + + if (count > 0) { + outgoingGapCounter = 0; + } else { + outgoingGapCounter++; + } + } + } + + if (checkSegwitAsWell) { + int receivingGapCounterSegwit = 0; + int outgoingGapCounterSegwit = 0; + // segwit receiving + for (int i = 0; + i < maxNumberOfIndexesToCheck && + receivingGapCounterSegwit < maxUnusedAddressGap; + i++) { + if (receivingGapCounterSegwit < maxUnusedAddressGap) { + final address = await _generatePaynymReceivingAddress( + sender: other, + index: i, + generateSegwitAddress: true, + ); + + addresses.add(address); + + final count = await _getTxCount(address: address.value); + + if (count > 0) { + receivingGapCounterSegwit = 0; + } else { + receivingGapCounterSegwit++; + } + } + } + + // segwit sends + for (int i = 0; + i < maxNumberOfIndexesToCheck && + outgoingGapCounterSegwit < maxUnusedAddressGap; + i++) { + if (outgoingGapCounterSegwit < maxUnusedAddressGap) { + final address = await _generatePaynymSendAddress( + other: other, + index: i, + generateSegwitAddress: true, + mySendBip32Node: mySendBip32Node, + ); + + addresses.add(address); + + final count = await _getTxCount(address: address.value); + + if (count > 0) { + outgoingGapCounterSegwit = 0; + } else { + outgoingGapCounterSegwit++; + } + } + } + } await _db.updateOrPutAddresses(addresses); } - Future
generatePaynymSendAddressFromKeyPair({ - required btc_dart.ECPair pair, - required int derivationIndex, - required DerivePathType derivePathType, - required PaymentCode toPaymentCode, - }) async { - final data = btc_dart.PaymentData(pubkey: pair.publicKey); - - String addressString; - switch (derivePathType) { - case DerivePathType.bip44: - addressString = - btc_dart.P2PKH(data: data, network: _network).data.address!; - break; - - // The following doesn't apply currently - // case DerivePathType.bip49: - // addressString = btc_dart - // .P2SH( - // data: btc_dart.PaymentData( - // redeem: btc_dart - // .P2WPKH( - // data: data, - // network: network, - // ) - // .data), - // network: network, - // ) - // .data - // .address!; - // break; - // - // case DerivePathType.bip84: - // addressString = btc_dart - // .P2WPKH( - // network: network, - // data: data, - // ) - // .data - // .address!; - // break; - default: - throw UnimplementedError("segwit paynyms not implemented yet"); - } - - final address = Address( - walletId: _walletId, - value: addressString, - publicKey: pair.publicKey, - derivationIndex: derivationIndex, - derivationPath: - null, // might as well use null due to complexity of context - type: AddressType.nonWallet, - subType: AddressSubType.paynymSend, - otherData: await storeCode(toPaymentCode.toString()), - ); - - return address; - } - - Future
generatePaynymReceivingAddressFromKeyPair({ - required btc_dart.ECPair pair, - required int derivationIndex, - required DerivePathType derivePathType, - required PaymentCode fromPaymentCode, - }) async { - final data = btc_dart.PaymentData(pubkey: pair.publicKey); - - String addressString; - AddressType addrType; - switch (derivePathType) { - case DerivePathType.bip44: - addressString = btc_dart - .P2PKH( - data: data, - network: _network, - ) - .data - .address!; - addrType = AddressType.p2pkh; - break; - - // The following doesn't apply currently - // case DerivePathType.bip49: - // addressString = btc_dart - // .P2SH( - // data: btc_dart.PaymentData( - // redeem: btc_dart - // .P2WPKH( - // data: data, - // network: network, - // ) - // .data), - // network: network, - // ) - // .data - // .address!; - // addrType = AddressType.p2sh; - // break; - // - // case DerivePathType.bip84: - // addressString = btc_dart - // .P2WPKH( - // network: network, - // data: data, - // ) - // .data - // .address!; - // addrType = AddressType.p2wpkh; - // break; - default: - throw UnimplementedError("segwit paynyms not implemented yet"); - } - - final address = Address( - walletId: _walletId, - value: addressString, - publicKey: pair.publicKey, - derivationIndex: derivationIndex, - derivationPath: DerivationPath() - ..value = _receivingPaynymAddressDerivationPath(derivationIndex), - type: addrType, - subType: AddressSubType.paynymReceive, - otherData: await storeCode(fromPaymentCode.toString()), - ); - - final myCode = await getPaymentCode(DerivePathType.bip44); - - final bip32NetworkType = bip32.NetworkType( - wif: _network.wif, - bip32: bip32.Bip32Type( - public: _network.bip32.public, - private: _network.bip32.private, - ), - ); - - final bip32.BIP32 node = bip32.BIP32.fromPrivateKey( - pair.privateKey!, - myCode.getChain(), - bip32NetworkType, - ); - - return address; - } - - Future
getMyNotificationAddress( - DerivePathType derivePathType, [ - bip32.BIP32? bip32Root, - ]) async { - // TODO: fix when segwit is here - derivePathType = DerivePathType.bip44; - - AddressType type; - switch (derivePathType) { - case DerivePathType.bip44: - type = AddressType.p2pkh; - break; - case DerivePathType.bip49: - type = AddressType.p2sh; - break; - case DerivePathType.bip84: - type = AddressType.p2wpkh; - break; - default: - throw Exception("DerivePathType $derivePathType not supported"); - } - + Future
getMyNotificationAddress() async { final storedAddress = await _db .getAddresses(_walletId) .filter() .subTypeEqualTo(AddressSubType.paynymNotification) .and() - .typeEqualTo(type) + .typeEqualTo(AddressType.p2pkh) .and() .not() .typeEqualTo(AddressType.nonWallet) @@ -1320,71 +1293,67 @@ mixin PaynymWalletInterface { if (storedAddress != null) { return storedAddress; } else { - final root = bip32Root ?? - await _getRootNode( - mnemonic: (await _getMnemonicString())!, - mnemonicPassphrase: (await _getMnemonicPassphrase())!, - ); - final node = root.derivePath(kPaynymDerivePath); + final root = await _getRootNode(); + final node = root.derivePath( + _basePaynymDerivePath( + testnet: _coin.isTestNet, + ), + ); final paymentCode = PaymentCode.fromBip32Node( node, - _network, + networkType: _network, + shouldSetSegwitBit: false, ); - String addressString; - final data = - btc_dart.PaymentData(pubkey: paymentCode.notificationPublicKey()); - switch (derivePathType) { - case DerivePathType.bip44: - addressString = btc_dart - .P2PKH( - data: data, - network: _network, - ) - .data - .address!; - break; - // case DerivePathType.bip49: - // addressString = btc_dart - // .P2SH( - // data: btc_dart.PaymentData( - // redeem: btc_dart - // .P2WPKH( - // data: data, - // network: network, - // ) - // .data), - // network: network, - // ) - // .data - // .address!; - // break; - // case DerivePathType.bip84: - // addressString = btc_dart - // .P2WPKH( - // network: network, - // data: data, - // ) - // .data - // .address!; - // break; - default: - throw UnimplementedError("segwit paynyms not implemented yet"); - } + final data = btc_dart.PaymentData( + pubkey: paymentCode.notificationPublicKey(), + ); - final address = Address( + final addressString = btc_dart + .P2PKH( + data: data, + network: _network, + ) + .data + .address!; + + Address address = Address( walletId: _walletId, value: addressString, publicKey: paymentCode.getPubKey(), derivationIndex: 0, derivationPath: DerivationPath() - ..value = kPaynymNotificationDerivationPath, - type: type, + ..value = _notificationDerivationPath( + testnet: _coin.isTestNet, + ), + type: AddressType.p2pkh, subType: AddressSubType.paynymNotification, otherData: await storeCode(paymentCode.toString()), ); - await _db.putAddress(address); + // check against possible race condition. Ff this function was called + // multiple times an address could've been saved after the check at the + // beginning to see if there already was notification address. This would + // lead to a Unique Index violation error + await _db.isar.writeTxn(() async { + final storedAddress = await _db + .getAddresses(_walletId) + .filter() + .subTypeEqualTo(AddressSubType.paynymNotification) + .and() + .typeEqualTo(AddressType.p2pkh) + .and() + .not() + .typeEqualTo(AddressType.nonWallet) + .findFirst(); + + if (storedAddress == null) { + await _db.isar.addresses.put(address); + } else { + address = storedAddress; + } + }); + return address; } } @@ -1430,5 +1399,3 @@ mixin PaynymWalletInterface { List.generate(n, (_) => rng.nextInt(0xFF + 1))); } } - -const String kPCodeKeyPrefix = "pCode_key_"; diff --git a/lib/utilities/assets.dart b/lib/utilities/assets.dart index b2adfdce5..b6e77f878 100644 --- a/lib/utilities/assets.dart +++ b/lib/utilities/assets.dart @@ -206,7 +206,7 @@ class _SVG { String get pending => "assets/svg/pending.svg"; String get radio => "assets/svg/signal-stream.svg"; String get arrowRotate => "assets/svg/arrow-rotate.svg"; - String get arrowRotate2 => "assets/svg/arrow-rotate2.svg"; + String get arrowsTwoWay => "assets/svg/arrow-rotate2.svg"; String get alertCircle => "assets/svg/alert-circle.svg"; String get checkCircle => "assets/svg/circle-check.svg"; String get clipboard => "assets/svg/clipboard.svg"; @@ -222,7 +222,6 @@ class _SVG { String get networkWired => "assets/svg/network-wired-2.svg"; String get addressBook => "assets/svg/address-book.svg"; String get addressBook2 => "assets/svg/address-book2.svg"; - String get arrowRotate3 => "assets/svg/rotate-exclamation.svg"; String get delete => "assets/svg/delete.svg"; String get arrowRight => "assets/svg/arrow-right.svg"; String get dollarSign => "assets/svg/dollar-sign.svg"; @@ -417,6 +416,7 @@ class _ANIMATIONS { String get test2 => "assets/lottie/test2.json"; String get iconSend => "assets/lottie/icon_send.json"; String get loaderAndCheckmark => "assets/lottie/loader_and_checkmark.json"; + String get arrowRotate => "assets/lottie/arrow_rotate.json"; } class _GIF { diff --git a/lib/utilities/paynym_is_api.dart b/lib/utilities/paynym_is_api.dart index 7d1fc79ed..edbd4f416 100644 --- a/lib/utilities/paynym_is_api.dart +++ b/lib/utilities/paynym_is_api.dart @@ -25,14 +25,18 @@ class PaynymIsApi { version + (endpoint.startsWith("/") ? endpoint : "/$endpoint"); final uri = Uri.parse(url); + final headers = { + 'Content-Type': 'application/json; charset=UTF-8', + }..addAll(additionalHeaders); final response = await http.post( uri, - headers: { - 'Content-Type': 'application/json; charset=UTF-8', - }..addAll(additionalHeaders), + headers: headers, body: jsonEncode(body), ); + debugPrint("Paynym request uri: $uri"); + debugPrint("Paynym request body: $body"); + debugPrint("Paynym request headers: $headers"); debugPrint("Paynym response code: ${response.statusCode}"); debugPrint("Paynym response body: ${response.body}"); @@ -543,24 +547,44 @@ class PaynymIsApi { // | 401 | Unauthorized token or signature or Unclaimed payment code | // // ------ + Future> add( + String token, + String signature, + String nym, + String code, + ) async { + final result = await _post( + "/nym/add", + { + "nym": nym, + "code": code, + "signature": signature, + }, + { + "auth-token": token, + }, + ); -// NOT USED - // Future> add( - // String token, - // String signature, - // String nym, - // String code, - // ) async { - // return _post( - // "/add", - // { - // "nym": nym, - // "code": code, - // "signature": signature, - // }, - // { - // "auth-token": token, - // }, - // ); - // } + String message; + bool value = false; + + switch (result.item2) { + case 200: + message = "Code added successfully"; + value = true; + break; + case 400: + message = "Bad request"; + break; + case 401: + message = "Unauthorized token or signature or Unclaimed payment code"; + break; + case 404: + message = "Nym not found"; + break; + default: + message = result.item1["message"] as String? ?? "Unknown error"; + } + return PaynymResponse(value, result.item2, message); + } } diff --git a/lib/widgets/animated_widgets/rotating_arrows.dart b/lib/widgets/animated_widgets/rotating_arrows.dart new file mode 100644 index 000000000..19edab1c9 --- /dev/null +++ b/lib/widgets/animated_widgets/rotating_arrows.dart @@ -0,0 +1,87 @@ +import 'package:flutter/material.dart'; +import 'package:lottie/lottie.dart'; +import 'package:stackwallet/utilities/assets.dart'; +import 'package:stackwallet/utilities/theme/stack_colors.dart'; + +class RotatingArrowsController { + VoidCallback? forward; + VoidCallback? repeat; + VoidCallback? stop; +} + +class RotatingArrows extends StatefulWidget { + const RotatingArrows({ + Key? key, + required this.height, + required this.width, + this.controller, + this.color, + this.spinByDefault = true, + }) : super(key: key); + + final double height; + final double width; + final RotatingArrowsController? controller; + final Color? color; + final bool spinByDefault; + + @override + State createState() => _RotatingArrowsState(); +} + +class _RotatingArrowsState extends State + with SingleTickerProviderStateMixin { + late final AnimationController animationController; + + @override + void initState() { + animationController = AnimationController(vsync: this); + + widget.controller?.forward = animationController.forward; + widget.controller?.repeat = animationController.repeat; + widget.controller?.stop = animationController.stop; + + super.initState(); + } + + @override + void dispose() { + animationController.dispose(); + widget.controller?.forward = null; + widget.controller?.repeat = null; + widget.controller?.stop = null; + super.dispose(); + } + + @override + Widget build(BuildContext context) { + return Lottie.asset( + Assets.lottie.arrowRotate, + controller: animationController, + height: widget.height, + width: widget.width, + delegates: LottieDelegates( + values: [ + ValueDelegate.color( + const ["**"], + value: widget.color ?? + Theme.of(context).extension()!.accentColorDark, + ), + ValueDelegate.strokeColor( + const ["**"], + value: widget.color ?? + Theme.of(context).extension()!.accentColorDark, + ), + ], + ), + onLoaded: (composition) { + animationController.duration = composition.duration; + + // if controller was not set just assume continuous repeat + if (widget.spinByDefault) { + animationController.repeat(); + } + }, + ); + } +} diff --git a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart index e4235fef4..4c6733e96 100644 --- a/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart +++ b/lib/widgets/custom_buttons/paynym_follow_toggle_button.dart @@ -11,7 +11,6 @@ import 'package:stackwallet/providers/global/wallets_provider.dart'; import 'package:stackwallet/providers/wallet/my_paynym_account_state_provider.dart'; import 'package:stackwallet/services/mixins/paynym_wallet_interface.dart'; import 'package:stackwallet/utilities/assets.dart'; -import 'package:stackwallet/utilities/enums/derive_path_type_enum.dart'; import 'package:stackwallet/utilities/theme/stack_colors.dart'; import 'package:stackwallet/utilities/util.dart'; import 'package:stackwallet/widgets/desktop/primary_button.dart'; @@ -68,8 +67,7 @@ class _PaynymFollowToggleButtonState .read(paynymAPIProvider) .nym(widget.paymentCodeStringToFollow, true); - final myPCode = - await wallet.getPaymentCode(DerivePathTypeExt.primaryFor(manager.coin)); + final myPCode = await wallet.getPaymentCode(isSegwit: false); PaynymResponse token = await ref.read(paynymAPIProvider).token(myPCode.toString()); @@ -77,8 +75,8 @@ class _PaynymFollowToggleButtonState // sign token with notification private key String signature = await wallet.signStringWithNotificationKey(token.value!); - var result = await ref.read(paynymAPIProvider).follow( - token.value!, signature, followedAccount.value!.codes.first.code); + var result = await ref.read(paynymAPIProvider).follow(token.value!, + signature, followedAccount.value!.nonSegwitPaymentCode.code); int i = 0; for (; @@ -90,8 +88,8 @@ class _PaynymFollowToggleButtonState // sign token with notification private key signature = await wallet.signStringWithNotificationKey(token.value!); - result = await ref.read(paynymAPIProvider).follow( - token.value!, signature, followedAccount.value!.codes.first.code); + result = await ref.read(paynymAPIProvider).follow(token.value!, signature, + followedAccount.value!.nonSegwitPaymentCode.code); await Future.delayed(const Duration(milliseconds: 200)); print("RRR result: $result"); @@ -118,8 +116,8 @@ class _PaynymFollowToggleButtonState PaynymAccountLite( followedAccount.value!.nymID, followedAccount.value!.nymName, - followedAccount.value!.codes.first.code, - followedAccount.value!.codes.first.segwit, + followedAccount.value!.nonSegwitPaymentCode.code, + followedAccount.value!.segwit, ), ); @@ -169,8 +167,7 @@ class _PaynymFollowToggleButtonState .read(paynymAPIProvider) .nym(widget.paymentCodeStringToFollow, true); - final myPCode = - await wallet.getPaymentCode(DerivePathTypeExt.primaryFor(manager.coin)); + final myPCode = await wallet.getPaymentCode(isSegwit: false); PaynymResponse token = await ref.read(paynymAPIProvider).token(myPCode.toString()); @@ -178,8 +175,8 @@ class _PaynymFollowToggleButtonState // sign token with notification private key String signature = await wallet.signStringWithNotificationKey(token.value!); - var result = await ref.read(paynymAPIProvider).unfollow( - token.value!, signature, followedAccount.value!.codes.first.code); + var result = await ref.read(paynymAPIProvider).unfollow(token.value!, + signature, followedAccount.value!.nonSegwitPaymentCode.code); int i = 0; for (; @@ -191,8 +188,8 @@ class _PaynymFollowToggleButtonState // sign token with notification private key signature = await wallet.signStringWithNotificationKey(token.value!); - result = await ref.read(paynymAPIProvider).unfollow( - token.value!, signature, followedAccount.value!.codes.first.code); + result = await ref.read(paynymAPIProvider).unfollow(token.value!, + signature, followedAccount.value!.nonSegwitPaymentCode.code); await Future.delayed(const Duration(milliseconds: 200)); print("unfollow RRR result: $result"); } diff --git a/lib/widgets/custom_pin_put/pin_keyboard.dart b/lib/widgets/custom_pin_put/pin_keyboard.dart index 86c5bddd3..954bd257c 100644 --- a/lib/widgets/custom_pin_put/pin_keyboard.dart +++ b/lib/widgets/custom_pin_put/pin_keyboard.dart @@ -1,4 +1,5 @@ import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:flutter_svg/flutter_svg.dart'; import 'package:stackwallet/utilities/assets.dart'; import 'package:stackwallet/utilities/text_styles.dart'; @@ -276,6 +277,7 @@ class PinKeyboard extends StatelessWidget { void _numberHandler(String number) { onNumberKeyPressed.call(number); + HapticFeedback.lightImpact(); } @override diff --git a/pubspec.lock b/pubspec.lock index 704bbe10e..d9654c4b6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -111,11 +111,11 @@ packages: dependency: "direct main" description: path: "." - ref: "48dd65f88822fba8543826274f6d51c17f735f93" - resolved-ref: "48dd65f88822fba8543826274f6d51c17f735f93" + ref: "38847255d035c0f6ec5bc93d19130ec804cf90e9" + resolved-ref: "38847255d035c0f6ec5bc93d19130ec804cf90e9" url: "https://github.com/cypherstack/bip47.git" source: git - version: "1.0.0" + version: "2.0.0" bitbox: dependency: "direct main" description: diff --git a/pubspec.yaml b/pubspec.yaml index 21a017673..d84d0d15d 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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.2+162 +version: 1.7.4+164 environment: sdk: ">=2.17.0 <3.0.0" @@ -60,7 +60,7 @@ dependencies: bip47: git: url: https://github.com/cypherstack/bip47.git - ref: 48dd65f88822fba8543826274f6d51c17f735f93 + ref: 38847255d035c0f6ec5bc93d19130ec804cf90e9 # Utility plugins # provider: ^6.0.1 @@ -248,7 +248,6 @@ flutter: - assets/svg/chevron-up.svg - assets/svg/lock-keyhole.svg - assets/svg/lock-open.svg - - assets/svg/rotate-exclamation.svg - assets/svg/folder-down.svg - assets/svg/network-wired.svg - assets/svg/network-wired-2.svg @@ -383,6 +382,7 @@ flutter: - assets/lottie/test2.json - assets/lottie/icon_send.json - assets/lottie/loader_and_checkmark.json + - assets/lottie/arrow_rotate.json # gifs - assets/gif/ diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index 7c8c5e4a1..fda4f4c21 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -7,7 +7,7 @@ import 'dart:async' as _i23; import 'dart:typed_data' as _i30; import 'dart:ui' as _i25; -import 'package:bip32/bip32.dart' as _i18; +import 'package:bip32/bip32.dart' as _i17; import 'package:bip47/bip47.dart' as _i19; import 'package:bitcoindart/bitcoindart.dart' as _i14; import 'package:flutter/foundation.dart' as _i4; @@ -17,7 +17,7 @@ import 'package:stackwallet/db/isar/main_db.dart' as _i13; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i11; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i10; import 'package:stackwallet/models/balance.dart' as _i12; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i17; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i18; import 'package:stackwallet/models/node_model.dart' as _i26; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i9; import 'package:stackwallet/models/signing_data.dart' as _i29; @@ -209,8 +209,8 @@ class _FakeTuple2_14 extends _i1.SmartFake ); } -class _FakeAddress_15 extends _i1.SmartFake implements _i17.Address { - _FakeAddress_15( +class _FakeBIP32_15 extends _i1.SmartFake implements _i17.BIP32 { + _FakeBIP32_15( Object parent, Invocation parentInvocation, ) : super( @@ -219,8 +219,8 @@ class _FakeAddress_15 extends _i1.SmartFake implements _i17.Address { ); } -class _FakeBIP32_16 extends _i1.SmartFake implements _i18.BIP32 { - _FakeBIP32_16( +class _FakeAddress_16 extends _i1.SmartFake implements _i18.Address { + _FakeAddress_16( Object parent, Invocation parentInvocation, ) : super( @@ -987,16 +987,16 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValue: _i22.Coin.bitcoin, ) as _i22.Coin); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i17.UTXO>[]), - ) as _i23.Future>); + returnValue: _i23.Future>.value(<_i18.UTXO>[]), + ) as _i23.Future>); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i17.Transaction>[]), - ) as _i23.Future>); + _i23.Future>.value(<_i18.Transaction>[]), + ) as _i23.Future>); @override _i23.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), @@ -1406,7 +1406,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { required bool? coinControl, required bool? isSendAll, int? additionalOutputs = 0, - List<_i17.UTXO>? utxos, + List<_i18.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1423,7 +1423,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { )); @override _i23.Future> fetchBuildTxData( - List<_i17.UTXO>? utxosToUse) => + List<_i18.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, @@ -1677,10 +1677,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i16.Tuple2<_i17.Transaction, _i17.Address>> parseTransaction( + _i23.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>> parseTransaction( Map? txData, dynamic electrumxClient, - List<_i17.Address>? myAddresses, + List<_i18.Address>? myAddresses, _i22.Coin? coin, int? minConfirms, String? walletId, @@ -1698,8 +1698,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { ], ), returnValue: - _i23.Future<_i16.Tuple2<_i17.Transaction, _i17.Address>>.value( - _FakeTuple2_14<_i17.Transaction, _i17.Address>( + _i23.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>>.value( + _FakeTuple2_14<_i18.Transaction, _i18.Address>( this, Invocation.method( #parseTransaction, @@ -1713,7 +1713,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { ], ), )), - ) as _i23.Future<_i16.Tuple2<_i17.Transaction, _i17.Address>>); + ) as _i23.Future<_i16.Tuple2<_i18.Transaction, _i18.Address>>); @override void initPaynymWalletInterface({ required String? walletId, @@ -1723,6 +1723,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { required _i13.MainDB? db, required _i10.ElectrumX? electrumXClient, required _i7.SecureStorageInterface? secureStorage, + required int? dustLimit, required int? dustLimitP2PKH, required int? minConfirms, required _i23.Future Function()? getMnemonicString, @@ -1741,7 +1742,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { })? prepareSend, required _i23.Future Function({required String address})? getTxCount, - required _i23.Future> Function(List<_i17.UTXO>)? + required _i23.Future> Function(List<_i18.UTXO>)? fetchBuildTxData, required _i23.Future Function()? refresh, required _i23.Future Function()? checkChangeAddressForTransactions, @@ -1758,6 +1759,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { #db: db, #electrumXClient: electrumXClient, #secureStorage: secureStorage, + #dustLimit: dustLimit, #dustLimitP2PKH: dustLimitP2PKH, #minConfirms: minConfirms, #getMnemonicString: getMnemonicString, @@ -1776,28 +1778,74 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i17.Address> currentReceivingPaynymAddress( - _i19.PaymentCode? sender) => + _i23.Future<_i17.BIP32> getBip47BaseNode() => (super.noSuchMethod( + Invocation.method( + #getBip47BaseNode, + [], + ), + returnValue: _i23.Future<_i17.BIP32>.value(_FakeBIP32_15( + this, + Invocation.method( + #getBip47BaseNode, + [], + ), + )), + ) as _i23.Future<_i17.BIP32>); + @override + _i23.Future<_i30.Uint8List> getPrivateKeyForPaynymReceivingAddress({ + required String? paymentCodeString, + required int? index, + }) => + (super.noSuchMethod( + Invocation.method( + #getPrivateKeyForPaynymReceivingAddress, + [], + { + #paymentCodeString: paymentCodeString, + #index: index, + }, + ), + returnValue: _i23.Future<_i30.Uint8List>.value(_i30.Uint8List(0)), + ) as _i23.Future<_i30.Uint8List>); + @override + _i23.Future<_i18.Address> currentReceivingPaynymAddress({ + required _i19.PaymentCode? sender, + required bool? isSegwit, + }) => (super.noSuchMethod( Invocation.method( #currentReceivingPaynymAddress, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), - returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i23.Future<_i18.Address>.value(_FakeAddress_16( this, Invocation.method( #currentReceivingPaynymAddress, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), )), - ) as _i23.Future<_i17.Address>); + ) as _i23.Future<_i18.Address>); @override - _i23.Future checkCurrentPaynymReceivingAddressForTransactions( - _i19.PaymentCode? sender) => + _i23.Future checkCurrentPaynymReceivingAddressForTransactions({ + required _i19.PaymentCode? sender, + required bool? isSegwit, + }) => (super.noSuchMethod( Invocation.method( #checkCurrentPaynymReceivingAddressForTransactions, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), returnValue: _i23.Future.value(), returnValueForMissingStub: _i23.Future.value(), @@ -1813,81 +1861,33 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future<_i18.BIP32> deriveNotificationBip32Node({ - required String? mnemonic, - required String? mnemonicPassphrase, - }) => - (super.noSuchMethod( + _i23.Future<_i17.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( Invocation.method( #deriveNotificationBip32Node, [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - }, ), - returnValue: _i23.Future<_i18.BIP32>.value(_FakeBIP32_16( + returnValue: _i23.Future<_i17.BIP32>.value(_FakeBIP32_15( this, Invocation.method( #deriveNotificationBip32Node, [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - }, ), )), - ) as _i23.Future<_i18.BIP32>); + ) as _i23.Future<_i17.BIP32>); @override - _i23.Future<_i18.BIP32> deriveReceivingPrivateKeyNode({ - required String? mnemonic, - required String? mnemonicPassphrase, - required int? index, - }) => - (super.noSuchMethod( - Invocation.method( - #deriveReceivingPrivateKeyNode, - [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - #index: index, - }, - ), - returnValue: _i23.Future<_i18.BIP32>.value(_FakeBIP32_16( - this, - Invocation.method( - #deriveReceivingPrivateKeyNode, - [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - #index: index, - }, - ), - )), - ) as _i23.Future<_i18.BIP32>); - @override - _i23.Future<_i19.PaymentCode> getPaymentCode( - _i28.DerivePathType? derivePathType, [ - _i18.BIP32? bip32Root, - ]) => + _i23.Future<_i19.PaymentCode> getPaymentCode({required bool? isSegwit}) => (super.noSuchMethod( Invocation.method( #getPaymentCode, - [ - derivePathType, - bip32Root, - ], + [], + {#isSegwit: isSegwit}, ), returnValue: _i23.Future<_i19.PaymentCode>.value(_FakePaymentCode_17( this, Invocation.method( #getPaymentCode, - [ - derivePathType, - bip32Root, - ], + [], + {#isSegwit: isSegwit}, ), )), ) as _i23.Future<_i19.PaymentCode>); @@ -1912,6 +1912,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { @override _i23.Future> preparePaymentCodeSend({ required _i19.PaymentCode? paymentCode, + required bool? isSegwit, required _i15.Amount? amount, Map? args, }) => @@ -1921,6 +1922,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { [], { #paymentCode: paymentCode, + #isSegwit: isSegwit, #amount: amount, #args: args, }, @@ -1929,9 +1931,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { _i23.Future>.value({}), ) as _i23.Future>); @override - _i23.Future<_i17.Address> nextUnusedSendAddressFrom({ + _i23.Future<_i18.Address> nextUnusedSendAddressFrom({ required _i19.PaymentCode? pCode, - required _i18.BIP32? privateKeyNode, + required bool? isSegwit, + required _i17.BIP32? privateKeyNode, int? startIndex = 0, }) => (super.noSuchMethod( @@ -1940,29 +1943,31 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { [], { #pCode: pCode, + #isSegwit: isSegwit, #privateKeyNode: privateKeyNode, #startIndex: startIndex, }, ), - returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i23.Future<_i18.Address>.value(_FakeAddress_16( this, Invocation.method( #nextUnusedSendAddressFrom, [], { #pCode: pCode, + #isSegwit: isSegwit, #privateKeyNode: privateKeyNode, #startIndex: startIndex, }, ), )), - ) as _i23.Future<_i17.Address>); + ) as _i23.Future<_i18.Address>); @override _i23.Future> prepareNotificationTx({ required int? selectedTxFeeRate, required String? targetPaymentCodeString, int? additionalOutputs = 0, - List<_i17.UTXO>? utxos, + List<_i18.UTXO>? utxos, }) => (super.noSuchMethod( Invocation.method( @@ -1999,34 +2004,24 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValue: _i23.Future.value(false), ) as _i23.Future); @override - _i23.Future<_i19.PaymentCode?> unBlindedPaymentCodeFromTransaction({ - required _i17.Transaction? transaction, - required _i17.Address? myNotificationAddress, - }) => + _i23.Future<_i19.PaymentCode?> unBlindedPaymentCodeFromTransaction( + {required _i18.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransaction, [], - { - #transaction: transaction, - #myNotificationAddress: myNotificationAddress, - }, + {#transaction: transaction}, ), returnValue: _i23.Future<_i19.PaymentCode?>.value(), ) as _i23.Future<_i19.PaymentCode?>); @override - _i23.Future<_i19.PaymentCode?> unBlindedPaymentCodeFromTransactionBad({ - required _i17.Transaction? transaction, - required _i17.Address? myNotificationAddress, - }) => + _i23.Future<_i19.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( + {required _i18.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransactionBad, [], - { - #transaction: transaction, - #myNotificationAddress: myNotificationAddress, - }, + {#transaction: transaction}, ), returnValue: _i23.Future<_i19.PaymentCode?>.value(), ) as _i23.Future<_i19.PaymentCode?>); @@ -2071,111 +2066,40 @@ class MockBitcoinWallet extends _i1.Mock implements _i27.BitcoinWallet { returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future restoreHistoryWith( - _i19.PaymentCode? other, - int? maxUnusedAddressGap, - int? maxNumberOfIndexesToCheck, - ) => + _i23.Future restoreHistoryWith({ + required _i19.PaymentCode? other, + required bool? checkSegwitAsWell, + required int? maxUnusedAddressGap, + required int? maxNumberOfIndexesToCheck, + }) => (super.noSuchMethod( Invocation.method( #restoreHistoryWith, - [ - other, - maxUnusedAddressGap, - maxNumberOfIndexesToCheck, - ], + [], + { + #other: other, + #checkSegwitAsWell: checkSegwitAsWell, + #maxUnusedAddressGap: maxUnusedAddressGap, + #maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, + }, ), returnValue: _i23.Future.value(), returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future<_i17.Address> generatePaynymSendAddressFromKeyPair({ - required _i14.ECPair? pair, - required int? derivationIndex, - required _i28.DerivePathType? derivePathType, - required _i19.PaymentCode? toPaymentCode, - }) => - (super.noSuchMethod( - Invocation.method( - #generatePaynymSendAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #toPaymentCode: toPaymentCode, - }, - ), - returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( - this, - Invocation.method( - #generatePaynymSendAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #toPaymentCode: toPaymentCode, - }, - ), - )), - ) as _i23.Future<_i17.Address>); - @override - _i23.Future<_i17.Address> generatePaynymReceivingAddressFromKeyPair({ - required _i14.ECPair? pair, - required int? derivationIndex, - required _i28.DerivePathType? derivePathType, - required _i19.PaymentCode? fromPaymentCode, - }) => - (super.noSuchMethod( - Invocation.method( - #generatePaynymReceivingAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #fromPaymentCode: fromPaymentCode, - }, - ), - returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( - this, - Invocation.method( - #generatePaynymReceivingAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #fromPaymentCode: fromPaymentCode, - }, - ), - )), - ) as _i23.Future<_i17.Address>); - @override - _i23.Future<_i17.Address> getMyNotificationAddress( - _i28.DerivePathType? derivePathType, [ - _i18.BIP32? bip32Root, - ]) => - (super.noSuchMethod( + _i23.Future<_i18.Address> getMyNotificationAddress() => (super.noSuchMethod( Invocation.method( #getMyNotificationAddress, - [ - derivePathType, - bip32Root, - ], + [], ), - returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( + returnValue: _i23.Future<_i18.Address>.value(_FakeAddress_16( this, Invocation.method( #getMyNotificationAddress, - [ - derivePathType, - bip32Root, - ], + [], ), )), - ) as _i23.Future<_i17.Address>); + ) as _i23.Future<_i18.Address>); @override _i23.Future> lookupKey(String? paymentCodeString) => (super.noSuchMethod( @@ -2812,16 +2736,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i12.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i17.Transaction>[]), - ) as _i23.Future>); + _i23.Future>.value(<_i18.Transaction>[]), + ) as _i23.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i17.UTXO>[]), - ) as _i23.Future>); + returnValue: _i23.Future>.value(<_i18.UTXO>[]), + ) as _i23.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -3180,16 +3104,16 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { ), ) as _i12.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i17.Transaction>[]), - ) as _i23.Future>); + _i23.Future>.value(<_i18.Transaction>[]), + ) as _i23.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i17.UTXO>[]), - ) as _i23.Future>); + returnValue: _i23.Future>.value(<_i18.UTXO>[]), + ) as _i23.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index 4982f76bd..337eb47e4 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -7,7 +7,7 @@ import 'dart:async' as _i23; import 'dart:typed_data' as _i29; import 'dart:ui' as _i25; -import 'package:bip32/bip32.dart' as _i17; +import 'package:bip32/bip32.dart' as _i16; import 'package:bip47/bip47.dart' as _i18; import 'package:bitcoindart/bitcoindart.dart' as _i13; import 'package:flutter/foundation.dart' as _i4; @@ -17,7 +17,7 @@ import 'package:stackwallet/db/isar/main_db.dart' as _i12; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i10; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i9; import 'package:stackwallet/models/balance.dart' as _i11; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i16; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i17; import 'package:stackwallet/models/node_model.dart' as _i31; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/models/signing_data.dart' as _i28; @@ -194,8 +194,8 @@ class _FakeTuple2_13 extends _i1.SmartFake ); } -class _FakeAddress_14 extends _i1.SmartFake implements _i16.Address { - _FakeAddress_14( +class _FakeBIP32_14 extends _i1.SmartFake implements _i16.BIP32 { + _FakeBIP32_14( Object parent, Invocation parentInvocation, ) : super( @@ -204,8 +204,8 @@ class _FakeAddress_14 extends _i1.SmartFake implements _i16.Address { ); } -class _FakeBIP32_15 extends _i1.SmartFake implements _i17.BIP32 { - _FakeBIP32_15( +class _FakeAddress_15 extends _i1.SmartFake implements _i17.Address { + _FakeAddress_15( Object parent, Invocation parentInvocation, ) : super( @@ -779,16 +779,16 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValue: _i22.Coin.bitcoin, ) as _i22.Coin); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i16.UTXO>[]), - ) as _i23.Future>); + returnValue: _i23.Future>.value(<_i17.UTXO>[]), + ) as _i23.Future>); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i16.Transaction>[]), - ) as _i23.Future>); + _i23.Future>.value(<_i17.Transaction>[]), + ) as _i23.Future>); @override _i23.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), @@ -1197,7 +1197,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { required bool? coinControl, required bool? isSendAll, int? additionalOutputs = 0, - List<_i16.UTXO>? utxos, + List<_i17.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1214,7 +1214,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { )); @override _i23.Future> fetchBuildTxData( - List<_i16.UTXO>? utxosToUse) => + List<_i17.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, @@ -1468,10 +1468,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>> parseTransaction( + _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>> parseTransaction( Map? txData, dynamic electrumxClient, - List<_i16.Address>? myAddresses, + List<_i17.Address>? myAddresses, _i22.Coin? coin, int? minConfirms, String? walletId, @@ -1489,8 +1489,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ], ), returnValue: - _i23.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>>.value( - _FakeTuple2_13<_i16.Transaction, _i16.Address>( + _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>.value( + _FakeTuple2_13<_i17.Transaction, _i17.Address>( this, Invocation.method( #parseTransaction, @@ -1504,7 +1504,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ], ), )), - ) as _i23.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>>); + ) as _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>); @override void initPaynymWalletInterface({ required String? walletId, @@ -1514,6 +1514,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { required _i12.MainDB? db, required _i9.ElectrumX? electrumXClient, required _i19.SecureStorageInterface? secureStorage, + required int? dustLimit, required int? dustLimitP2PKH, required int? minConfirms, required _i23.Future Function()? getMnemonicString, @@ -1532,7 +1533,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { })? prepareSend, required _i23.Future Function({required String address})? getTxCount, - required _i23.Future> Function(List<_i16.UTXO>)? + required _i23.Future> Function(List<_i17.UTXO>)? fetchBuildTxData, required _i23.Future Function()? refresh, required _i23.Future Function()? checkChangeAddressForTransactions, @@ -1549,6 +1550,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { #db: db, #electrumXClient: electrumXClient, #secureStorage: secureStorage, + #dustLimit: dustLimit, #dustLimitP2PKH: dustLimitP2PKH, #minConfirms: minConfirms, #getMnemonicString: getMnemonicString, @@ -1567,28 +1569,74 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i16.Address> currentReceivingPaynymAddress( - _i18.PaymentCode? sender) => + _i23.Future<_i16.BIP32> getBip47BaseNode() => (super.noSuchMethod( + Invocation.method( + #getBip47BaseNode, + [], + ), + returnValue: _i23.Future<_i16.BIP32>.value(_FakeBIP32_14( + this, + Invocation.method( + #getBip47BaseNode, + [], + ), + )), + ) as _i23.Future<_i16.BIP32>); + @override + _i23.Future<_i29.Uint8List> getPrivateKeyForPaynymReceivingAddress({ + required String? paymentCodeString, + required int? index, + }) => + (super.noSuchMethod( + Invocation.method( + #getPrivateKeyForPaynymReceivingAddress, + [], + { + #paymentCodeString: paymentCodeString, + #index: index, + }, + ), + returnValue: _i23.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), + ) as _i23.Future<_i29.Uint8List>); + @override + _i23.Future<_i17.Address> currentReceivingPaynymAddress({ + required _i18.PaymentCode? sender, + required bool? isSegwit, + }) => (super.noSuchMethod( Invocation.method( #currentReceivingPaynymAddress, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #currentReceivingPaynymAddress, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), )), - ) as _i23.Future<_i16.Address>); + ) as _i23.Future<_i17.Address>); @override - _i23.Future checkCurrentPaynymReceivingAddressForTransactions( - _i18.PaymentCode? sender) => + _i23.Future checkCurrentPaynymReceivingAddressForTransactions({ + required _i18.PaymentCode? sender, + required bool? isSegwit, + }) => (super.noSuchMethod( Invocation.method( #checkCurrentPaynymReceivingAddressForTransactions, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), returnValue: _i23.Future.value(), returnValueForMissingStub: _i23.Future.value(), @@ -1604,81 +1652,33 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future<_i17.BIP32> deriveNotificationBip32Node({ - required String? mnemonic, - required String? mnemonicPassphrase, - }) => - (super.noSuchMethod( + _i23.Future<_i16.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( Invocation.method( #deriveNotificationBip32Node, [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - }, ), - returnValue: _i23.Future<_i17.BIP32>.value(_FakeBIP32_15( + returnValue: _i23.Future<_i16.BIP32>.value(_FakeBIP32_14( this, Invocation.method( #deriveNotificationBip32Node, [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - }, ), )), - ) as _i23.Future<_i17.BIP32>); + ) as _i23.Future<_i16.BIP32>); @override - _i23.Future<_i17.BIP32> deriveReceivingPrivateKeyNode({ - required String? mnemonic, - required String? mnemonicPassphrase, - required int? index, - }) => - (super.noSuchMethod( - Invocation.method( - #deriveReceivingPrivateKeyNode, - [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - #index: index, - }, - ), - returnValue: _i23.Future<_i17.BIP32>.value(_FakeBIP32_15( - this, - Invocation.method( - #deriveReceivingPrivateKeyNode, - [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - #index: index, - }, - ), - )), - ) as _i23.Future<_i17.BIP32>); - @override - _i23.Future<_i18.PaymentCode> getPaymentCode( - _i27.DerivePathType? derivePathType, [ - _i17.BIP32? bip32Root, - ]) => + _i23.Future<_i18.PaymentCode> getPaymentCode({required bool? isSegwit}) => (super.noSuchMethod( Invocation.method( #getPaymentCode, - [ - derivePathType, - bip32Root, - ], + [], + {#isSegwit: isSegwit}, ), returnValue: _i23.Future<_i18.PaymentCode>.value(_FakePaymentCode_16( this, Invocation.method( #getPaymentCode, - [ - derivePathType, - bip32Root, - ], + [], + {#isSegwit: isSegwit}, ), )), ) as _i23.Future<_i18.PaymentCode>); @@ -1703,6 +1703,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { @override _i23.Future> preparePaymentCodeSend({ required _i18.PaymentCode? paymentCode, + required bool? isSegwit, required _i14.Amount? amount, Map? args, }) => @@ -1712,6 +1713,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { [], { #paymentCode: paymentCode, + #isSegwit: isSegwit, #amount: amount, #args: args, }, @@ -1720,9 +1722,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { _i23.Future>.value({}), ) as _i23.Future>); @override - _i23.Future<_i16.Address> nextUnusedSendAddressFrom({ + _i23.Future<_i17.Address> nextUnusedSendAddressFrom({ required _i18.PaymentCode? pCode, - required _i17.BIP32? privateKeyNode, + required bool? isSegwit, + required _i16.BIP32? privateKeyNode, int? startIndex = 0, }) => (super.noSuchMethod( @@ -1731,29 +1734,31 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { [], { #pCode: pCode, + #isSegwit: isSegwit, #privateKeyNode: privateKeyNode, #startIndex: startIndex, }, ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #nextUnusedSendAddressFrom, [], { #pCode: pCode, + #isSegwit: isSegwit, #privateKeyNode: privateKeyNode, #startIndex: startIndex, }, ), )), - ) as _i23.Future<_i16.Address>); + ) as _i23.Future<_i17.Address>); @override _i23.Future> prepareNotificationTx({ required int? selectedTxFeeRate, required String? targetPaymentCodeString, int? additionalOutputs = 0, - List<_i16.UTXO>? utxos, + List<_i17.UTXO>? utxos, }) => (super.noSuchMethod( Invocation.method( @@ -1790,34 +1795,24 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValue: _i23.Future.value(false), ) as _i23.Future); @override - _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction({ - required _i16.Transaction? transaction, - required _i16.Address? myNotificationAddress, - }) => + _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction( + {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransaction, [], - { - #transaction: transaction, - #myNotificationAddress: myNotificationAddress, - }, + {#transaction: transaction}, ), returnValue: _i23.Future<_i18.PaymentCode?>.value(), ) as _i23.Future<_i18.PaymentCode?>); @override - _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad({ - required _i16.Transaction? transaction, - required _i16.Address? myNotificationAddress, - }) => + _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( + {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransactionBad, [], - { - #transaction: transaction, - #myNotificationAddress: myNotificationAddress, - }, + {#transaction: transaction}, ), returnValue: _i23.Future<_i18.PaymentCode?>.value(), ) as _i23.Future<_i18.PaymentCode?>); @@ -1862,111 +1857,40 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future restoreHistoryWith( - _i18.PaymentCode? other, - int? maxUnusedAddressGap, - int? maxNumberOfIndexesToCheck, - ) => + _i23.Future restoreHistoryWith({ + required _i18.PaymentCode? other, + required bool? checkSegwitAsWell, + required int? maxUnusedAddressGap, + required int? maxNumberOfIndexesToCheck, + }) => (super.noSuchMethod( Invocation.method( #restoreHistoryWith, - [ - other, - maxUnusedAddressGap, - maxNumberOfIndexesToCheck, - ], + [], + { + #other: other, + #checkSegwitAsWell: checkSegwitAsWell, + #maxUnusedAddressGap: maxUnusedAddressGap, + #maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, + }, ), returnValue: _i23.Future.value(), returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future<_i16.Address> generatePaynymSendAddressFromKeyPair({ - required _i13.ECPair? pair, - required int? derivationIndex, - required _i27.DerivePathType? derivePathType, - required _i18.PaymentCode? toPaymentCode, - }) => - (super.noSuchMethod( - Invocation.method( - #generatePaynymSendAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #toPaymentCode: toPaymentCode, - }, - ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( - this, - Invocation.method( - #generatePaynymSendAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #toPaymentCode: toPaymentCode, - }, - ), - )), - ) as _i23.Future<_i16.Address>); - @override - _i23.Future<_i16.Address> generatePaynymReceivingAddressFromKeyPair({ - required _i13.ECPair? pair, - required int? derivationIndex, - required _i27.DerivePathType? derivePathType, - required _i18.PaymentCode? fromPaymentCode, - }) => - (super.noSuchMethod( - Invocation.method( - #generatePaynymReceivingAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #fromPaymentCode: fromPaymentCode, - }, - ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( - this, - Invocation.method( - #generatePaynymReceivingAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #fromPaymentCode: fromPaymentCode, - }, - ), - )), - ) as _i23.Future<_i16.Address>); - @override - _i23.Future<_i16.Address> getMyNotificationAddress( - _i27.DerivePathType? derivePathType, [ - _i17.BIP32? bip32Root, - ]) => - (super.noSuchMethod( + _i23.Future<_i17.Address> getMyNotificationAddress() => (super.noSuchMethod( Invocation.method( #getMyNotificationAddress, - [ - derivePathType, - bip32Root, - ], + [], ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #getMyNotificationAddress, - [ - derivePathType, - bip32Root, - ], + [], ), )), - ) as _i23.Future<_i16.Address>); + ) as _i23.Future<_i17.Address>); @override _i23.Future> lookupKey(String? paymentCodeString) => (super.noSuchMethod( @@ -2386,16 +2310,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i11.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i16.Transaction>[]), - ) as _i23.Future>); + _i23.Future>.value(<_i17.Transaction>[]), + ) as _i23.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i16.UTXO>[]), - ) as _i23.Future>); + returnValue: _i23.Future>.value(<_i17.UTXO>[]), + ) as _i23.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2754,16 +2678,16 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { ), ) as _i11.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i16.Transaction>[]), - ) as _i23.Future>); + _i23.Future>.value(<_i17.Transaction>[]), + ) as _i23.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i16.UTXO>[]), - ) as _i23.Future>); + returnValue: _i23.Future>.value(<_i17.UTXO>[]), + ) as _i23.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( diff --git a/test/widget_tests/table_view/table_view_row_test.mocks.dart b/test/widget_tests/table_view/table_view_row_test.mocks.dart index 1c5c1465c..38a6e1d91 100644 --- a/test/widget_tests/table_view/table_view_row_test.mocks.dart +++ b/test/widget_tests/table_view/table_view_row_test.mocks.dart @@ -7,7 +7,7 @@ import 'dart:async' as _i22; import 'dart:typed_data' as _i29; import 'dart:ui' as _i24; -import 'package:bip32/bip32.dart' as _i17; +import 'package:bip32/bip32.dart' as _i16; import 'package:bip47/bip47.dart' as _i18; import 'package:bitcoindart/bitcoindart.dart' as _i13; import 'package:flutter/foundation.dart' as _i4; @@ -17,7 +17,7 @@ import 'package:stackwallet/db/isar/main_db.dart' as _i12; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i10; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i9; import 'package:stackwallet/models/balance.dart' as _i11; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i16; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i17; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/models/signing_data.dart' as _i27; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i25; @@ -192,8 +192,8 @@ class _FakeTuple2_13 extends _i1.SmartFake ); } -class _FakeAddress_14 extends _i1.SmartFake implements _i16.Address { - _FakeAddress_14( +class _FakeBIP32_14 extends _i1.SmartFake implements _i16.BIP32 { + _FakeBIP32_14( Object parent, Invocation parentInvocation, ) : super( @@ -202,8 +202,8 @@ class _FakeAddress_14 extends _i1.SmartFake implements _i16.Address { ); } -class _FakeBIP32_15 extends _i1.SmartFake implements _i17.BIP32 { - _FakeBIP32_15( +class _FakeAddress_15 extends _i1.SmartFake implements _i17.Address { + _FakeAddress_15( Object parent, Invocation parentInvocation, ) : super( @@ -766,16 +766,16 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { returnValue: _i21.Coin.bitcoin, ) as _i21.Coin); @override - _i22.Future> get utxos => (super.noSuchMethod( + _i22.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i22.Future>.value(<_i16.UTXO>[]), - ) as _i22.Future>); + returnValue: _i22.Future>.value(<_i17.UTXO>[]), + ) as _i22.Future>); @override - _i22.Future> get transactions => (super.noSuchMethod( + _i22.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i22.Future>.value(<_i16.Transaction>[]), - ) as _i22.Future>); + _i22.Future>.value(<_i17.Transaction>[]), + ) as _i22.Future>); @override _i22.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), @@ -1184,7 +1184,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { required bool? coinControl, required bool? isSendAll, int? additionalOutputs = 0, - List<_i16.UTXO>? utxos, + List<_i17.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1201,7 +1201,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { )); @override _i22.Future> fetchBuildTxData( - List<_i16.UTXO>? utxosToUse) => + List<_i17.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, @@ -1455,10 +1455,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i22.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>> parseTransaction( + _i22.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>> parseTransaction( Map? txData, dynamic electrumxClient, - List<_i16.Address>? myAddresses, + List<_i17.Address>? myAddresses, _i21.Coin? coin, int? minConfirms, String? walletId, @@ -1476,8 +1476,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { ], ), returnValue: - _i22.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>>.value( - _FakeTuple2_13<_i16.Transaction, _i16.Address>( + _i22.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>.value( + _FakeTuple2_13<_i17.Transaction, _i17.Address>( this, Invocation.method( #parseTransaction, @@ -1491,7 +1491,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { ], ), )), - ) as _i22.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>>); + ) as _i22.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>); @override void initPaynymWalletInterface({ required String? walletId, @@ -1501,6 +1501,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { required _i12.MainDB? db, required _i9.ElectrumX? electrumXClient, required _i28.SecureStorageInterface? secureStorage, + required int? dustLimit, required int? dustLimitP2PKH, required int? minConfirms, required _i22.Future Function()? getMnemonicString, @@ -1519,7 +1520,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { })? prepareSend, required _i22.Future Function({required String address})? getTxCount, - required _i22.Future> Function(List<_i16.UTXO>)? + required _i22.Future> Function(List<_i17.UTXO>)? fetchBuildTxData, required _i22.Future Function()? refresh, required _i22.Future Function()? checkChangeAddressForTransactions, @@ -1536,6 +1537,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { #db: db, #electrumXClient: electrumXClient, #secureStorage: secureStorage, + #dustLimit: dustLimit, #dustLimitP2PKH: dustLimitP2PKH, #minConfirms: minConfirms, #getMnemonicString: getMnemonicString, @@ -1554,28 +1556,74 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i22.Future<_i16.Address> currentReceivingPaynymAddress( - _i18.PaymentCode? sender) => + _i22.Future<_i16.BIP32> getBip47BaseNode() => (super.noSuchMethod( + Invocation.method( + #getBip47BaseNode, + [], + ), + returnValue: _i22.Future<_i16.BIP32>.value(_FakeBIP32_14( + this, + Invocation.method( + #getBip47BaseNode, + [], + ), + )), + ) as _i22.Future<_i16.BIP32>); + @override + _i22.Future<_i29.Uint8List> getPrivateKeyForPaynymReceivingAddress({ + required String? paymentCodeString, + required int? index, + }) => + (super.noSuchMethod( + Invocation.method( + #getPrivateKeyForPaynymReceivingAddress, + [], + { + #paymentCodeString: paymentCodeString, + #index: index, + }, + ), + returnValue: _i22.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), + ) as _i22.Future<_i29.Uint8List>); + @override + _i22.Future<_i17.Address> currentReceivingPaynymAddress({ + required _i18.PaymentCode? sender, + required bool? isSegwit, + }) => (super.noSuchMethod( Invocation.method( #currentReceivingPaynymAddress, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), - returnValue: _i22.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i22.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #currentReceivingPaynymAddress, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), )), - ) as _i22.Future<_i16.Address>); + ) as _i22.Future<_i17.Address>); @override - _i22.Future checkCurrentPaynymReceivingAddressForTransactions( - _i18.PaymentCode? sender) => + _i22.Future checkCurrentPaynymReceivingAddressForTransactions({ + required _i18.PaymentCode? sender, + required bool? isSegwit, + }) => (super.noSuchMethod( Invocation.method( #checkCurrentPaynymReceivingAddressForTransactions, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), returnValue: _i22.Future.value(), returnValueForMissingStub: _i22.Future.value(), @@ -1591,81 +1639,33 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { returnValueForMissingStub: _i22.Future.value(), ) as _i22.Future); @override - _i22.Future<_i17.BIP32> deriveNotificationBip32Node({ - required String? mnemonic, - required String? mnemonicPassphrase, - }) => - (super.noSuchMethod( + _i22.Future<_i16.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( Invocation.method( #deriveNotificationBip32Node, [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - }, ), - returnValue: _i22.Future<_i17.BIP32>.value(_FakeBIP32_15( + returnValue: _i22.Future<_i16.BIP32>.value(_FakeBIP32_14( this, Invocation.method( #deriveNotificationBip32Node, [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - }, ), )), - ) as _i22.Future<_i17.BIP32>); + ) as _i22.Future<_i16.BIP32>); @override - _i22.Future<_i17.BIP32> deriveReceivingPrivateKeyNode({ - required String? mnemonic, - required String? mnemonicPassphrase, - required int? index, - }) => - (super.noSuchMethod( - Invocation.method( - #deriveReceivingPrivateKeyNode, - [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - #index: index, - }, - ), - returnValue: _i22.Future<_i17.BIP32>.value(_FakeBIP32_15( - this, - Invocation.method( - #deriveReceivingPrivateKeyNode, - [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - #index: index, - }, - ), - )), - ) as _i22.Future<_i17.BIP32>); - @override - _i22.Future<_i18.PaymentCode> getPaymentCode( - _i26.DerivePathType? derivePathType, [ - _i17.BIP32? bip32Root, - ]) => + _i22.Future<_i18.PaymentCode> getPaymentCode({required bool? isSegwit}) => (super.noSuchMethod( Invocation.method( #getPaymentCode, - [ - derivePathType, - bip32Root, - ], + [], + {#isSegwit: isSegwit}, ), returnValue: _i22.Future<_i18.PaymentCode>.value(_FakePaymentCode_16( this, Invocation.method( #getPaymentCode, - [ - derivePathType, - bip32Root, - ], + [], + {#isSegwit: isSegwit}, ), )), ) as _i22.Future<_i18.PaymentCode>); @@ -1690,6 +1690,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { @override _i22.Future> preparePaymentCodeSend({ required _i18.PaymentCode? paymentCode, + required bool? isSegwit, required _i14.Amount? amount, Map? args, }) => @@ -1699,6 +1700,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { [], { #paymentCode: paymentCode, + #isSegwit: isSegwit, #amount: amount, #args: args, }, @@ -1707,9 +1709,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { _i22.Future>.value({}), ) as _i22.Future>); @override - _i22.Future<_i16.Address> nextUnusedSendAddressFrom({ + _i22.Future<_i17.Address> nextUnusedSendAddressFrom({ required _i18.PaymentCode? pCode, - required _i17.BIP32? privateKeyNode, + required bool? isSegwit, + required _i16.BIP32? privateKeyNode, int? startIndex = 0, }) => (super.noSuchMethod( @@ -1718,29 +1721,31 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { [], { #pCode: pCode, + #isSegwit: isSegwit, #privateKeyNode: privateKeyNode, #startIndex: startIndex, }, ), - returnValue: _i22.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i22.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #nextUnusedSendAddressFrom, [], { #pCode: pCode, + #isSegwit: isSegwit, #privateKeyNode: privateKeyNode, #startIndex: startIndex, }, ), )), - ) as _i22.Future<_i16.Address>); + ) as _i22.Future<_i17.Address>); @override _i22.Future> prepareNotificationTx({ required int? selectedTxFeeRate, required String? targetPaymentCodeString, int? additionalOutputs = 0, - List<_i16.UTXO>? utxos, + List<_i17.UTXO>? utxos, }) => (super.noSuchMethod( Invocation.method( @@ -1777,34 +1782,24 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { returnValue: _i22.Future.value(false), ) as _i22.Future); @override - _i22.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction({ - required _i16.Transaction? transaction, - required _i16.Address? myNotificationAddress, - }) => + _i22.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction( + {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransaction, [], - { - #transaction: transaction, - #myNotificationAddress: myNotificationAddress, - }, + {#transaction: transaction}, ), returnValue: _i22.Future<_i18.PaymentCode?>.value(), ) as _i22.Future<_i18.PaymentCode?>); @override - _i22.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad({ - required _i16.Transaction? transaction, - required _i16.Address? myNotificationAddress, - }) => + _i22.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( + {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransactionBad, [], - { - #transaction: transaction, - #myNotificationAddress: myNotificationAddress, - }, + {#transaction: transaction}, ), returnValue: _i22.Future<_i18.PaymentCode?>.value(), ) as _i22.Future<_i18.PaymentCode?>); @@ -1849,111 +1844,40 @@ class MockBitcoinWallet extends _i1.Mock implements _i25.BitcoinWallet { returnValueForMissingStub: _i22.Future.value(), ) as _i22.Future); @override - _i22.Future restoreHistoryWith( - _i18.PaymentCode? other, - int? maxUnusedAddressGap, - int? maxNumberOfIndexesToCheck, - ) => + _i22.Future restoreHistoryWith({ + required _i18.PaymentCode? other, + required bool? checkSegwitAsWell, + required int? maxUnusedAddressGap, + required int? maxNumberOfIndexesToCheck, + }) => (super.noSuchMethod( Invocation.method( #restoreHistoryWith, - [ - other, - maxUnusedAddressGap, - maxNumberOfIndexesToCheck, - ], + [], + { + #other: other, + #checkSegwitAsWell: checkSegwitAsWell, + #maxUnusedAddressGap: maxUnusedAddressGap, + #maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, + }, ), returnValue: _i22.Future.value(), returnValueForMissingStub: _i22.Future.value(), ) as _i22.Future); @override - _i22.Future<_i16.Address> generatePaynymSendAddressFromKeyPair({ - required _i13.ECPair? pair, - required int? derivationIndex, - required _i26.DerivePathType? derivePathType, - required _i18.PaymentCode? toPaymentCode, - }) => - (super.noSuchMethod( - Invocation.method( - #generatePaynymSendAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #toPaymentCode: toPaymentCode, - }, - ), - returnValue: _i22.Future<_i16.Address>.value(_FakeAddress_14( - this, - Invocation.method( - #generatePaynymSendAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #toPaymentCode: toPaymentCode, - }, - ), - )), - ) as _i22.Future<_i16.Address>); - @override - _i22.Future<_i16.Address> generatePaynymReceivingAddressFromKeyPair({ - required _i13.ECPair? pair, - required int? derivationIndex, - required _i26.DerivePathType? derivePathType, - required _i18.PaymentCode? fromPaymentCode, - }) => - (super.noSuchMethod( - Invocation.method( - #generatePaynymReceivingAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #fromPaymentCode: fromPaymentCode, - }, - ), - returnValue: _i22.Future<_i16.Address>.value(_FakeAddress_14( - this, - Invocation.method( - #generatePaynymReceivingAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #fromPaymentCode: fromPaymentCode, - }, - ), - )), - ) as _i22.Future<_i16.Address>); - @override - _i22.Future<_i16.Address> getMyNotificationAddress( - _i26.DerivePathType? derivePathType, [ - _i17.BIP32? bip32Root, - ]) => - (super.noSuchMethod( + _i22.Future<_i17.Address> getMyNotificationAddress() => (super.noSuchMethod( Invocation.method( #getMyNotificationAddress, - [ - derivePathType, - bip32Root, - ], + [], ), - returnValue: _i22.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i22.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #getMyNotificationAddress, - [ - derivePathType, - bip32Root, - ], + [], ), )), - ) as _i22.Future<_i16.Address>); + ) as _i22.Future<_i17.Address>); @override _i22.Future> lookupKey(String? paymentCodeString) => (super.noSuchMethod( @@ -2111,16 +2035,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i11.Balance); @override - _i22.Future> get transactions => (super.noSuchMethod( + _i22.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i22.Future>.value(<_i16.Transaction>[]), - ) as _i22.Future>); + _i22.Future>.value(<_i17.Transaction>[]), + ) as _i22.Future>); @override - _i22.Future> get utxos => (super.noSuchMethod( + _i22.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i22.Future>.value(<_i16.UTXO>[]), - ) as _i22.Future>); + returnValue: _i22.Future>.value(<_i17.UTXO>[]), + ) as _i22.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2479,16 +2403,16 @@ class MockCoinServiceAPI extends _i1.Mock implements _i19.CoinServiceAPI { ), ) as _i11.Balance); @override - _i22.Future> get transactions => (super.noSuchMethod( + _i22.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i22.Future>.value(<_i16.Transaction>[]), - ) as _i22.Future>); + _i22.Future>.value(<_i17.Transaction>[]), + ) as _i22.Future>); @override - _i22.Future> get utxos => (super.noSuchMethod( + _i22.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i22.Future>.value(<_i16.UTXO>[]), - ) as _i22.Future>); + returnValue: _i22.Future>.value(<_i17.UTXO>[]), + ) as _i22.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( diff --git a/test/widget_tests/wallet_card_test.mocks.dart b/test/widget_tests/wallet_card_test.mocks.dart index 0e3a61dd1..908eef0dc 100644 --- a/test/widget_tests/wallet_card_test.mocks.dart +++ b/test/widget_tests/wallet_card_test.mocks.dart @@ -7,7 +7,7 @@ import 'dart:async' as _i21; import 'dart:typed_data' as _i28; import 'dart:ui' as _i23; -import 'package:bip32/bip32.dart' as _i17; +import 'package:bip32/bip32.dart' as _i16; import 'package:bip47/bip47.dart' as _i18; import 'package:bitcoindart/bitcoindart.dart' as _i13; import 'package:flutter/foundation.dart' as _i4; @@ -17,7 +17,7 @@ import 'package:stackwallet/db/isar/main_db.dart' as _i12; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i10; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i9; import 'package:stackwallet/models/balance.dart' as _i11; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i16; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i17; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/models/signing_data.dart' as _i26; import 'package:stackwallet/services/coins/bitcoin/bitcoin_wallet.dart' as _i24; @@ -192,8 +192,8 @@ class _FakeTuple2_13 extends _i1.SmartFake ); } -class _FakeAddress_14 extends _i1.SmartFake implements _i16.Address { - _FakeAddress_14( +class _FakeBIP32_14 extends _i1.SmartFake implements _i16.BIP32 { + _FakeBIP32_14( Object parent, Invocation parentInvocation, ) : super( @@ -202,8 +202,8 @@ class _FakeAddress_14 extends _i1.SmartFake implements _i16.Address { ); } -class _FakeBIP32_15 extends _i1.SmartFake implements _i17.BIP32 { - _FakeBIP32_15( +class _FakeAddress_15 extends _i1.SmartFake implements _i17.Address { + _FakeAddress_15( Object parent, Invocation parentInvocation, ) : super( @@ -521,16 +521,16 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValue: _i20.Coin.bitcoin, ) as _i20.Coin); @override - _i21.Future> get utxos => (super.noSuchMethod( + _i21.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i21.Future>.value(<_i16.UTXO>[]), - ) as _i21.Future>); + returnValue: _i21.Future>.value(<_i17.UTXO>[]), + ) as _i21.Future>); @override - _i21.Future> get transactions => (super.noSuchMethod( + _i21.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i21.Future>.value(<_i16.Transaction>[]), - ) as _i21.Future>); + _i21.Future>.value(<_i17.Transaction>[]), + ) as _i21.Future>); @override _i21.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), @@ -939,7 +939,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { required bool? coinControl, required bool? isSendAll, int? additionalOutputs = 0, - List<_i16.UTXO>? utxos, + List<_i17.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -956,7 +956,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { )); @override _i21.Future> fetchBuildTxData( - List<_i16.UTXO>? utxosToUse) => + List<_i17.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, @@ -1210,10 +1210,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i21.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>> parseTransaction( + _i21.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>> parseTransaction( Map? txData, dynamic electrumxClient, - List<_i16.Address>? myAddresses, + List<_i17.Address>? myAddresses, _i20.Coin? coin, int? minConfirms, String? walletId, @@ -1231,8 +1231,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { ], ), returnValue: - _i21.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>>.value( - _FakeTuple2_13<_i16.Transaction, _i16.Address>( + _i21.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>.value( + _FakeTuple2_13<_i17.Transaction, _i17.Address>( this, Invocation.method( #parseTransaction, @@ -1246,7 +1246,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { ], ), )), - ) as _i21.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>>); + ) as _i21.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>); @override void initPaynymWalletInterface({ required String? walletId, @@ -1256,6 +1256,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { required _i12.MainDB? db, required _i9.ElectrumX? electrumXClient, required _i27.SecureStorageInterface? secureStorage, + required int? dustLimit, required int? dustLimitP2PKH, required int? minConfirms, required _i21.Future Function()? getMnemonicString, @@ -1274,7 +1275,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { })? prepareSend, required _i21.Future Function({required String address})? getTxCount, - required _i21.Future> Function(List<_i16.UTXO>)? + required _i21.Future> Function(List<_i17.UTXO>)? fetchBuildTxData, required _i21.Future Function()? refresh, required _i21.Future Function()? checkChangeAddressForTransactions, @@ -1291,6 +1292,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { #db: db, #electrumXClient: electrumXClient, #secureStorage: secureStorage, + #dustLimit: dustLimit, #dustLimitP2PKH: dustLimitP2PKH, #minConfirms: minConfirms, #getMnemonicString: getMnemonicString, @@ -1309,28 +1311,74 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i21.Future<_i16.Address> currentReceivingPaynymAddress( - _i18.PaymentCode? sender) => + _i21.Future<_i16.BIP32> getBip47BaseNode() => (super.noSuchMethod( + Invocation.method( + #getBip47BaseNode, + [], + ), + returnValue: _i21.Future<_i16.BIP32>.value(_FakeBIP32_14( + this, + Invocation.method( + #getBip47BaseNode, + [], + ), + )), + ) as _i21.Future<_i16.BIP32>); + @override + _i21.Future<_i28.Uint8List> getPrivateKeyForPaynymReceivingAddress({ + required String? paymentCodeString, + required int? index, + }) => + (super.noSuchMethod( + Invocation.method( + #getPrivateKeyForPaynymReceivingAddress, + [], + { + #paymentCodeString: paymentCodeString, + #index: index, + }, + ), + returnValue: _i21.Future<_i28.Uint8List>.value(_i28.Uint8List(0)), + ) as _i21.Future<_i28.Uint8List>); + @override + _i21.Future<_i17.Address> currentReceivingPaynymAddress({ + required _i18.PaymentCode? sender, + required bool? isSegwit, + }) => (super.noSuchMethod( Invocation.method( #currentReceivingPaynymAddress, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), - returnValue: _i21.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i21.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #currentReceivingPaynymAddress, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), )), - ) as _i21.Future<_i16.Address>); + ) as _i21.Future<_i17.Address>); @override - _i21.Future checkCurrentPaynymReceivingAddressForTransactions( - _i18.PaymentCode? sender) => + _i21.Future checkCurrentPaynymReceivingAddressForTransactions({ + required _i18.PaymentCode? sender, + required bool? isSegwit, + }) => (super.noSuchMethod( Invocation.method( #checkCurrentPaynymReceivingAddressForTransactions, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), returnValue: _i21.Future.value(), returnValueForMissingStub: _i21.Future.value(), @@ -1346,81 +1394,33 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValueForMissingStub: _i21.Future.value(), ) as _i21.Future); @override - _i21.Future<_i17.BIP32> deriveNotificationBip32Node({ - required String? mnemonic, - required String? mnemonicPassphrase, - }) => - (super.noSuchMethod( + _i21.Future<_i16.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( Invocation.method( #deriveNotificationBip32Node, [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - }, ), - returnValue: _i21.Future<_i17.BIP32>.value(_FakeBIP32_15( + returnValue: _i21.Future<_i16.BIP32>.value(_FakeBIP32_14( this, Invocation.method( #deriveNotificationBip32Node, [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - }, ), )), - ) as _i21.Future<_i17.BIP32>); + ) as _i21.Future<_i16.BIP32>); @override - _i21.Future<_i17.BIP32> deriveReceivingPrivateKeyNode({ - required String? mnemonic, - required String? mnemonicPassphrase, - required int? index, - }) => - (super.noSuchMethod( - Invocation.method( - #deriveReceivingPrivateKeyNode, - [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - #index: index, - }, - ), - returnValue: _i21.Future<_i17.BIP32>.value(_FakeBIP32_15( - this, - Invocation.method( - #deriveReceivingPrivateKeyNode, - [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - #index: index, - }, - ), - )), - ) as _i21.Future<_i17.BIP32>); - @override - _i21.Future<_i18.PaymentCode> getPaymentCode( - _i25.DerivePathType? derivePathType, [ - _i17.BIP32? bip32Root, - ]) => + _i21.Future<_i18.PaymentCode> getPaymentCode({required bool? isSegwit}) => (super.noSuchMethod( Invocation.method( #getPaymentCode, - [ - derivePathType, - bip32Root, - ], + [], + {#isSegwit: isSegwit}, ), returnValue: _i21.Future<_i18.PaymentCode>.value(_FakePaymentCode_16( this, Invocation.method( #getPaymentCode, - [ - derivePathType, - bip32Root, - ], + [], + {#isSegwit: isSegwit}, ), )), ) as _i21.Future<_i18.PaymentCode>); @@ -1445,6 +1445,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { @override _i21.Future> preparePaymentCodeSend({ required _i18.PaymentCode? paymentCode, + required bool? isSegwit, required _i14.Amount? amount, Map? args, }) => @@ -1454,6 +1455,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { [], { #paymentCode: paymentCode, + #isSegwit: isSegwit, #amount: amount, #args: args, }, @@ -1462,9 +1464,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { _i21.Future>.value({}), ) as _i21.Future>); @override - _i21.Future<_i16.Address> nextUnusedSendAddressFrom({ + _i21.Future<_i17.Address> nextUnusedSendAddressFrom({ required _i18.PaymentCode? pCode, - required _i17.BIP32? privateKeyNode, + required bool? isSegwit, + required _i16.BIP32? privateKeyNode, int? startIndex = 0, }) => (super.noSuchMethod( @@ -1473,29 +1476,31 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { [], { #pCode: pCode, + #isSegwit: isSegwit, #privateKeyNode: privateKeyNode, #startIndex: startIndex, }, ), - returnValue: _i21.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i21.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #nextUnusedSendAddressFrom, [], { #pCode: pCode, + #isSegwit: isSegwit, #privateKeyNode: privateKeyNode, #startIndex: startIndex, }, ), )), - ) as _i21.Future<_i16.Address>); + ) as _i21.Future<_i17.Address>); @override _i21.Future> prepareNotificationTx({ required int? selectedTxFeeRate, required String? targetPaymentCodeString, int? additionalOutputs = 0, - List<_i16.UTXO>? utxos, + List<_i17.UTXO>? utxos, }) => (super.noSuchMethod( Invocation.method( @@ -1532,34 +1537,24 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValue: _i21.Future.value(false), ) as _i21.Future); @override - _i21.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction({ - required _i16.Transaction? transaction, - required _i16.Address? myNotificationAddress, - }) => + _i21.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction( + {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransaction, [], - { - #transaction: transaction, - #myNotificationAddress: myNotificationAddress, - }, + {#transaction: transaction}, ), returnValue: _i21.Future<_i18.PaymentCode?>.value(), ) as _i21.Future<_i18.PaymentCode?>); @override - _i21.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad({ - required _i16.Transaction? transaction, - required _i16.Address? myNotificationAddress, - }) => + _i21.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( + {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransactionBad, [], - { - #transaction: transaction, - #myNotificationAddress: myNotificationAddress, - }, + {#transaction: transaction}, ), returnValue: _i21.Future<_i18.PaymentCode?>.value(), ) as _i21.Future<_i18.PaymentCode?>); @@ -1604,111 +1599,40 @@ class MockBitcoinWallet extends _i1.Mock implements _i24.BitcoinWallet { returnValueForMissingStub: _i21.Future.value(), ) as _i21.Future); @override - _i21.Future restoreHistoryWith( - _i18.PaymentCode? other, - int? maxUnusedAddressGap, - int? maxNumberOfIndexesToCheck, - ) => + _i21.Future restoreHistoryWith({ + required _i18.PaymentCode? other, + required bool? checkSegwitAsWell, + required int? maxUnusedAddressGap, + required int? maxNumberOfIndexesToCheck, + }) => (super.noSuchMethod( Invocation.method( #restoreHistoryWith, - [ - other, - maxUnusedAddressGap, - maxNumberOfIndexesToCheck, - ], + [], + { + #other: other, + #checkSegwitAsWell: checkSegwitAsWell, + #maxUnusedAddressGap: maxUnusedAddressGap, + #maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, + }, ), returnValue: _i21.Future.value(), returnValueForMissingStub: _i21.Future.value(), ) as _i21.Future); @override - _i21.Future<_i16.Address> generatePaynymSendAddressFromKeyPair({ - required _i13.ECPair? pair, - required int? derivationIndex, - required _i25.DerivePathType? derivePathType, - required _i18.PaymentCode? toPaymentCode, - }) => - (super.noSuchMethod( - Invocation.method( - #generatePaynymSendAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #toPaymentCode: toPaymentCode, - }, - ), - returnValue: _i21.Future<_i16.Address>.value(_FakeAddress_14( - this, - Invocation.method( - #generatePaynymSendAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #toPaymentCode: toPaymentCode, - }, - ), - )), - ) as _i21.Future<_i16.Address>); - @override - _i21.Future<_i16.Address> generatePaynymReceivingAddressFromKeyPair({ - required _i13.ECPair? pair, - required int? derivationIndex, - required _i25.DerivePathType? derivePathType, - required _i18.PaymentCode? fromPaymentCode, - }) => - (super.noSuchMethod( - Invocation.method( - #generatePaynymReceivingAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #fromPaymentCode: fromPaymentCode, - }, - ), - returnValue: _i21.Future<_i16.Address>.value(_FakeAddress_14( - this, - Invocation.method( - #generatePaynymReceivingAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #fromPaymentCode: fromPaymentCode, - }, - ), - )), - ) as _i21.Future<_i16.Address>); - @override - _i21.Future<_i16.Address> getMyNotificationAddress( - _i25.DerivePathType? derivePathType, [ - _i17.BIP32? bip32Root, - ]) => - (super.noSuchMethod( + _i21.Future<_i17.Address> getMyNotificationAddress() => (super.noSuchMethod( Invocation.method( #getMyNotificationAddress, - [ - derivePathType, - bip32Root, - ], + [], ), - returnValue: _i21.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i21.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #getMyNotificationAddress, - [ - derivePathType, - bip32Root, - ], + [], ), )), - ) as _i21.Future<_i16.Address>); + ) as _i21.Future<_i17.Address>); @override _i21.Future> lookupKey(String? paymentCodeString) => (super.noSuchMethod( diff --git a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart index 94ce87475..70954c6db 100644 --- a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart +++ b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart @@ -7,7 +7,7 @@ import 'dart:async' as _i23; import 'dart:typed_data' as _i29; import 'dart:ui' as _i25; -import 'package:bip32/bip32.dart' as _i17; +import 'package:bip32/bip32.dart' as _i16; import 'package:bip47/bip47.dart' as _i18; import 'package:bitcoindart/bitcoindart.dart' as _i13; import 'package:flutter/foundation.dart' as _i4; @@ -17,7 +17,7 @@ import 'package:stackwallet/db/isar/main_db.dart' as _i12; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i10; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i9; import 'package:stackwallet/models/balance.dart' as _i11; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i16; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i17; import 'package:stackwallet/models/node_model.dart' as _i30; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/models/signing_data.dart' as _i28; @@ -193,8 +193,8 @@ class _FakeTuple2_13 extends _i1.SmartFake ); } -class _FakeAddress_14 extends _i1.SmartFake implements _i16.Address { - _FakeAddress_14( +class _FakeBIP32_14 extends _i1.SmartFake implements _i16.BIP32 { + _FakeBIP32_14( Object parent, Invocation parentInvocation, ) : super( @@ -203,8 +203,8 @@ class _FakeAddress_14 extends _i1.SmartFake implements _i16.Address { ); } -class _FakeBIP32_15 extends _i1.SmartFake implements _i17.BIP32 { - _FakeBIP32_15( +class _FakeAddress_15 extends _i1.SmartFake implements _i17.Address { + _FakeAddress_15( Object parent, Invocation parentInvocation, ) : super( @@ -778,16 +778,16 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValue: _i22.Coin.bitcoin, ) as _i22.Coin); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i16.UTXO>[]), - ) as _i23.Future>); + returnValue: _i23.Future>.value(<_i17.UTXO>[]), + ) as _i23.Future>); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i16.Transaction>[]), - ) as _i23.Future>); + _i23.Future>.value(<_i17.Transaction>[]), + ) as _i23.Future>); @override _i23.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), @@ -1196,7 +1196,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { required bool? coinControl, required bool? isSendAll, int? additionalOutputs = 0, - List<_i16.UTXO>? utxos, + List<_i17.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1213,7 +1213,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { )); @override _i23.Future> fetchBuildTxData( - List<_i16.UTXO>? utxosToUse) => + List<_i17.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, @@ -1467,10 +1467,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>> parseTransaction( + _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>> parseTransaction( Map? txData, dynamic electrumxClient, - List<_i16.Address>? myAddresses, + List<_i17.Address>? myAddresses, _i22.Coin? coin, int? minConfirms, String? walletId, @@ -1488,8 +1488,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ], ), returnValue: - _i23.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>>.value( - _FakeTuple2_13<_i16.Transaction, _i16.Address>( + _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>.value( + _FakeTuple2_13<_i17.Transaction, _i17.Address>( this, Invocation.method( #parseTransaction, @@ -1503,7 +1503,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ], ), )), - ) as _i23.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>>); + ) as _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>); @override void initPaynymWalletInterface({ required String? walletId, @@ -1513,6 +1513,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { required _i12.MainDB? db, required _i9.ElectrumX? electrumXClient, required _i19.SecureStorageInterface? secureStorage, + required int? dustLimit, required int? dustLimitP2PKH, required int? minConfirms, required _i23.Future Function()? getMnemonicString, @@ -1531,7 +1532,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { })? prepareSend, required _i23.Future Function({required String address})? getTxCount, - required _i23.Future> Function(List<_i16.UTXO>)? + required _i23.Future> Function(List<_i17.UTXO>)? fetchBuildTxData, required _i23.Future Function()? refresh, required _i23.Future Function()? checkChangeAddressForTransactions, @@ -1548,6 +1549,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { #db: db, #electrumXClient: electrumXClient, #secureStorage: secureStorage, + #dustLimit: dustLimit, #dustLimitP2PKH: dustLimitP2PKH, #minConfirms: minConfirms, #getMnemonicString: getMnemonicString, @@ -1566,28 +1568,74 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i16.Address> currentReceivingPaynymAddress( - _i18.PaymentCode? sender) => + _i23.Future<_i16.BIP32> getBip47BaseNode() => (super.noSuchMethod( + Invocation.method( + #getBip47BaseNode, + [], + ), + returnValue: _i23.Future<_i16.BIP32>.value(_FakeBIP32_14( + this, + Invocation.method( + #getBip47BaseNode, + [], + ), + )), + ) as _i23.Future<_i16.BIP32>); + @override + _i23.Future<_i29.Uint8List> getPrivateKeyForPaynymReceivingAddress({ + required String? paymentCodeString, + required int? index, + }) => + (super.noSuchMethod( + Invocation.method( + #getPrivateKeyForPaynymReceivingAddress, + [], + { + #paymentCodeString: paymentCodeString, + #index: index, + }, + ), + returnValue: _i23.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), + ) as _i23.Future<_i29.Uint8List>); + @override + _i23.Future<_i17.Address> currentReceivingPaynymAddress({ + required _i18.PaymentCode? sender, + required bool? isSegwit, + }) => (super.noSuchMethod( Invocation.method( #currentReceivingPaynymAddress, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #currentReceivingPaynymAddress, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), )), - ) as _i23.Future<_i16.Address>); + ) as _i23.Future<_i17.Address>); @override - _i23.Future checkCurrentPaynymReceivingAddressForTransactions( - _i18.PaymentCode? sender) => + _i23.Future checkCurrentPaynymReceivingAddressForTransactions({ + required _i18.PaymentCode? sender, + required bool? isSegwit, + }) => (super.noSuchMethod( Invocation.method( #checkCurrentPaynymReceivingAddressForTransactions, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), returnValue: _i23.Future.value(), returnValueForMissingStub: _i23.Future.value(), @@ -1603,81 +1651,33 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future<_i17.BIP32> deriveNotificationBip32Node({ - required String? mnemonic, - required String? mnemonicPassphrase, - }) => - (super.noSuchMethod( + _i23.Future<_i16.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( Invocation.method( #deriveNotificationBip32Node, [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - }, ), - returnValue: _i23.Future<_i17.BIP32>.value(_FakeBIP32_15( + returnValue: _i23.Future<_i16.BIP32>.value(_FakeBIP32_14( this, Invocation.method( #deriveNotificationBip32Node, [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - }, ), )), - ) as _i23.Future<_i17.BIP32>); + ) as _i23.Future<_i16.BIP32>); @override - _i23.Future<_i17.BIP32> deriveReceivingPrivateKeyNode({ - required String? mnemonic, - required String? mnemonicPassphrase, - required int? index, - }) => - (super.noSuchMethod( - Invocation.method( - #deriveReceivingPrivateKeyNode, - [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - #index: index, - }, - ), - returnValue: _i23.Future<_i17.BIP32>.value(_FakeBIP32_15( - this, - Invocation.method( - #deriveReceivingPrivateKeyNode, - [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - #index: index, - }, - ), - )), - ) as _i23.Future<_i17.BIP32>); - @override - _i23.Future<_i18.PaymentCode> getPaymentCode( - _i27.DerivePathType? derivePathType, [ - _i17.BIP32? bip32Root, - ]) => + _i23.Future<_i18.PaymentCode> getPaymentCode({required bool? isSegwit}) => (super.noSuchMethod( Invocation.method( #getPaymentCode, - [ - derivePathType, - bip32Root, - ], + [], + {#isSegwit: isSegwit}, ), returnValue: _i23.Future<_i18.PaymentCode>.value(_FakePaymentCode_16( this, Invocation.method( #getPaymentCode, - [ - derivePathType, - bip32Root, - ], + [], + {#isSegwit: isSegwit}, ), )), ) as _i23.Future<_i18.PaymentCode>); @@ -1702,6 +1702,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { @override _i23.Future> preparePaymentCodeSend({ required _i18.PaymentCode? paymentCode, + required bool? isSegwit, required _i14.Amount? amount, Map? args, }) => @@ -1711,6 +1712,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { [], { #paymentCode: paymentCode, + #isSegwit: isSegwit, #amount: amount, #args: args, }, @@ -1719,9 +1721,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { _i23.Future>.value({}), ) as _i23.Future>); @override - _i23.Future<_i16.Address> nextUnusedSendAddressFrom({ + _i23.Future<_i17.Address> nextUnusedSendAddressFrom({ required _i18.PaymentCode? pCode, - required _i17.BIP32? privateKeyNode, + required bool? isSegwit, + required _i16.BIP32? privateKeyNode, int? startIndex = 0, }) => (super.noSuchMethod( @@ -1730,29 +1733,31 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { [], { #pCode: pCode, + #isSegwit: isSegwit, #privateKeyNode: privateKeyNode, #startIndex: startIndex, }, ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #nextUnusedSendAddressFrom, [], { #pCode: pCode, + #isSegwit: isSegwit, #privateKeyNode: privateKeyNode, #startIndex: startIndex, }, ), )), - ) as _i23.Future<_i16.Address>); + ) as _i23.Future<_i17.Address>); @override _i23.Future> prepareNotificationTx({ required int? selectedTxFeeRate, required String? targetPaymentCodeString, int? additionalOutputs = 0, - List<_i16.UTXO>? utxos, + List<_i17.UTXO>? utxos, }) => (super.noSuchMethod( Invocation.method( @@ -1789,34 +1794,24 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValue: _i23.Future.value(false), ) as _i23.Future); @override - _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction({ - required _i16.Transaction? transaction, - required _i16.Address? myNotificationAddress, - }) => + _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction( + {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransaction, [], - { - #transaction: transaction, - #myNotificationAddress: myNotificationAddress, - }, + {#transaction: transaction}, ), returnValue: _i23.Future<_i18.PaymentCode?>.value(), ) as _i23.Future<_i18.PaymentCode?>); @override - _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad({ - required _i16.Transaction? transaction, - required _i16.Address? myNotificationAddress, - }) => + _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( + {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransactionBad, [], - { - #transaction: transaction, - #myNotificationAddress: myNotificationAddress, - }, + {#transaction: transaction}, ), returnValue: _i23.Future<_i18.PaymentCode?>.value(), ) as _i23.Future<_i18.PaymentCode?>); @@ -1861,111 +1856,40 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future restoreHistoryWith( - _i18.PaymentCode? other, - int? maxUnusedAddressGap, - int? maxNumberOfIndexesToCheck, - ) => + _i23.Future restoreHistoryWith({ + required _i18.PaymentCode? other, + required bool? checkSegwitAsWell, + required int? maxUnusedAddressGap, + required int? maxNumberOfIndexesToCheck, + }) => (super.noSuchMethod( Invocation.method( #restoreHistoryWith, - [ - other, - maxUnusedAddressGap, - maxNumberOfIndexesToCheck, - ], + [], + { + #other: other, + #checkSegwitAsWell: checkSegwitAsWell, + #maxUnusedAddressGap: maxUnusedAddressGap, + #maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, + }, ), returnValue: _i23.Future.value(), returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future<_i16.Address> generatePaynymSendAddressFromKeyPair({ - required _i13.ECPair? pair, - required int? derivationIndex, - required _i27.DerivePathType? derivePathType, - required _i18.PaymentCode? toPaymentCode, - }) => - (super.noSuchMethod( - Invocation.method( - #generatePaynymSendAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #toPaymentCode: toPaymentCode, - }, - ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( - this, - Invocation.method( - #generatePaynymSendAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #toPaymentCode: toPaymentCode, - }, - ), - )), - ) as _i23.Future<_i16.Address>); - @override - _i23.Future<_i16.Address> generatePaynymReceivingAddressFromKeyPair({ - required _i13.ECPair? pair, - required int? derivationIndex, - required _i27.DerivePathType? derivePathType, - required _i18.PaymentCode? fromPaymentCode, - }) => - (super.noSuchMethod( - Invocation.method( - #generatePaynymReceivingAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #fromPaymentCode: fromPaymentCode, - }, - ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( - this, - Invocation.method( - #generatePaynymReceivingAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #fromPaymentCode: fromPaymentCode, - }, - ), - )), - ) as _i23.Future<_i16.Address>); - @override - _i23.Future<_i16.Address> getMyNotificationAddress( - _i27.DerivePathType? derivePathType, [ - _i17.BIP32? bip32Root, - ]) => - (super.noSuchMethod( + _i23.Future<_i17.Address> getMyNotificationAddress() => (super.noSuchMethod( Invocation.method( #getMyNotificationAddress, - [ - derivePathType, - bip32Root, - ], + [], ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #getMyNotificationAddress, - [ - derivePathType, - bip32Root, - ], + [], ), )), - ) as _i23.Future<_i16.Address>); + ) as _i23.Future<_i17.Address>); @override _i23.Future> lookupKey(String? paymentCodeString) => (super.noSuchMethod( @@ -2323,16 +2247,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i11.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i16.Transaction>[]), - ) as _i23.Future>); + _i23.Future>.value(<_i17.Transaction>[]), + ) as _i23.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i16.UTXO>[]), - ) as _i23.Future>); + returnValue: _i23.Future>.value(<_i17.UTXO>[]), + ) as _i23.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2691,16 +2615,16 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { ), ) as _i11.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i16.Transaction>[]), - ) as _i23.Future>); + _i23.Future>.value(<_i17.Transaction>[]), + ) as _i23.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i16.UTXO>[]), - ) as _i23.Future>); + returnValue: _i23.Future>.value(<_i17.UTXO>[]), + ) as _i23.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( diff --git a/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart b/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart index 0856db274..40f033633 100644 --- a/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart +++ b/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart @@ -7,7 +7,7 @@ import 'dart:async' as _i23; import 'dart:typed_data' as _i29; import 'dart:ui' as _i25; -import 'package:bip32/bip32.dart' as _i17; +import 'package:bip32/bip32.dart' as _i16; import 'package:bip47/bip47.dart' as _i18; import 'package:bitcoindart/bitcoindart.dart' as _i13; import 'package:flutter/foundation.dart' as _i4; @@ -17,7 +17,7 @@ import 'package:stackwallet/db/isar/main_db.dart' as _i12; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart' as _i10; import 'package:stackwallet/electrumx_rpc/electrumx.dart' as _i9; import 'package:stackwallet/models/balance.dart' as _i11; -import 'package:stackwallet/models/isar/models/isar_models.dart' as _i16; +import 'package:stackwallet/models/isar/models/isar_models.dart' as _i17; import 'package:stackwallet/models/node_model.dart' as _i30; import 'package:stackwallet/models/paymint/fee_object_model.dart' as _i8; import 'package:stackwallet/models/signing_data.dart' as _i28; @@ -193,8 +193,8 @@ class _FakeTuple2_13 extends _i1.SmartFake ); } -class _FakeAddress_14 extends _i1.SmartFake implements _i16.Address { - _FakeAddress_14( +class _FakeBIP32_14 extends _i1.SmartFake implements _i16.BIP32 { + _FakeBIP32_14( Object parent, Invocation parentInvocation, ) : super( @@ -203,8 +203,8 @@ class _FakeAddress_14 extends _i1.SmartFake implements _i16.Address { ); } -class _FakeBIP32_15 extends _i1.SmartFake implements _i17.BIP32 { - _FakeBIP32_15( +class _FakeAddress_15 extends _i1.SmartFake implements _i17.Address { + _FakeAddress_15( Object parent, Invocation parentInvocation, ) : super( @@ -778,16 +778,16 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValue: _i22.Coin.bitcoin, ) as _i22.Coin); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i16.UTXO>[]), - ) as _i23.Future>); + returnValue: _i23.Future>.value(<_i17.UTXO>[]), + ) as _i23.Future>); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i16.Transaction>[]), - ) as _i23.Future>); + _i23.Future>.value(<_i17.Transaction>[]), + ) as _i23.Future>); @override _i23.Future get currentReceivingAddress => (super.noSuchMethod( Invocation.getter(#currentReceivingAddress), @@ -1196,7 +1196,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { required bool? coinControl, required bool? isSendAll, int? additionalOutputs = 0, - List<_i16.UTXO>? utxos, + List<_i17.UTXO>? utxos, }) => super.noSuchMethod(Invocation.method( #coinSelection, @@ -1213,7 +1213,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { )); @override _i23.Future> fetchBuildTxData( - List<_i16.UTXO>? utxosToUse) => + List<_i17.UTXO>? utxosToUse) => (super.noSuchMethod( Invocation.method( #fetchBuildTxData, @@ -1467,10 +1467,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>> parseTransaction( + _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>> parseTransaction( Map? txData, dynamic electrumxClient, - List<_i16.Address>? myAddresses, + List<_i17.Address>? myAddresses, _i22.Coin? coin, int? minConfirms, String? walletId, @@ -1488,8 +1488,8 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ], ), returnValue: - _i23.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>>.value( - _FakeTuple2_13<_i16.Transaction, _i16.Address>( + _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>.value( + _FakeTuple2_13<_i17.Transaction, _i17.Address>( this, Invocation.method( #parseTransaction, @@ -1503,7 +1503,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { ], ), )), - ) as _i23.Future<_i15.Tuple2<_i16.Transaction, _i16.Address>>); + ) as _i23.Future<_i15.Tuple2<_i17.Transaction, _i17.Address>>); @override void initPaynymWalletInterface({ required String? walletId, @@ -1513,6 +1513,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { required _i12.MainDB? db, required _i9.ElectrumX? electrumXClient, required _i19.SecureStorageInterface? secureStorage, + required int? dustLimit, required int? dustLimitP2PKH, required int? minConfirms, required _i23.Future Function()? getMnemonicString, @@ -1531,7 +1532,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { })? prepareSend, required _i23.Future Function({required String address})? getTxCount, - required _i23.Future> Function(List<_i16.UTXO>)? + required _i23.Future> Function(List<_i17.UTXO>)? fetchBuildTxData, required _i23.Future Function()? refresh, required _i23.Future Function()? checkChangeAddressForTransactions, @@ -1548,6 +1549,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { #db: db, #electrumXClient: electrumXClient, #secureStorage: secureStorage, + #dustLimit: dustLimit, #dustLimitP2PKH: dustLimitP2PKH, #minConfirms: minConfirms, #getMnemonicString: getMnemonicString, @@ -1566,28 +1568,74 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: null, ); @override - _i23.Future<_i16.Address> currentReceivingPaynymAddress( - _i18.PaymentCode? sender) => + _i23.Future<_i16.BIP32> getBip47BaseNode() => (super.noSuchMethod( + Invocation.method( + #getBip47BaseNode, + [], + ), + returnValue: _i23.Future<_i16.BIP32>.value(_FakeBIP32_14( + this, + Invocation.method( + #getBip47BaseNode, + [], + ), + )), + ) as _i23.Future<_i16.BIP32>); + @override + _i23.Future<_i29.Uint8List> getPrivateKeyForPaynymReceivingAddress({ + required String? paymentCodeString, + required int? index, + }) => + (super.noSuchMethod( + Invocation.method( + #getPrivateKeyForPaynymReceivingAddress, + [], + { + #paymentCodeString: paymentCodeString, + #index: index, + }, + ), + returnValue: _i23.Future<_i29.Uint8List>.value(_i29.Uint8List(0)), + ) as _i23.Future<_i29.Uint8List>); + @override + _i23.Future<_i17.Address> currentReceivingPaynymAddress({ + required _i18.PaymentCode? sender, + required bool? isSegwit, + }) => (super.noSuchMethod( Invocation.method( #currentReceivingPaynymAddress, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #currentReceivingPaynymAddress, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), )), - ) as _i23.Future<_i16.Address>); + ) as _i23.Future<_i17.Address>); @override - _i23.Future checkCurrentPaynymReceivingAddressForTransactions( - _i18.PaymentCode? sender) => + _i23.Future checkCurrentPaynymReceivingAddressForTransactions({ + required _i18.PaymentCode? sender, + required bool? isSegwit, + }) => (super.noSuchMethod( Invocation.method( #checkCurrentPaynymReceivingAddressForTransactions, - [sender], + [], + { + #sender: sender, + #isSegwit: isSegwit, + }, ), returnValue: _i23.Future.value(), returnValueForMissingStub: _i23.Future.value(), @@ -1603,81 +1651,33 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future<_i17.BIP32> deriveNotificationBip32Node({ - required String? mnemonic, - required String? mnemonicPassphrase, - }) => - (super.noSuchMethod( + _i23.Future<_i16.BIP32> deriveNotificationBip32Node() => (super.noSuchMethod( Invocation.method( #deriveNotificationBip32Node, [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - }, ), - returnValue: _i23.Future<_i17.BIP32>.value(_FakeBIP32_15( + returnValue: _i23.Future<_i16.BIP32>.value(_FakeBIP32_14( this, Invocation.method( #deriveNotificationBip32Node, [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - }, ), )), - ) as _i23.Future<_i17.BIP32>); + ) as _i23.Future<_i16.BIP32>); @override - _i23.Future<_i17.BIP32> deriveReceivingPrivateKeyNode({ - required String? mnemonic, - required String? mnemonicPassphrase, - required int? index, - }) => - (super.noSuchMethod( - Invocation.method( - #deriveReceivingPrivateKeyNode, - [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - #index: index, - }, - ), - returnValue: _i23.Future<_i17.BIP32>.value(_FakeBIP32_15( - this, - Invocation.method( - #deriveReceivingPrivateKeyNode, - [], - { - #mnemonic: mnemonic, - #mnemonicPassphrase: mnemonicPassphrase, - #index: index, - }, - ), - )), - ) as _i23.Future<_i17.BIP32>); - @override - _i23.Future<_i18.PaymentCode> getPaymentCode( - _i27.DerivePathType? derivePathType, [ - _i17.BIP32? bip32Root, - ]) => + _i23.Future<_i18.PaymentCode> getPaymentCode({required bool? isSegwit}) => (super.noSuchMethod( Invocation.method( #getPaymentCode, - [ - derivePathType, - bip32Root, - ], + [], + {#isSegwit: isSegwit}, ), returnValue: _i23.Future<_i18.PaymentCode>.value(_FakePaymentCode_16( this, Invocation.method( #getPaymentCode, - [ - derivePathType, - bip32Root, - ], + [], + {#isSegwit: isSegwit}, ), )), ) as _i23.Future<_i18.PaymentCode>); @@ -1702,6 +1702,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { @override _i23.Future> preparePaymentCodeSend({ required _i18.PaymentCode? paymentCode, + required bool? isSegwit, required _i14.Amount? amount, Map? args, }) => @@ -1711,6 +1712,7 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { [], { #paymentCode: paymentCode, + #isSegwit: isSegwit, #amount: amount, #args: args, }, @@ -1719,9 +1721,10 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { _i23.Future>.value({}), ) as _i23.Future>); @override - _i23.Future<_i16.Address> nextUnusedSendAddressFrom({ + _i23.Future<_i17.Address> nextUnusedSendAddressFrom({ required _i18.PaymentCode? pCode, - required _i17.BIP32? privateKeyNode, + required bool? isSegwit, + required _i16.BIP32? privateKeyNode, int? startIndex = 0, }) => (super.noSuchMethod( @@ -1730,29 +1733,31 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { [], { #pCode: pCode, + #isSegwit: isSegwit, #privateKeyNode: privateKeyNode, #startIndex: startIndex, }, ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #nextUnusedSendAddressFrom, [], { #pCode: pCode, + #isSegwit: isSegwit, #privateKeyNode: privateKeyNode, #startIndex: startIndex, }, ), )), - ) as _i23.Future<_i16.Address>); + ) as _i23.Future<_i17.Address>); @override _i23.Future> prepareNotificationTx({ required int? selectedTxFeeRate, required String? targetPaymentCodeString, int? additionalOutputs = 0, - List<_i16.UTXO>? utxos, + List<_i17.UTXO>? utxos, }) => (super.noSuchMethod( Invocation.method( @@ -1789,34 +1794,24 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValue: _i23.Future.value(false), ) as _i23.Future); @override - _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction({ - required _i16.Transaction? transaction, - required _i16.Address? myNotificationAddress, - }) => + _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransaction( + {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransaction, [], - { - #transaction: transaction, - #myNotificationAddress: myNotificationAddress, - }, + {#transaction: transaction}, ), returnValue: _i23.Future<_i18.PaymentCode?>.value(), ) as _i23.Future<_i18.PaymentCode?>); @override - _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad({ - required _i16.Transaction? transaction, - required _i16.Address? myNotificationAddress, - }) => + _i23.Future<_i18.PaymentCode?> unBlindedPaymentCodeFromTransactionBad( + {required _i17.Transaction? transaction}) => (super.noSuchMethod( Invocation.method( #unBlindedPaymentCodeFromTransactionBad, [], - { - #transaction: transaction, - #myNotificationAddress: myNotificationAddress, - }, + {#transaction: transaction}, ), returnValue: _i23.Future<_i18.PaymentCode?>.value(), ) as _i23.Future<_i18.PaymentCode?>); @@ -1861,111 +1856,40 @@ class MockBitcoinWallet extends _i1.Mock implements _i26.BitcoinWallet { returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future restoreHistoryWith( - _i18.PaymentCode? other, - int? maxUnusedAddressGap, - int? maxNumberOfIndexesToCheck, - ) => + _i23.Future restoreHistoryWith({ + required _i18.PaymentCode? other, + required bool? checkSegwitAsWell, + required int? maxUnusedAddressGap, + required int? maxNumberOfIndexesToCheck, + }) => (super.noSuchMethod( Invocation.method( #restoreHistoryWith, - [ - other, - maxUnusedAddressGap, - maxNumberOfIndexesToCheck, - ], + [], + { + #other: other, + #checkSegwitAsWell: checkSegwitAsWell, + #maxUnusedAddressGap: maxUnusedAddressGap, + #maxNumberOfIndexesToCheck: maxNumberOfIndexesToCheck, + }, ), returnValue: _i23.Future.value(), returnValueForMissingStub: _i23.Future.value(), ) as _i23.Future); @override - _i23.Future<_i16.Address> generatePaynymSendAddressFromKeyPair({ - required _i13.ECPair? pair, - required int? derivationIndex, - required _i27.DerivePathType? derivePathType, - required _i18.PaymentCode? toPaymentCode, - }) => - (super.noSuchMethod( - Invocation.method( - #generatePaynymSendAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #toPaymentCode: toPaymentCode, - }, - ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( - this, - Invocation.method( - #generatePaynymSendAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #toPaymentCode: toPaymentCode, - }, - ), - )), - ) as _i23.Future<_i16.Address>); - @override - _i23.Future<_i16.Address> generatePaynymReceivingAddressFromKeyPair({ - required _i13.ECPair? pair, - required int? derivationIndex, - required _i27.DerivePathType? derivePathType, - required _i18.PaymentCode? fromPaymentCode, - }) => - (super.noSuchMethod( - Invocation.method( - #generatePaynymReceivingAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #fromPaymentCode: fromPaymentCode, - }, - ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( - this, - Invocation.method( - #generatePaynymReceivingAddressFromKeyPair, - [], - { - #pair: pair, - #derivationIndex: derivationIndex, - #derivePathType: derivePathType, - #fromPaymentCode: fromPaymentCode, - }, - ), - )), - ) as _i23.Future<_i16.Address>); - @override - _i23.Future<_i16.Address> getMyNotificationAddress( - _i27.DerivePathType? derivePathType, [ - _i17.BIP32? bip32Root, - ]) => - (super.noSuchMethod( + _i23.Future<_i17.Address> getMyNotificationAddress() => (super.noSuchMethod( Invocation.method( #getMyNotificationAddress, - [ - derivePathType, - bip32Root, - ], + [], ), - returnValue: _i23.Future<_i16.Address>.value(_FakeAddress_14( + returnValue: _i23.Future<_i17.Address>.value(_FakeAddress_15( this, Invocation.method( #getMyNotificationAddress, - [ - derivePathType, - bip32Root, - ], + [], ), )), - ) as _i23.Future<_i16.Address>); + ) as _i23.Future<_i17.Address>); @override _i23.Future> lookupKey(String? paymentCodeString) => (super.noSuchMethod( @@ -2323,16 +2247,16 @@ class MockManager extends _i1.Mock implements _i6.Manager { ), ) as _i11.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i16.Transaction>[]), - ) as _i23.Future>); + _i23.Future>.value(<_i17.Transaction>[]), + ) as _i23.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i16.UTXO>[]), - ) as _i23.Future>); + returnValue: _i23.Future>.value(<_i17.UTXO>[]), + ) as _i23.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter( @@ -2691,16 +2615,16 @@ class MockCoinServiceAPI extends _i1.Mock implements _i20.CoinServiceAPI { ), ) as _i11.Balance); @override - _i23.Future> get transactions => (super.noSuchMethod( + _i23.Future> get transactions => (super.noSuchMethod( Invocation.getter(#transactions), returnValue: - _i23.Future>.value(<_i16.Transaction>[]), - ) as _i23.Future>); + _i23.Future>.value(<_i17.Transaction>[]), + ) as _i23.Future>); @override - _i23.Future> get utxos => (super.noSuchMethod( + _i23.Future> get utxos => (super.noSuchMethod( Invocation.getter(#utxos), - returnValue: _i23.Future>.value(<_i16.UTXO>[]), - ) as _i23.Future>); + returnValue: _i23.Future>.value(<_i17.UTXO>[]), + ) as _i23.Future>); @override set walletName(String? newName) => super.noSuchMethod( Invocation.setter(