mirror of
https://github.com/Such-Software/hash-wallet.git
synced 2026-10-19 05:58:50 +02:00
Mweb enhancements 4 (#1768)
* [skip-ci] show mweb confirmations, show last mweb balance while syncing * potential send-all fix * [skip-ci] undo fix that didn't work * [skip-ci] undo unnecessary changes * [skip ci] add export mweb logs screen * [skip ci] cleanup * confirmation fixes * catch electrum call errors * [skip ci] undo some changes * potential electrum fixes + mweb logs display only last 10000 characters * Add question mark and link to MWEB card * updates * show negative unconfirmed mweb balanaces + other fixes [skip ci] * error handling * [skip ci] [wip] check if node supports mweb * check fee before building tx * [skip ci] minor * [skip ci] minor * mweb node setting [wip] [skip ci] * prioritize mweb coins when selecting inputs from the pool * potential connection edgecase fix * translations + mweb node fixes * don't use mweb for exchange refund address * add peg in / out labels and make 6 confs only show up for peg in / out * bump bitcoin_base version to v9 * [skip ci] fix logs page * don't fetch txinfo for non-mweb addresses [skip ci] * fix non-mweb confirmations * rename always scan to enable mweb * Update litecoin_wallet_addresses.dart Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * Update cw_mweb.dart Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com> * [skip ci] review updates pt.1 * [skip ci] minor code cleanup * [skip ci] use exception handler * exception handling [skip ci] * [skip ci] exception handling * trigger build * pegout label fixes * fix showing change transactions on peg-out * minor code cleanup and minor peg-out fix * final balance fixes * non-mweb confirmations potential fix * [skip ci] wip * trigger build --------- Co-authored-by: tuxpizza <tuxsudo@tux.pizza> Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
co-authored by
Omar Hatem
tuxpizza
parent
109d9b458e
commit
c8cfc2cff1
@@ -381,7 +381,7 @@ abstract class BalanceViewModelBase with Store {
|
||||
|
||||
bool _hasSecondAdditionalBalanceForWalletType(WalletType type) {
|
||||
if (wallet.type == WalletType.litecoin) {
|
||||
if ((wallet.balance[CryptoCurrency.ltc]?.secondAdditional ?? 0) > 0) {
|
||||
if ((wallet.balance[CryptoCurrency.ltc]?.secondAdditional ?? 0) != 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -56,25 +56,53 @@ class TransactionListItem extends ActionListItem with Keyable {
|
||||
}
|
||||
|
||||
String get formattedPendingStatus {
|
||||
if (balanceViewModel.wallet.type == WalletType.monero ||
|
||||
balanceViewModel.wallet.type == WalletType.haven) {
|
||||
if (transaction.confirmations >= 0 && transaction.confirmations < 10) {
|
||||
return ' (${transaction.confirmations}/10)';
|
||||
}
|
||||
} else if (balanceViewModel.wallet.type == WalletType.wownero) {
|
||||
if (transaction.confirmations >= 0 && transaction.confirmations < 3) {
|
||||
return ' (${transaction.confirmations}/3)';
|
||||
}
|
||||
switch (balanceViewModel.wallet.type) {
|
||||
case WalletType.monero:
|
||||
case WalletType.haven:
|
||||
if (transaction.confirmations >= 0 && transaction.confirmations < 10) {
|
||||
return ' (${transaction.confirmations}/10)';
|
||||
}
|
||||
break;
|
||||
case WalletType.wownero:
|
||||
if (transaction.confirmations >= 0 && transaction.confirmations < 3) {
|
||||
return ' (${transaction.confirmations}/3)';
|
||||
}
|
||||
break;
|
||||
case WalletType.litecoin:
|
||||
bool isPegIn = (transaction.additionalInfo["isPegIn"] as bool?) ?? false;
|
||||
bool isPegOut = (transaction.additionalInfo["isPegOut"] as bool?) ?? false;
|
||||
bool fromPegOut = (transaction.additionalInfo["fromPegOut"] as bool?) ?? false;
|
||||
String str = '';
|
||||
if (transaction.confirmations <= 0) {
|
||||
str = S.current.pending;
|
||||
}
|
||||
if ((isPegOut || fromPegOut) && transaction.confirmations >= 0 && transaction.confirmations < 6) {
|
||||
str = " (${transaction.confirmations}/6)";
|
||||
}
|
||||
if (isPegIn) {
|
||||
str += " (Peg In)";
|
||||
}
|
||||
if (isPegOut) {
|
||||
str += " (Peg Out)";
|
||||
}
|
||||
return str;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
String get formattedStatus {
|
||||
if (balanceViewModel.wallet.type == WalletType.monero ||
|
||||
balanceViewModel.wallet.type == WalletType.wownero ||
|
||||
balanceViewModel.wallet.type == WalletType.haven) {
|
||||
if ([
|
||||
WalletType.monero,
|
||||
WalletType.haven,
|
||||
WalletType.wownero,
|
||||
WalletType.litecoin,
|
||||
].contains(balanceViewModel.wallet.type)) {
|
||||
return formattedPendingStatus;
|
||||
}
|
||||
|
||||
return transaction.isPending ? S.current.pending : '';
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,12 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/store/settings_store.dart';
|
||||
import 'package:cake_wallet/utils/exception_handler.dart';
|
||||
import 'package:cw_core/wallet_base.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
|
||||
part 'mweb_settings_view_model.g.dart';
|
||||
|
||||
@@ -22,15 +27,60 @@ abstract class MwebSettingsViewModelBase with Store {
|
||||
@observable
|
||||
late bool mwebEnabled;
|
||||
|
||||
@computed
|
||||
String get mwebNodeUri => _settingsStore.mwebNodeUri;
|
||||
|
||||
@action
|
||||
void setMwebCardDisplay(bool value) {
|
||||
_settingsStore.mwebCardDisplay = value;
|
||||
}
|
||||
|
||||
@action
|
||||
void setMwebNodeUri(String value) {
|
||||
_settingsStore.mwebNodeUri = value;
|
||||
}
|
||||
|
||||
@action
|
||||
void setMwebEnabled(bool value) {
|
||||
mwebEnabled = value;
|
||||
bitcoin!.setMwebEnabled(_wallet, value);
|
||||
_settingsStore.mwebAlwaysScan = value;
|
||||
}
|
||||
|
||||
Future<bool> saveLogsLocally(String filePath) async {
|
||||
try {
|
||||
final appSupportPath = (await getApplicationSupportDirectory()).path;
|
||||
final logsFile = File("$appSupportPath/logs/debug.log");
|
||||
if (!logsFile.existsSync()) {
|
||||
throw Exception('Logs file does not exist');
|
||||
}
|
||||
await logsFile.copy(filePath);
|
||||
return true;
|
||||
} catch (e, s) {
|
||||
ExceptionHandler.onError(FlutterErrorDetails(
|
||||
exception: e,
|
||||
stack: s,
|
||||
library: "Export Logs",
|
||||
));
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Future<String> getAbbreviatedLogs() async {
|
||||
final appSupportPath = (await getApplicationSupportDirectory()).path;
|
||||
final logsFile = File("$appSupportPath/logs/debug.log");
|
||||
if (!logsFile.existsSync()) {
|
||||
return "";
|
||||
}
|
||||
final logs = logsFile.readAsStringSync();
|
||||
// return last 10000 characters:
|
||||
return logs.substring(logs.length > 10000 ? logs.length - 10000 : 0);
|
||||
}
|
||||
|
||||
Future<void> removeLogsLocally(String filePath) async {
|
||||
final logsFile = File(filePath);
|
||||
if (logsFile.existsSync()) {
|
||||
await logsFile.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user