mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-21 06:18:42 +02:00
* feat(zcash): initial commit - initial work on cw_zcash - use single .db for everything zcash to speed up sync and scanning - implement silent autoshielding of non-orchard funds - use FFI for everything to fetch the data - add support for passphrase by adding extra word to seed phrase - enforce lints on CI for cw_zcash directory - use correct zcash name, and call transparent zcash tZEC - minor cleanups outsite of cw_zcash - gitmodules, gitignore - db debug - fix broken addressPageType in WalletInfo - enable debug options in kDebugMode and kProfileMode * feat: T address rotation (and cache) wip: minor fixes * wip: shield tx list * fix fiat amounts fix derrivation of rotation account addresses screen for zcash block height fix T address shields improvements Amount in disposable T shields UI improvements show pending outgoing tx in tx history * fix null check on passphrase page fix tx showing as pending rename auto shield txs fixed send all to include fee use rotating address in addressForExchange wrap all calls of WarpApi.getLatestHeight in try catch to prevent leaking errors other minor fixes from notion * wallet group debug cache sent tx address wallet T address rotation fixes automatically pick the fee for auto-shield * fix T address cache deserialization fix autoshield icon fix autoshield text getCachedDestinationAddress fix send address cache * address comments from review * wip: iOS fix * fix swap * Allow cakepay payment from zcash wallet * fix: ios (I'm stupid) fix: reorder addresses to make orchard default fix: send all balance * 5.6.6 bump fix: ios apple review add transport error to ignored exceptions * fix: leaving dust behind when sweeping all * Change wallets order * fix: reflect balance of pending out txs fix: restore height support * linux support (disabled) * fix: date picker for zcash on restore screen fix: build script for linux match WarpApi.warpSync args with upstream * fix: linter script * ensure all exchange providers support ZEC (#2802) * ensure all exchange providers support ZEC * remove zaddr and tzec currencies and refactor providers * Update lib/exchange/provider/near_Intents_exchange_provider.dart * add back old zcash currencies for backward compatibility, thanks Czarek * minor fix [skip ci] --------- Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * Update android/app/src/main/AndroidManifestBase.xml [skip ci] * Update ios/Runner/InfoBase.plist [skip ci] * fix: remove unused code fix: macos fix: disable on linux and macos * update build numbers [skip ci] * Add zcash to birdpay --------- Co-authored-by: Czarek Nakamoto <cyjan@mrcyjanek.net> Co-authored-by: Serhii <borodenko.sv@gmail.com>
216 lines
7.4 KiB
Dart
216 lines
7.4 KiB
Dart
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
|
import 'package:cake_wallet/src/widgets/standard_switch.dart';
|
|
import 'package:cake_wallet/utils/date_picker.dart';
|
|
import 'package:cake_wallet/wownero/wownero.dart';
|
|
import 'package:cake_wallet/zcash/zcash.dart';
|
|
import 'package:cw_core/wallet_type.dart';
|
|
import 'package:flutter/material.dart';
|
|
import 'package:intl/intl.dart';
|
|
import 'package:cake_wallet/generated/i18n.dart';
|
|
import 'package:cake_wallet/monero/monero.dart';
|
|
import 'package:cake_wallet/src/widgets/base_text_form_field.dart';
|
|
import 'package:cake_wallet/decred/decred.dart';
|
|
|
|
class BlockchainHeightWidget extends StatefulWidget {
|
|
BlockchainHeightWidget({
|
|
GlobalKey? key,
|
|
this.onHeightChange,
|
|
this.focusNode,
|
|
this.onHeightOrDateEntered,
|
|
this.hasDatePicker = true,
|
|
this.isSilentPaymentsScan = false,
|
|
this.isMwebScan = false,
|
|
this.toggleSingleScan,
|
|
this.doSingleScan = false,
|
|
this.bitcoinMempoolAPIEnabled,
|
|
required this.walletType,
|
|
this.blockHeightTextFieldKey,
|
|
}) : super(key: key);
|
|
|
|
final Function(int)? onHeightChange;
|
|
final Function(bool)? onHeightOrDateEntered;
|
|
final FocusNode? focusNode;
|
|
final bool hasDatePicker;
|
|
final bool isSilentPaymentsScan;
|
|
final bool isMwebScan;
|
|
final bool doSingleScan;
|
|
final Future<bool>? bitcoinMempoolAPIEnabled;
|
|
final Function()? toggleSingleScan;
|
|
final WalletType walletType;
|
|
final Key? blockHeightTextFieldKey;
|
|
@override
|
|
State<StatefulWidget> createState() => BlockchainHeightState();
|
|
}
|
|
|
|
class BlockchainHeightState extends State<BlockchainHeightWidget> {
|
|
final dateController = TextEditingController();
|
|
final restoreHeightController = TextEditingController();
|
|
|
|
int get height => _height;
|
|
int _height = 0;
|
|
|
|
@override
|
|
void initState() {
|
|
restoreHeightController.addListener(() {
|
|
if (restoreHeightController.text.isNotEmpty) {
|
|
widget.onHeightOrDateEntered?.call(true);
|
|
} else {
|
|
widget.onHeightOrDateEntered?.call(false);
|
|
dateController.text = '';
|
|
}
|
|
try {
|
|
_changeHeight(
|
|
restoreHeightController.text.isNotEmpty ? int.parse(restoreHeightController.text) : 0);
|
|
} catch (_) {
|
|
_changeHeight(0);
|
|
}
|
|
});
|
|
|
|
super.initState();
|
|
}
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return GestureDetector(
|
|
behavior: HitTestBehavior.opaque,
|
|
onTap: () => FocusScope.of(context).unfocus(),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: <Widget>[
|
|
Row(
|
|
children: <Widget>[
|
|
Flexible(
|
|
child: Container(
|
|
padding: EdgeInsets.only(top: 20.0, bottom: 10.0),
|
|
child: BaseTextFormField(
|
|
key: widget.blockHeightTextFieldKey,
|
|
focusNode: widget.focusNode,
|
|
controller: restoreHeightController,
|
|
keyboardType: TextInputType.numberWithOptions(
|
|
signed: false,
|
|
decimal: false,
|
|
),
|
|
hintText: widget.isSilentPaymentsScan
|
|
? S.of(context).silent_payments_scan_from_height
|
|
: S.of(context).widgets_restore_from_blockheight,
|
|
),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
if (widget.hasDatePicker) ...[
|
|
Padding(
|
|
padding: EdgeInsets.only(top: 15, bottom: 15),
|
|
child: Text(
|
|
S.of(context).widgets_or,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
fontSize: 16,
|
|
fontWeight: FontWeight.w500,
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
),
|
|
Row(
|
|
children: <Widget>[
|
|
Flexible(
|
|
child: Container(
|
|
child: InkWell(
|
|
onTap: () => _selectDate(context),
|
|
child: IgnorePointer(
|
|
child: BaseTextFormField(
|
|
controller: dateController,
|
|
hintText: widget.isSilentPaymentsScan
|
|
? S.of(context).silent_payments_scan_from_date
|
|
: S.of(context).widgets_restore_from_date,
|
|
),
|
|
),
|
|
),
|
|
))
|
|
],
|
|
),
|
|
if (widget.isSilentPaymentsScan)
|
|
Padding(
|
|
padding: EdgeInsets.only(top: 24),
|
|
child: Row(
|
|
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
|
children: [
|
|
Text(
|
|
S.of(context).scan_one_block,
|
|
style: Theme.of(context).textTheme.bodyMedium?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
Padding(
|
|
padding: const EdgeInsets.only(right: 8),
|
|
child: StandardSwitch(
|
|
value: widget.doSingleScan,
|
|
onTapped: () => widget.toggleSingleScan?.call(),
|
|
),
|
|
)
|
|
],
|
|
),
|
|
),
|
|
Padding(
|
|
padding: EdgeInsets.only(left: 40, right: 40, top: 24),
|
|
child: Text(
|
|
widget.isSilentPaymentsScan
|
|
? S.of(context).silent_payments_scan_from_date_or_blockheight
|
|
: S.of(context).restore_from_date_or_blockheight,
|
|
textAlign: TextAlign.center,
|
|
style: Theme.of(context).textTheme.bodySmall?.copyWith(
|
|
color: Theme.of(context).colorScheme.onSurfaceVariant,
|
|
),
|
|
),
|
|
)
|
|
]
|
|
],
|
|
),
|
|
);
|
|
}
|
|
|
|
Future<void> _selectDate(BuildContext context) async {
|
|
final now = DateTime.now();
|
|
final date = await getDate(
|
|
context: context,
|
|
initialDate: now.subtract(Duration(days: 1)),
|
|
firstDate: DateTime(2014, DateTime.may),
|
|
lastDate: now);
|
|
|
|
if (date != null) {
|
|
int height;
|
|
if (widget.isMwebScan) {
|
|
height = bitcoin!.getLitecoinHeightByDate(date: date);
|
|
} else if (widget.isSilentPaymentsScan) {
|
|
height = await bitcoin!.getHeightByDate(
|
|
date: date,
|
|
bitcoinMempoolAPIEnabled: await widget.bitcoinMempoolAPIEnabled,
|
|
);
|
|
} else {
|
|
if (widget.walletType == WalletType.decred) {
|
|
height = decred!.heightByDate(date);
|
|
} else if (widget.walletType == WalletType.monero) {
|
|
height = monero!.getHeightByDate(date: date);
|
|
} else if (widget.walletType == WalletType.wownero){
|
|
height = wownero!.getHeightByDate(date: date);
|
|
} else if (widget.walletType == WalletType.zcash) {
|
|
height = await zcash!.getHeightByDate(date);
|
|
} else {
|
|
throw Exception("unknown currency in BlockchainHeightWidget");
|
|
}
|
|
}
|
|
if (mounted) {
|
|
setState(() {
|
|
dateController.text = DateFormat('yyyy-MM-dd').format(date);
|
|
restoreHeightController.text = '$height';
|
|
_changeHeight(height);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
|
|
void _changeHeight(int height) {
|
|
_height = height;
|
|
widget.onHeightChange?.call(height);
|
|
}
|
|
}
|