mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-12-03 12:24:19 +01:00
Fixes for LTC and added banner for old bitcoin electrum wallets.
This commit is contained in:
@@ -26,6 +26,8 @@ class BitcoinTransactionPriority extends TransactionPriority {
|
||||
}
|
||||
}
|
||||
|
||||
String get units => 'sat';
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
var label = '';
|
||||
@@ -46,4 +48,56 @@ class BitcoinTransactionPriority extends TransactionPriority {
|
||||
|
||||
return label;
|
||||
}
|
||||
|
||||
String labelWithRate(int rate) => '${toString()} ($rate ${units}/byte)';
|
||||
}
|
||||
|
||||
class LitecoinTransactionPriority extends BitcoinTransactionPriority {
|
||||
const LitecoinTransactionPriority({String title, int raw})
|
||||
: super(title: title, raw: raw);
|
||||
|
||||
static const List<LitecoinTransactionPriority> all = [fast, medium, slow];
|
||||
static const LitecoinTransactionPriority slow =
|
||||
LitecoinTransactionPriority(title: 'Slow', raw: 0);
|
||||
static const LitecoinTransactionPriority medium =
|
||||
LitecoinTransactionPriority(title: 'Medium', raw: 1);
|
||||
static const LitecoinTransactionPriority fast =
|
||||
LitecoinTransactionPriority(title: 'Fast', raw: 2);
|
||||
|
||||
static LitecoinTransactionPriority deserialize({int raw}) {
|
||||
switch (raw) {
|
||||
case 0:
|
||||
return slow;
|
||||
case 1:
|
||||
return medium;
|
||||
case 2:
|
||||
return fast;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
String get units => 'Latoshi';
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
var label = '';
|
||||
|
||||
switch (this) {
|
||||
case LitecoinTransactionPriority.slow:
|
||||
label = S.current.transaction_priority_slow;
|
||||
break;
|
||||
case LitecoinTransactionPriority.medium:
|
||||
label = S.current.transaction_priority_medium;
|
||||
break;
|
||||
case LitecoinTransactionPriority.fast:
|
||||
label = S.current.transaction_priority_fast;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return label;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,13 +72,13 @@ abstract class LitecoinWalletBase extends ElectrumWallet with Store {
|
||||
|
||||
@override
|
||||
int feeRate(TransactionPriority priority) {
|
||||
if (priority is BitcoinTransactionPriority) {
|
||||
if (priority is LitecoinTransactionPriority) {
|
||||
switch (priority) {
|
||||
case BitcoinTransactionPriority.slow:
|
||||
case LitecoinTransactionPriority.slow:
|
||||
return 1;
|
||||
case BitcoinTransactionPriority.medium:
|
||||
case LitecoinTransactionPriority.medium:
|
||||
return 2;
|
||||
case BitcoinTransactionPriority.fast:
|
||||
case LitecoinTransactionPriority.fast:
|
||||
return 3;
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -74,7 +74,7 @@ Future<void> main() async {
|
||||
if (!Hive.isAdapterRegistered(Order.typeId)) {
|
||||
Hive.registerAdapter(OrderAdapter());
|
||||
}
|
||||
|
||||
|
||||
final secureStorage = FlutterSecureStorage();
|
||||
final transactionDescriptionsBoxKey = await getEncryptionKey(
|
||||
secureStorage: secureStorage, forKey: TransactionDescription.boxKey);
|
||||
|
||||
@@ -16,6 +16,7 @@ import 'package:cake_wallet/src/screens/dashboard/widgets/transactions_page.dart
|
||||
import 'package:cake_wallet/src/screens/dashboard/widgets/sync_indicator.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_view_model.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:smooth_page_indicator/smooth_page_indicator.dart';
|
||||
import 'package:flutter_spinkit/flutter_spinkit.dart';
|
||||
|
||||
@@ -26,8 +27,8 @@ class DashboardPage extends BasePage {
|
||||
});
|
||||
|
||||
@override
|
||||
Color get backgroundLightColor => currentTheme.type == ThemeType.bright
|
||||
? Colors.transparent : Colors.white;
|
||||
Color get backgroundLightColor =>
|
||||
currentTheme.type == ThemeType.bright ? Colors.transparent : Colors.white;
|
||||
|
||||
@override
|
||||
Color get backgroundDarkColor => Colors.transparent;
|
||||
@@ -56,9 +57,8 @@ class DashboardPage extends BasePage {
|
||||
|
||||
@override
|
||||
Widget trailing(BuildContext context) {
|
||||
final menuButton =
|
||||
Image.asset('assets/images/menu.png',
|
||||
color: Theme.of(context).accentTextTheme.display3.backgroundColor);
|
||||
final menuButton = Image.asset('assets/images/menu.png',
|
||||
color: Theme.of(context).accentTextTheme.display3.backgroundColor);
|
||||
|
||||
return Container(
|
||||
alignment: Alignment.centerRight,
|
||||
@@ -81,15 +81,18 @@ class DashboardPage extends BasePage {
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
final sendImage = Image.asset('assets/images/upload.png',
|
||||
height: 22.24, width: 24,
|
||||
height: 22.24,
|
||||
width: 24,
|
||||
color: Theme.of(context).accentTextTheme.display3.backgroundColor);
|
||||
final exchangeImage = Image.asset('assets/images/transfer.png',
|
||||
height: 24.27, width: 22.25,
|
||||
height: 24.27,
|
||||
width: 22.25,
|
||||
color: Theme.of(context).accentTextTheme.display3.backgroundColor);
|
||||
final buyImage = Image.asset('assets/images/coins.png',
|
||||
height: 22.24, width: 24,
|
||||
height: 22.24,
|
||||
width: 24,
|
||||
color: Theme.of(context).accentTextTheme.display3.backgroundColor);
|
||||
_setEffects();
|
||||
_setEffects(context);
|
||||
|
||||
return SafeArea(
|
||||
child: Column(
|
||||
@@ -111,7 +114,9 @@ class DashboardPage extends BasePage {
|
||||
dotWidth: 6.0,
|
||||
dotHeight: 6.0,
|
||||
dotColor: Theme.of(context).indicatorColor,
|
||||
activeDotColor: Theme.of(context).accentTextTheme.display1
|
||||
activeDotColor: Theme.of(context)
|
||||
.accentTextTheme
|
||||
.display1
|
||||
.backgroundColor),
|
||||
)),
|
||||
Container(
|
||||
@@ -129,25 +134,27 @@ class DashboardPage extends BasePage {
|
||||
route: Routes.exchange),
|
||||
Observer(
|
||||
builder: (_) => Stack(
|
||||
clipBehavior: Clip.none,
|
||||
alignment: Alignment.topCenter,
|
||||
children: [
|
||||
if (walletViewModel.isRunningWebView) Positioned(
|
||||
top: -5,
|
||||
child: SpinKitRing(
|
||||
color: Theme.of(context).buttonColor,
|
||||
lineWidth: 3,
|
||||
size: 70.0,
|
||||
),
|
||||
),
|
||||
ActionButton(
|
||||
image: buyImage,
|
||||
title: S.of(context).buy,
|
||||
onClick: walletViewModel.isRunningWebView
|
||||
? null
|
||||
: () async => await _onClickBuyButton(context))
|
||||
],
|
||||
)),
|
||||
clipBehavior: Clip.none,
|
||||
alignment: Alignment.topCenter,
|
||||
children: [
|
||||
if (walletViewModel.isRunningWebView)
|
||||
Positioned(
|
||||
top: -5,
|
||||
child: SpinKitRing(
|
||||
color: Theme.of(context).buttonColor,
|
||||
lineWidth: 3,
|
||||
size: 70.0,
|
||||
),
|
||||
),
|
||||
ActionButton(
|
||||
image: buyImage,
|
||||
title: S.of(context).buy,
|
||||
onClick: walletViewModel.isRunningWebView
|
||||
? null
|
||||
: () async =>
|
||||
await _onClickBuyButton(context))
|
||||
],
|
||||
)),
|
||||
],
|
||||
),
|
||||
)
|
||||
@@ -155,7 +162,7 @@ class DashboardPage extends BasePage {
|
||||
));
|
||||
}
|
||||
|
||||
void _setEffects() {
|
||||
void _setEffects(BuildContext context) {
|
||||
if (_isEffectsInstalled) {
|
||||
return;
|
||||
}
|
||||
@@ -164,14 +171,42 @@ class DashboardPage extends BasePage {
|
||||
pages.add(BalancePage(dashboardViewModel: walletViewModel));
|
||||
pages.add(TransactionsPage(dashboardViewModel: walletViewModel));
|
||||
|
||||
autorun((_) async {
|
||||
if (!walletViewModel.isOutdatedElectrumWallet) {
|
||||
return;
|
||||
}
|
||||
|
||||
await Future<void>.delayed(Duration(seconds: 1));
|
||||
await showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: S.of(context).pre_seed_title,
|
||||
alertContent:
|
||||
S.of(context).outdated_electrum_wallet_desceription,
|
||||
buttonText: S.of(context).understand,
|
||||
buttonAction: () => Navigator.of(context).pop());
|
||||
});
|
||||
});
|
||||
|
||||
_isEffectsInstalled = true;
|
||||
}
|
||||
|
||||
Future <void> _onClickBuyButton(BuildContext context) async {
|
||||
Future<void> _onClickBuyButton(BuildContext context) async {
|
||||
final walletType = walletViewModel.type;
|
||||
|
||||
switch (walletType) {
|
||||
case WalletType.monero:
|
||||
case WalletType.bitcoin:
|
||||
try {
|
||||
walletViewModel.isRunningWebView = true;
|
||||
final url = await walletViewModel.wyreViewModel.wyreUrl;
|
||||
await Navigator.of(context).pushNamed(Routes.wyre, arguments: url);
|
||||
walletViewModel.isRunningWebView = false;
|
||||
} catch (_) {
|
||||
walletViewModel.isRunningWebView = false;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
await showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
@@ -182,16 +217,6 @@ class DashboardPage extends BasePage {
|
||||
buttonAction: () => Navigator.of(context).pop());
|
||||
});
|
||||
break;
|
||||
default:
|
||||
try {
|
||||
walletViewModel.isRunningWebView = true;
|
||||
final url = await walletViewModel.wyreViewModel.wyreUrl;
|
||||
await Navigator.of(context).pushNamed(Routes.wyre, arguments: url);
|
||||
walletViewModel.isRunningWebView = false;
|
||||
} catch(_) {
|
||||
walletViewModel.isRunningWebView = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -234,6 +234,10 @@ abstract class DashboardViewModelBase with Store {
|
||||
await wallet.connectToNode(node: node);
|
||||
}
|
||||
|
||||
@computed
|
||||
bool get isOutdatedElectrumWallet =>
|
||||
wallet.type == WalletType.bitcoin && wallet.seed.split(' ').length < 24;
|
||||
|
||||
@action
|
||||
void _onWalletChange(
|
||||
WalletBase<Balance, TransactionHistoryBase<TransactionInfo>,
|
||||
|
||||
@@ -372,7 +372,7 @@ abstract class SendViewModelBase with Store {
|
||||
|
||||
if (wallet is ElectrumWallet) {
|
||||
final rate = wallet.feeRate(_priority);
|
||||
return '${priority.toString()} ($rate sat/byte)';
|
||||
return '${priority.labelWithRate(rate)}';
|
||||
}
|
||||
|
||||
return priority.toString();
|
||||
|
||||
@@ -39,7 +39,7 @@ List<TransactionPriority> priorityForWalletType(WalletType type) {
|
||||
case WalletType.bitcoin:
|
||||
return BitcoinTransactionPriority.all;
|
||||
case WalletType.litecoin:
|
||||
return BitcoinTransactionPriority.all;
|
||||
return LitecoinTransactionPriority.all;
|
||||
default:
|
||||
return [];
|
||||
}
|
||||
@@ -87,7 +87,7 @@ abstract class SettingsViewModelBase with Store {
|
||||
|
||||
if (wallet is ElectrumWallet) {
|
||||
final rate = wallet.feeRate(_priority);
|
||||
return '${priority.toString()} ($rate sat/byte)';
|
||||
return '${priority.labelWithRate(rate)}';
|
||||
}
|
||||
|
||||
return priority.toString();
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
import 'package:cake_wallet/core/transaction_history.dart';
|
||||
import 'package:cake_wallet/entities/balance.dart';
|
||||
import 'package:cake_wallet/entities/transaction_info.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/bitcoin/bitcoin_wallet.dart';
|
||||
@@ -12,6 +8,11 @@ import 'package:cake_wallet/view_model/wallet_address_list/wallet_account_list_h
|
||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_header.dart';
|
||||
import 'package:cake_wallet/view_model/wallet_address_list/wallet_address_list_item.dart';
|
||||
import 'package:cake_wallet/entities/wallet_type.dart';
|
||||
import 'package:cake_wallet/bitcoin/electrum_wallet.dart';
|
||||
import 'package:cake_wallet/core/transaction_history.dart';
|
||||
import 'package:cake_wallet/entities/balance.dart';
|
||||
import 'package:cake_wallet/entities/transaction_info.dart';
|
||||
import 'package:cake_wallet/store/app_store.dart';
|
||||
|
||||
part 'wallet_address_list_view_model.g.dart';
|
||||
|
||||
@@ -175,7 +176,7 @@ abstract class WalletAddressListViewModelBase with Store {
|
||||
void nextAddress() {
|
||||
final wallet = _wallet;
|
||||
|
||||
if (wallet is BitcoinWallet) {
|
||||
if (wallet is ElectrumWallet) {
|
||||
wallet.nextAddress();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user