mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-20 06:08:34 +02:00
Ywallet zcash (#2810)
* 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>
This commit is contained in:
co-authored by
Czarek Nakamoto
Serhii
parent
2a77d359f1
commit
ef9b0fbae6
@@ -62,7 +62,6 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
|
||||
CryptoCurrency.hbar,
|
||||
CryptoCurrency.sc,
|
||||
CryptoCurrency.usdcsol,
|
||||
CryptoCurrency.zaddr,
|
||||
CryptoCurrency.zec,
|
||||
CryptoCurrency.zen,
|
||||
CryptoCurrency.xvg,
|
||||
@@ -140,6 +139,10 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
|
||||
xusd,
|
||||
];
|
||||
|
||||
// well technically not currencies but since we had them a long time ago and don't want to break
|
||||
// the app for users who had contacts saved for them
|
||||
static const zcashCurrencies = [ zec, zaddr, tzec ];
|
||||
|
||||
// title, tag (if applicable), fullName (if unique), raw, name, iconPath
|
||||
static const xmr = CryptoCurrency(title: 'XMR', fullName: 'Monero', raw: 0, name: 'xmr', iconPath: 'assets/images/crypto/monero.webp', decimals: 12);
|
||||
static const ada = CryptoCurrency(title: 'ADA', fullName: 'Cardano', raw: 1, name: 'ada', iconPath: 'assets/images/ada_icon.png', decimals: 6);
|
||||
@@ -186,7 +189,7 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
|
||||
static const usdc = CryptoCurrency(title: 'USDC', tag: 'ETH', fullName: 'USD Coin', raw: 40, name: 'usdc', iconPath: 'assets/images/crypto/usdc.webp', decimals: 6);
|
||||
static const usdcsol = CryptoCurrency(title: 'USDC', tag: 'SOL', fullName: 'USDC Coin', raw: 41, name: 'usdcsol', iconPath: 'assets/images/crypto/usdc.webp', decimals: 6);
|
||||
static const zaddr = CryptoCurrency(title: 'ZZEC', tag: 'ZEC', fullName: 'Shielded Zcash', raw: 42, name: 'zaddr', iconPath: 'assets/images/zec_icon.png', decimals: 8);
|
||||
static const zec = CryptoCurrency(title: 'TZEC', tag: 'ZEC', fullName: 'Transparent Zcash', raw: 43, name: 'zec', iconPath: 'assets/images/zec_icon.png', decimals: 8);
|
||||
static const tzec = CryptoCurrency(title: 'tZEC', tag: 'ZEC', fullName: 'Transparent Zcash', raw: 43, name: 'zec', iconPath: 'assets/images/zec_icon.png', decimals: 8);
|
||||
static const zen = CryptoCurrency(title: 'ZEN', fullName: 'Horizen', raw: 44, name: 'zen', iconPath: 'assets/images/zen_icon.png', decimals: 8);
|
||||
static const xvg = CryptoCurrency(title: 'XVG', fullName: 'Verge', raw: 45, name: 'xvg', iconPath: 'assets/images/xvg_icon.png', decimals: 8);
|
||||
|
||||
@@ -250,23 +253,24 @@ class CryptoCurrency extends EnumerableItem<int> with Serializable<int> implemen
|
||||
static const cbbtc = CryptoCurrency(title: 'CBBTC', tag: 'ETH', fullName: 'Coinbase Wrapped BTC', raw: 103, name: 'cbbtc', iconPath: 'assets/images/cbbtc_icon.png', decimals: 8);
|
||||
static const baseEth = CryptoCurrency(title: 'ETH', tag: 'BASE', fullName: 'Ethereum', raw: 104, name: 'baseth', iconPath: 'assets/images/crypto/base_icon.webp', decimals: 18);
|
||||
static const usde = CryptoCurrency(title: 'USDE', tag: 'BASE', fullName: 'Ethena USDE', raw: 105, name: 'usde', iconPath: 'assets/images/crypto/ethena-usde-logo.png', decimals: 18);
|
||||
static const arbEth = CryptoCurrency(title: 'ETH', tag: 'ARB', fullName: 'Ethereum (Arbitrum One)', raw: 106, name: 'arbeth', iconPath: 'assets/images/crypto/ethereum.webp', decimals: 18);
|
||||
static const usdcArb = CryptoCurrency(title: 'USDC', tag: 'ARB', fullName: 'USDC Coin', raw: 107, name: 'usdcarb', iconPath: 'assets/images/crypto/usdc.webp', decimals: 6);
|
||||
static const arbEth = CryptoCurrency(title: 'ETH', tag: 'ARB', fullName: 'Ethereum (Arbitrum One)', raw: 106, name: 'arbeth', iconPath: 'assets/images/crypto/ethereum.webp', decimals: 18);
|
||||
static const zec = CryptoCurrency(title: 'ZEC', fullName: 'Zcash', raw: 107, name: 'zec', iconPath: 'assets/images/zec_icon.png', decimals: 8);
|
||||
static const usdcArb = CryptoCurrency(title: 'USDC', tag: 'ARB', fullName: 'USDC Coin', raw: 108, name: 'usdcarb', iconPath: 'assets/images/crypto/usdc.webp', decimals: 6);
|
||||
|
||||
static final Map<int, CryptoCurrency> _rawCurrencyMap =
|
||||
[...all, ...havenCurrencies].fold<Map<int, CryptoCurrency>>(<int, CryptoCurrency>{}, (acc, item) {
|
||||
[...all, ...havenCurrencies, ...zcashCurrencies].fold<Map<int, CryptoCurrency>>(<int, CryptoCurrency>{}, (acc, item) {
|
||||
acc.addAll({item.raw: item});
|
||||
return acc;
|
||||
});
|
||||
|
||||
static final Map<String, CryptoCurrency> _nameCurrencyMap =
|
||||
[...all, ...havenCurrencies].fold<Map<String, CryptoCurrency>>(<String, CryptoCurrency>{}, (acc, item) {
|
||||
[...all, ...havenCurrencies, ...zcashCurrencies].fold<Map<String, CryptoCurrency>>(<String, CryptoCurrency>{}, (acc, item) {
|
||||
acc.addAll({item.name: item});
|
||||
return acc;
|
||||
});
|
||||
|
||||
static final Map<String, CryptoCurrency> _fullNameCurrencyMap =
|
||||
[...all, ...havenCurrencies].fold<Map<String, CryptoCurrency>>(<String, CryptoCurrency>{}, (acc, item) {
|
||||
[...all, ...havenCurrencies, ...zcashCurrencies].fold<Map<String, CryptoCurrency>>(<String, CryptoCurrency>{}, (acc, item) {
|
||||
if(item.fullName != null){
|
||||
acc.addAll({item.fullName!.toLowerCase(): item});
|
||||
}
|
||||
|
||||
@@ -44,6 +44,8 @@ CryptoCurrency walletTypeToCryptoCurrency(WalletType type, {bool isTestnet = fal
|
||||
return CryptoCurrency.dcr;
|
||||
case WalletType.dogecoin:
|
||||
return CryptoCurrency.doge;
|
||||
case WalletType.zcash:
|
||||
return CryptoCurrency.zec;
|
||||
case WalletType.none:
|
||||
throw Exception(
|
||||
'Unexpected wallet type: ${type.toString()} for CryptoCurrency walletTypeToCryptoCurrency');
|
||||
|
||||
@@ -115,16 +115,26 @@ Future<Map<String, dynamic>> dumpDb() async {
|
||||
}
|
||||
}
|
||||
|
||||
Future<List<String>> _getTableNames() async {
|
||||
Future<List<String>> _getTableNames(Database db) async {
|
||||
final tableNames = await db.rawQuery('SELECT name FROM sqlite_master WHERE type = "table"');
|
||||
return tableNames.map((e) => (e["name"]).toString()).toList();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> _dumpDb() async {
|
||||
final tableNames = await _getTableNames();
|
||||
final tableNames = await _getTableNames(db);
|
||||
final ret = <String, dynamic>{};
|
||||
for (final tableName in tableNames) {
|
||||
ret[tableName] = await db.query(tableName);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> dumpCustomDb(String path) async {
|
||||
final db = await openDatabase(path);
|
||||
final tableNames = await _getTableNames(db);
|
||||
final ret = <String, dynamic>{};
|
||||
for (final tableName in tableNames) {
|
||||
ret[tableName] = await db.query(tableName);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -38,6 +38,20 @@ class Node extends HiveObject with Keyable {
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return """Node(
|
||||
uriRaw: $uriRaw,
|
||||
path: $path,
|
||||
login: $login,
|
||||
password: $password,
|
||||
useSSL: $useSSL,
|
||||
trusted: $trusted,
|
||||
socksProxyAddress: $socksProxyAddress,
|
||||
isEnabledForAutoSwitching: $isEnabledForAutoSwitching,
|
||||
})""";
|
||||
}
|
||||
|
||||
Node.fromMap(Map<String, Object?> map)
|
||||
: uriRaw = map['uri'] as String? ?? '',
|
||||
path = map['path'] as String? ?? '',
|
||||
@@ -94,6 +108,7 @@ class Node extends HiveObject with Keyable {
|
||||
Uri get uri {
|
||||
switch (type) {
|
||||
case WalletType.monero:
|
||||
case WalletType.zcash:
|
||||
case WalletType.haven:
|
||||
case WalletType.wownero:
|
||||
return Uri.http(uriRaw, '');
|
||||
@@ -176,6 +191,7 @@ class Node extends HiveObject with Keyable {
|
||||
case WalletType.solana:
|
||||
case WalletType.tron:
|
||||
case WalletType.dogecoin:
|
||||
case WalletType.zcash:
|
||||
return requestElectrumServer();
|
||||
case WalletType.zano:
|
||||
return requestZanoNode();
|
||||
|
||||
@@ -1,13 +1,23 @@
|
||||
import 'dart:io';
|
||||
import 'package:cw_core/root_dir.dart';
|
||||
import 'package:cw_core/wallet_type.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
Future<String> pathForWalletDir({required String name, required WalletType type}) async {
|
||||
Future<String> pathForWalletTypeDir({required WalletType type}) async {
|
||||
final root = await getAppDir();
|
||||
final prefix = walletTypeToString(type).toLowerCase();
|
||||
final walletsDir = Directory('${root.path}/wallets');
|
||||
final walletDire = Directory('${walletsDir.path}/$prefix/$name');
|
||||
final walletDir = Directory('${walletsDir.path}/$prefix');
|
||||
|
||||
if (!walletDir.existsSync()) {
|
||||
walletDir.createSync(recursive: true);
|
||||
}
|
||||
|
||||
return walletDir.path;
|
||||
}
|
||||
|
||||
Future<String> pathForWalletDir({required String name, required WalletType type}) async {
|
||||
final typeRoot = await pathForWalletTypeDir(type: type);
|
||||
final walletDire = Directory('${typeRoot}/$name');
|
||||
|
||||
if (!walletDire.existsSync()) {
|
||||
walletDire.createSync(recursive: true);
|
||||
|
||||
@@ -332,6 +332,7 @@ class WalletInfo {
|
||||
this.hashedWalletIdentifier,
|
||||
this.isNonSeedWallet,
|
||||
this.sortOrder,
|
||||
this.addressPageType,
|
||||
) : _yatLastUsedAddressController = StreamController<String>.broadcast();
|
||||
|
||||
factory WalletInfo.external({
|
||||
@@ -374,6 +375,7 @@ class WalletInfo {
|
||||
hashedWalletIdentifier,
|
||||
isNonSeedWallet ?? false,
|
||||
sortOrder ?? 0,
|
||||
null,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -546,6 +548,7 @@ class WalletInfo {
|
||||
"hashedWalletIdentifier": hashedWalletIdentifier,
|
||||
"isNonSeedWallet": isNonSeedWallet ? 1 : 0,
|
||||
"sortOrder": sortOrder,
|
||||
"addressPageType": addressPageType,
|
||||
};
|
||||
|
||||
factory WalletInfo.fromJson(Map<String, dynamic> json) {
|
||||
@@ -569,6 +572,7 @@ class WalletInfo {
|
||||
json['hashedWalletIdentifier'] as String?,
|
||||
(json['isNonSeedWallet'] as int) == 1,
|
||||
json['sortOrder'] as int? ?? 0,
|
||||
json['addressPageType'] as String? ?? null,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -270,6 +270,7 @@ class WalletInfo extends HiveObject {
|
||||
hashedWalletIdentifier,
|
||||
isNonSeedWallet,
|
||||
0,
|
||||
addressPageType,
|
||||
);
|
||||
final wiId = await walletInfo.save();
|
||||
for (final address in usedAddresses ?? <String>[]) {
|
||||
|
||||
@@ -21,6 +21,7 @@ const walletTypes = [
|
||||
WalletType.dogecoin,
|
||||
WalletType.base,
|
||||
WalletType.arbitrum,
|
||||
WalletType.zcash,
|
||||
];
|
||||
|
||||
@HiveType(typeId: WALLET_TYPE_TYPE_ID)
|
||||
@@ -78,6 +79,9 @@ enum WalletType {
|
||||
|
||||
@HiveField(17)
|
||||
arbitrum,
|
||||
|
||||
@HiveField(18)
|
||||
zcash,
|
||||
}
|
||||
|
||||
int serializeToInt(WalletType type) {
|
||||
@@ -116,6 +120,8 @@ int serializeToInt(WalletType type) {
|
||||
return 15;
|
||||
case WalletType.arbitrum:
|
||||
return 16;
|
||||
case WalletType.zcash:
|
||||
return 17;
|
||||
case WalletType.none:
|
||||
return -1;
|
||||
}
|
||||
@@ -157,6 +163,8 @@ WalletType deserializeFromInt(int raw) {
|
||||
return WalletType.base;
|
||||
case 16:
|
||||
return WalletType.arbitrum;
|
||||
case 17:
|
||||
return WalletType.zcash;
|
||||
default:
|
||||
throw Exception('Unexpected token: $raw for WalletType deserializeFromInt');
|
||||
}
|
||||
@@ -198,6 +206,8 @@ String walletTypeToString(WalletType type) {
|
||||
return 'Base';
|
||||
case WalletType.arbitrum:
|
||||
return 'Arbitrum';
|
||||
case WalletType.zcash:
|
||||
return 'Zcash';
|
||||
case WalletType.none:
|
||||
return '';
|
||||
}
|
||||
@@ -239,6 +249,8 @@ String walletTypeToDisplayName(WalletType type) {
|
||||
return 'Base (BASE)';
|
||||
case WalletType.arbitrum:
|
||||
return 'Arbitrum (ARB)';
|
||||
case WalletType.zcash:
|
||||
return 'Zcash (ZEC)';
|
||||
case WalletType.none:
|
||||
return '';
|
||||
}
|
||||
@@ -281,6 +293,8 @@ WalletType? cryptoCurrencyToWalletType(CryptoCurrency type) {
|
||||
return WalletType.decred;
|
||||
case CryptoCurrency.doge:
|
||||
return WalletType.dogecoin;
|
||||
case CryptoCurrency.zec:
|
||||
return WalletType.zcash;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user