2024-03-04 19:32:10 +02:00
|
|
|
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
2024-01-23 07:15:24 +02:00
|
|
|
import 'package:cake_wallet/src/screens/new_wallet/widgets/select_button.dart';
|
2023-08-17 12:28:31 -03:00
|
|
|
import 'package:cake_wallet/themes/extensions/keyboard_theme.dart';
|
2023-08-29 19:11:51 +03:00
|
|
|
import 'package:cake_wallet/di.dart';
|
|
|
|
import 'package:cake_wallet/src/screens/base_page.dart';
|
|
|
|
import 'package:cake_wallet/src/screens/monero_accounts/monero_account_list_page.dart';
|
2023-03-24 17:26:42 +02:00
|
|
|
import 'package:cake_wallet/anonpay/anonpay_donation_link_info.dart';
|
|
|
|
import 'package:cake_wallet/entities/preferences_key.dart';
|
Btc address types (#1263)
* inital migration changes
* feat: rest of changes
* minor fix [skip ci]
* fix: P2wshAddress & wallet address index
* fix: address review comments
* fix: address type restore
* feat: add testnet
* Fix review comments
Remove bitcoin_base from cw_core
* Fix address not matching selected type on start
* remove un-necessary parameter [skip ci]
* Remove bitcoin specific code from main lib
Fix possible runtime exception from list wrong access
* Minor fix
* fix: fixes for Testnet
* fix: bitcoin receive option dependency breaks monerocom
* Fix issues when building Monero.com
* feat: Transaction Builder changes
* fix: discover addresses, testnet restoring, duplicate unspent coins, and taproot address vs schnorr sig tweak
* fix: remove print
* feat: improve error when failed broadcast response
* feat: create fish shell env script
* fix: unmodifiable maps
* fix: build
* fix: build
* fix: computed observable side effect bug
* feat: add nix script for android build_all
* fix: wrong keypairs used for signing
* fix: wrong addresses when using fromScriptPubKey scripts
* fix(actual commit): testnet tx expanded + wrong addresses when using fromScriptPubKey scripts (update bitcoin_base deps)
* fix: self-send [skip ci]
* fix: p2wsh
* fix: testnet fees
* New versions
* Update macos build number
Minor UI fix
* fix: use new bitcoin_base ref, fix tx list wrong hex value & refactor hidden vs hd use
- if always use sideHd for isHidden, it is easier to simplify the functions instead of passing both which can be error prone
- (ps: now this could probably be changed, for example from isHidden to isChange since with address list we now see "hidden" addresses)
* Fix if condition to handle litecoin case
* fix: self-send, change address was always making direction incoming
* refactor: improve estimation function, add more inputs if balance missing
* fix: new bitcoin_base update, fixes script issues
* Update evm chain wallet service arguments
* Fix translation [skip ci]
* Fix translation [skip ci]
* Update strings_fr.arb [skip ci]
* fix: async isChange function not being awaited, refactor to reduce looping into a single place
* fix: _address vs address, missing p2sh
* fix: minor mistake in storing p2sh page type [skip ci]
* refactor: use already matched addresses property
* feat: improved perfomance for fetching transaction histories
* feat: continue perfomance change, improve address discovery only to last address by type with history
* fix: make sure transaction list is sorted by date
* refactor: isTestnet only for bitcoin
* fix: walletInfo type null case
* fix: deprecated p2pk
* refactor: make condition more readable
* refactor: remove unnecessary Str variant
* refactor: make condition more readable
* fix: infinite loop possible
* Revert removing isTestnet from other wallets [skip ci]
* refactor: rename addresses when matched by receive type
* Make the beta build [skip ci]
Remove app_env.fish
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-02-23 13:13:30 -03:00
|
|
|
import 'package:cw_core/receive_page_option.dart';
|
2023-03-24 17:26:42 +02:00
|
|
|
import 'package:cake_wallet/src/screens/dashboard/widgets/present_receive_option_picker.dart';
|
2023-08-17 12:28:31 -03:00
|
|
|
import 'package:cake_wallet/src/widgets/gradient_background.dart';
|
2021-01-07 14:19:21 +02:00
|
|
|
import 'package:cake_wallet/src/widgets/keyboard_done_button.dart';
|
2023-08-17 12:28:31 -03:00
|
|
|
import 'package:cake_wallet/themes/extensions/sync_indicator_theme.dart';
|
2021-06-04 20:48:33 +03:00
|
|
|
import 'package:cake_wallet/themes/theme_base.dart';
|
2023-04-26 14:59:27 +02:00
|
|
|
import 'package:cake_wallet/utils/responsive_layout_util.dart';
|
2023-02-08 20:16:12 +02:00
|
|
|
import 'package:cake_wallet/utils/share_util.dart';
|
2021-06-04 13:30:59 +03:00
|
|
|
import 'package:cake_wallet/utils/show_pop_up.dart';
|
2023-03-24 17:26:42 +02:00
|
|
|
import 'package:cake_wallet/view_model/dashboard/receive_option_view_model.dart';
|
2021-06-04 13:30:59 +03:00
|
|
|
import 'package:cake_wallet/view_model/dashboard/dashboard_view_model.dart';
|
2024-01-23 07:15:24 +02:00
|
|
|
import 'package:cw_core/wallet_type.dart';
|
2020-07-27 20:07:37 +03:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart';
|
|
|
|
import 'package:cake_wallet/src/screens/receive/widgets/qr_widget.dart';
|
|
|
|
import 'package:cake_wallet/routes.dart';
|
|
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
2020-12-17 22:50:26 +02:00
|
|
|
import 'package:flutter_mobx/flutter_mobx.dart';
|
2021-01-07 14:19:21 +02:00
|
|
|
import 'package:keyboard_actions/keyboard_actions.dart';
|
2021-06-04 13:30:59 +03:00
|
|
|
import 'package:mobx/mobx.dart';
|
2023-03-24 17:26:42 +02:00
|
|
|
import 'package:shared_preferences/shared_preferences.dart';
|
2023-08-17 12:28:31 -03:00
|
|
|
import 'package:cake_wallet/themes/extensions/balance_page_theme.dart';
|
2020-07-27 20:07:37 +03:00
|
|
|
|
2022-03-30 17:57:04 +02:00
|
|
|
class AddressPage extends BasePage {
|
2022-10-12 13:09:57 -04:00
|
|
|
AddressPage({
|
|
|
|
required this.addressListViewModel,
|
2023-04-14 06:39:08 +02:00
|
|
|
required this.dashboardViewModel,
|
2023-03-24 17:26:42 +02:00
|
|
|
required this.receiveOptionViewModel,
|
2023-08-04 20:01:49 +03:00
|
|
|
}) : _cryptoAmountFocus = FocusNode(),
|
|
|
|
_formKey = GlobalKey<FormState>(),
|
|
|
|
_amountController = TextEditingController() {
|
|
|
|
_amountController.addListener(() {
|
|
|
|
if (_formKey.currentState!.validate()) {
|
|
|
|
addressListViewModel.changeAmount(
|
|
|
|
_amountController.text,
|
|
|
|
);
|
|
|
|
}
|
2023-04-21 21:03:42 +03:00
|
|
|
});
|
|
|
|
}
|
2020-07-27 20:07:37 +03:00
|
|
|
|
|
|
|
final WalletAddressListViewModel addressListViewModel;
|
2023-04-14 06:39:08 +02:00
|
|
|
final DashboardViewModel dashboardViewModel;
|
2023-03-24 17:26:42 +02:00
|
|
|
final ReceiveOptionViewModel receiveOptionViewModel;
|
2023-04-21 21:03:42 +03:00
|
|
|
final TextEditingController _amountController;
|
|
|
|
final GlobalKey<FormState> _formKey;
|
2020-07-27 20:07:37 +03:00
|
|
|
|
2021-01-07 14:19:21 +02:00
|
|
|
final FocusNode _cryptoAmountFocus;
|
|
|
|
|
2020-07-27 20:07:37 +03:00
|
|
|
@override
|
2023-08-17 12:28:31 -03:00
|
|
|
bool get gradientBackground => true;
|
2022-03-30 17:57:04 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
bool get resizeToAvoidBottomInset => false;
|
|
|
|
|
2023-03-24 17:26:42 +02:00
|
|
|
bool effectsInstalled = false;
|
|
|
|
|
2023-04-14 06:39:08 +02:00
|
|
|
@override
|
2023-04-26 14:59:27 +02:00
|
|
|
Widget? leading(BuildContext context) {
|
2023-11-03 07:42:18 +02:00
|
|
|
final _backButton = Icon(
|
|
|
|
Icons.arrow_back_ios,
|
|
|
|
color: titleColor(context),
|
|
|
|
size: 16,
|
|
|
|
);
|
|
|
|
final _closeButton =
|
Btc address types (#1263)
* inital migration changes
* feat: rest of changes
* minor fix [skip ci]
* fix: P2wshAddress & wallet address index
* fix: address review comments
* fix: address type restore
* feat: add testnet
* Fix review comments
Remove bitcoin_base from cw_core
* Fix address not matching selected type on start
* remove un-necessary parameter [skip ci]
* Remove bitcoin specific code from main lib
Fix possible runtime exception from list wrong access
* Minor fix
* fix: fixes for Testnet
* fix: bitcoin receive option dependency breaks monerocom
* Fix issues when building Monero.com
* feat: Transaction Builder changes
* fix: discover addresses, testnet restoring, duplicate unspent coins, and taproot address vs schnorr sig tweak
* fix: remove print
* feat: improve error when failed broadcast response
* feat: create fish shell env script
* fix: unmodifiable maps
* fix: build
* fix: build
* fix: computed observable side effect bug
* feat: add nix script for android build_all
* fix: wrong keypairs used for signing
* fix: wrong addresses when using fromScriptPubKey scripts
* fix(actual commit): testnet tx expanded + wrong addresses when using fromScriptPubKey scripts (update bitcoin_base deps)
* fix: self-send [skip ci]
* fix: p2wsh
* fix: testnet fees
* New versions
* Update macos build number
Minor UI fix
* fix: use new bitcoin_base ref, fix tx list wrong hex value & refactor hidden vs hd use
- if always use sideHd for isHidden, it is easier to simplify the functions instead of passing both which can be error prone
- (ps: now this could probably be changed, for example from isHidden to isChange since with address list we now see "hidden" addresses)
* Fix if condition to handle litecoin case
* fix: self-send, change address was always making direction incoming
* refactor: improve estimation function, add more inputs if balance missing
* fix: new bitcoin_base update, fixes script issues
* Update evm chain wallet service arguments
* Fix translation [skip ci]
* Fix translation [skip ci]
* Update strings_fr.arb [skip ci]
* fix: async isChange function not being awaited, refactor to reduce looping into a single place
* fix: _address vs address, missing p2sh
* fix: minor mistake in storing p2sh page type [skip ci]
* refactor: use already matched addresses property
* feat: improved perfomance for fetching transaction histories
* feat: continue perfomance change, improve address discovery only to last address by type with history
* fix: make sure transaction list is sorted by date
* refactor: isTestnet only for bitcoin
* fix: walletInfo type null case
* fix: deprecated p2pk
* refactor: make condition more readable
* refactor: remove unnecessary Str variant
* refactor: make condition more readable
* fix: infinite loop possible
* Revert removing isTestnet from other wallets [skip ci]
* refactor: rename addresses when matched by receive type
* Make the beta build [skip ci]
Remove app_env.fish
---------
Co-authored-by: OmarHatem <omarh.ismail1@gmail.com>
2024-02-23 13:13:30 -03:00
|
|
|
currentTheme.type == ThemeType.dark ? closeButtonImageDarkTheme : closeButtonImage;
|
2023-11-03 07:42:18 +02:00
|
|
|
|
|
|
|
bool isMobileView = responsiveLayoutUtil.shouldRenderMobileUI;
|
2023-04-26 14:59:27 +02:00
|
|
|
|
|
|
|
return MergeSemantics(
|
|
|
|
child: SizedBox(
|
|
|
|
height: isMobileView ? 37 : 45,
|
|
|
|
width: isMobileView ? 37 : 45,
|
|
|
|
child: ButtonTheme(
|
|
|
|
minWidth: double.minPositive,
|
|
|
|
child: Semantics(
|
2023-08-04 20:01:49 +03:00
|
|
|
label: !isMobileView ? S.of(context).close : S.of(context).seed_alert_back,
|
2023-04-26 14:59:27 +02:00
|
|
|
child: TextButton(
|
|
|
|
style: ButtonStyle(
|
2023-08-04 20:01:49 +03:00
|
|
|
overlayColor: MaterialStateColor.resolveWith((states) => Colors.transparent),
|
2023-04-26 14:59:27 +02:00
|
|
|
),
|
|
|
|
onPressed: () => onClose(context),
|
2023-11-03 07:42:18 +02:00
|
|
|
child: !isMobileView ? _closeButton : _backButton,
|
2023-04-26 14:59:27 +02:00
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2022-03-30 17:57:04 +02:00
|
|
|
|
|
|
|
@override
|
2023-08-04 20:01:49 +03:00
|
|
|
Widget middle(BuildContext context) => PresentReceiveOptionPicker(
|
2023-08-17 12:28:31 -03:00
|
|
|
color: titleColor(context), receiveOptionViewModel: receiveOptionViewModel);
|
2022-03-30 17:57:04 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget Function(BuildContext, Widget) get rootWrapper =>
|
2023-08-17 12:28:31 -03:00
|
|
|
(BuildContext context, Widget scaffold) => GradientBackground(scaffold: scaffold);
|
2022-03-30 17:57:04 +02:00
|
|
|
|
2022-10-26 18:05:08 +03:00
|
|
|
@override
|
|
|
|
Widget? trailing(BuildContext context) {
|
2023-04-21 21:03:42 +03:00
|
|
|
return Material(
|
|
|
|
color: Colors.transparent,
|
2023-10-19 01:08:29 +03:00
|
|
|
child: Semantics(
|
|
|
|
label: S.of(context).share,
|
|
|
|
child: IconButton(
|
|
|
|
padding: EdgeInsets.zero,
|
|
|
|
constraints: BoxConstraints(),
|
|
|
|
highlightColor: Colors.transparent,
|
|
|
|
splashColor: Colors.transparent,
|
|
|
|
iconSize: 25,
|
|
|
|
onPressed: () {
|
|
|
|
ShareUtil.share(
|
|
|
|
text: addressListViewModel.uri.toString(),
|
|
|
|
context: context,
|
|
|
|
);
|
|
|
|
},
|
|
|
|
icon: Icon(Icons.share, size: 20, color: pageIconColor(context)),
|
|
|
|
),
|
2023-04-21 21:03:42 +03:00
|
|
|
),
|
|
|
|
);
|
2022-10-26 18:05:08 +03:00
|
|
|
}
|
|
|
|
|
2022-03-30 17:57:04 +02:00
|
|
|
@override
|
|
|
|
Widget body(BuildContext context) {
|
2023-03-24 17:26:42 +02:00
|
|
|
_setEffects(context);
|
|
|
|
|
2021-01-07 14:19:21 +02:00
|
|
|
return KeyboardActions(
|
2021-01-11 19:15:27 +02:00
|
|
|
autoScroll: false,
|
|
|
|
disableScroll: true,
|
2023-08-18 18:37:17 +03:00
|
|
|
tapOutsideBehavior: TapOutsideBehavior.translucentDismiss,
|
2021-01-07 14:19:21 +02:00
|
|
|
config: KeyboardActionsConfig(
|
|
|
|
keyboardActionsPlatform: KeyboardActionsPlatform.IOS,
|
2023-08-18 18:37:17 +03:00
|
|
|
keyboardBarColor: Theme.of(context).extension<KeyboardTheme>()!.keyboardBarColor,
|
2021-01-07 14:19:21 +02:00
|
|
|
nextFocus: false,
|
|
|
|
actions: [
|
|
|
|
KeyboardActionsItem(
|
|
|
|
focusNode: _cryptoAmountFocus,
|
|
|
|
toolbarButtons: [(_) => KeyboardDoneButton()],
|
|
|
|
)
|
|
|
|
]),
|
|
|
|
child: Container(
|
2023-04-21 21:03:42 +03:00
|
|
|
padding: EdgeInsets.fromLTRB(24, 0, 24, 32),
|
2021-01-07 14:19:21 +02:00
|
|
|
child: Column(
|
|
|
|
children: <Widget>[
|
2023-04-21 21:03:42 +03:00
|
|
|
Expanded(
|
|
|
|
child: Observer(
|
|
|
|
builder: (_) => QRWidget(
|
|
|
|
formKey: _formKey,
|
|
|
|
addressListViewModel: addressListViewModel,
|
|
|
|
amountTextFieldFocusNode: _cryptoAmountFocus,
|
|
|
|
amountController: _amountController,
|
|
|
|
isLight: dashboardViewModel.settingsStore.currentTheme.type ==
|
|
|
|
ThemeType.light))),
|
2024-01-23 07:15:24 +02:00
|
|
|
SizedBox(height: 16),
|
2021-01-12 13:14:28 +02:00
|
|
|
Observer(builder: (_) {
|
2023-08-04 20:01:49 +03:00
|
|
|
if (addressListViewModel.hasAddressList) {
|
2024-01-23 07:15:24 +02:00
|
|
|
return SelectButton(
|
|
|
|
text: addressListViewModel.buttonTitle,
|
2024-04-08 19:04:16 -04:00
|
|
|
onTap: () async => Navigator.of(context).pushNamed(Routes.receive),
|
2024-01-23 07:15:24 +02:00
|
|
|
textColor: Theme.of(context).extension<SyncIndicatorTheme>()!.textColor,
|
|
|
|
color: Theme.of(context).extension<SyncIndicatorTheme>()!.syncedBackgroundColor,
|
|
|
|
borderColor: Theme.of(context).extension<BalancePageTheme>()!.cardBorderColor,
|
|
|
|
arrowColor: Theme.of(context).extension<SyncIndicatorTheme>()!.textColor,
|
|
|
|
textSize: 14,
|
|
|
|
height: 50,
|
2023-08-04 20:01:49 +03:00
|
|
|
);
|
2024-04-08 19:04:16 -04:00
|
|
|
}
|
|
|
|
else {
|
2023-08-04 20:01:49 +03:00
|
|
|
return const SizedBox();
|
|
|
|
}
|
2024-04-08 19:04:16 -04:00
|
|
|
}),
|
2021-01-07 14:19:21 +02:00
|
|
|
],
|
|
|
|
),
|
|
|
|
));
|
2020-07-27 20:07:37 +03:00
|
|
|
}
|
2023-03-24 17:26:42 +02:00
|
|
|
|
|
|
|
void _setEffects(BuildContext context) {
|
|
|
|
if (effectsInstalled) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
reaction((_) => receiveOptionViewModel.selectedReceiveOption, (ReceivePageOption option) {
|
Cw 453 (#1306)
* feat: rebase btc-addr-types, migrate to bitcoin_base
* feat: allow scanning elect-rs using get_tweaks
* feat: scanning and adding addresses working with getTweaks, add btc SP address type
* chore: pubspec.lock
* chore: pubspec.lock
* fix: scan when switching, fix multiple unspents in same tx
* fix: initial scan
* fix: initial scan
* fix: scanning issues
* fix: sync, storing silent unspents
* chore: deps
* fix: label issues, clear spent utxo
* chore: deps
* fix: build
* fix: missing types
* feat: new electrs API & changes, fixes for last block scanning
* feat: Scan Silent Payments homepage toggle
* chore: build configure
* feat: generic fixes, testnet UI improvements, useSSL on bitcoin nodes
* fix: invalid Object in sendData
* feat: improve addresses page & address book displays
* feat: silent payments labeled addresses disclaimer
* fix: missing i18n
* chore: print
* feat: single block scan, rescan by date working for btc mainnet
* feat: new cake features page replace market page, move sp scan toggle, auto switch node pop up alert
* feat: delete silent addresses
* fix: red dot in non ssl nodes
* fix: inconsistent connection states, fix tx history
* fix: tx & balance displays, cpfp sending
* feat: new rust lib
* chore: node path
* fix: check node based on network
* fix: missing txcount from addresses
* style: padding in feature page cards
* fix: restore not getting all wallet addresses by type
* fix: auto switch node broken
* fix: silent payment txs not being restored
* feat: change scanning to subscription model, sync improvements
* fix: scan re-subscription
* fix: default nodes
* fix: improve scanning by date, fix single block scan
* refactor: common function for input tx selection
* fix: nodes & build
* fix: send all with multiple outs
* refactor: unchanged file
* Update pr_test_build.yml
* chore: upgrade
* chore: merge changes
* refactor: unchanged files [skip ci]
* fix: scan fixes, add date, allow sending while scanning
* feat: sync fixes, sp settings
* feat: fix resyncing
* fix: date from height logic, status disconnected & chain tip get
* fix: params
* feat: electrum migration if using cake electrum
* fix nodes
update versions
* re-enable tron
* update sp_scanner to work on iOS [skip ci]
* fix: wrong socket for old electrum nodes
* Fix unchecked wallet type call
* fix: double balance
* feat: node domain
* fix: menu name
* fix: update tip on set scanning
* fix: connection switching back and forth
* feat: check if node is electrs, and supports sp
* chore: fix build
* minor enhancements
* fixes and enhancements
* solve conflicts with main
* fix: status toggle
* minor enhancement
* Monero.com fixes
* update sp_scanner to include windows and linux
---------
Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
2024-05-29 11:43:48 -03:00
|
|
|
if (bitcoin!.isBitcoinReceivePageOption(option)) {
|
|
|
|
addressListViewModel.setAddressType(bitcoin!.getOptionToType(option));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-03-24 17:26:42 +02:00
|
|
|
switch (option) {
|
|
|
|
case ReceivePageOption.anonPayInvoice:
|
2023-06-08 02:16:52 +03:00
|
|
|
Navigator.pushNamed(
|
2023-03-24 17:26:42 +02:00
|
|
|
context,
|
|
|
|
Routes.anonPayInvoicePage,
|
|
|
|
arguments: [addressListViewModel.address.address, option],
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case ReceivePageOption.anonPayDonationLink:
|
|
|
|
final sharedPreferences = getIt.get<SharedPreferences>();
|
|
|
|
final clearnetUrl = sharedPreferences.getString(PreferencesKey.clearnetDonationLink);
|
|
|
|
final onionUrl = sharedPreferences.getString(PreferencesKey.onionDonationLink);
|
|
|
|
|
|
|
|
if (clearnetUrl != null && onionUrl != null) {
|
2023-06-08 02:16:52 +03:00
|
|
|
Navigator.pushNamed(
|
2023-03-24 17:26:42 +02:00
|
|
|
context,
|
|
|
|
Routes.anonPayReceivePage,
|
|
|
|
arguments: AnonpayDonationLinkInfo(
|
|
|
|
clearnetUrl: clearnetUrl,
|
|
|
|
onionUrl: onionUrl,
|
|
|
|
address: addressListViewModel.address.address,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
2023-06-08 02:16:52 +03:00
|
|
|
Navigator.pushNamed(
|
2023-03-24 17:26:42 +02:00
|
|
|
context,
|
|
|
|
Routes.anonPayInvoicePage,
|
|
|
|
arguments: [addressListViewModel.address.address, option],
|
|
|
|
);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
2024-03-04 19:32:10 +02:00
|
|
|
if (addressListViewModel.type == WalletType.bitcoin) {
|
|
|
|
addressListViewModel.setAddressType(bitcoin!.getBitcoinAddressType(option));
|
|
|
|
}
|
2023-03-24 17:26:42 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
effectsInstalled = true;
|
|
|
|
}
|
2020-12-17 15:39:21 +02:00
|
|
|
}
|