Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion lib/db/hive/db.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
import 'dart:isolate';

import 'package:compat/compat.dart' as lib_monero_compat;
import 'package:hive_ce/src/hive_impl.dart';
import 'package:hive_ce/hive.dart' show Box;
import 'package:hive_ce/src/hive_impl.dart';
import 'package:mutex/mutex.dart';

import '../../app_config.dart';
import '../../models/epicbox_server_model.dart';
import '../../models/exchange/response_objects/trade.dart';
import '../../models/node_model.dart';
import '../../models/notification_model.dart';
Expand Down Expand Up @@ -52,6 +53,8 @@ class DB {
static const String boxNameDBInfo = "dbInfo";
static const String boxNamePrefs = "prefs";
static const String boxNameOneTimeDialogsShown = "oneTimeDialogsShown";
static const String boxNameEpicBoxModels = "epicBoxModels";
static const String boxNamePrimaryEpicBox = "primaryEpicBox";

String _boxNameTxCache({required CryptoCurrency currency}) =>
"${currency.identifier}_txCache";
Expand All @@ -75,6 +78,8 @@ class DB {
Box<dynamic>? _boxPrefs;
Box<TradeWalletLookup>? _boxTradeLookup;
Box<dynamic>? _boxDBInfo;
late final Box<EpicBoxServerModel> _boxEpicBoxModels;
late final Box<EpicBoxServerModel> _boxPrimaryEpicBoxes;
// Box<String>? _boxDesktopData;

final Map<String, Box<dynamic>> _walletBoxes = {};
Expand Down Expand Up @@ -115,6 +120,24 @@ class DB {
}
await hive.openBox<String>(boxNameWalletsToDeleteOnStart);

if (hive.isBoxOpen(boxNameEpicBoxModels)) {
_boxEpicBoxModels = hive.box<EpicBoxServerModel>(boxNameEpicBoxModels);
} else {
_boxEpicBoxModels = await hive.openBox<EpicBoxServerModel>(
boxNameEpicBoxModels,
);
}

if (hive.isBoxOpen(boxNamePrimaryEpicBox)) {
_boxPrimaryEpicBoxes = hive.box<EpicBoxServerModel>(
boxNamePrimaryEpicBox,
);
} else {
_boxPrimaryEpicBoxes = await hive.openBox<EpicBoxServerModel>(
boxNamePrimaryEpicBox,
);
}

if (hive.isBoxOpen(boxNamePrefs)) {
_boxPrefs = hive.box<dynamic>(boxNamePrefs);
} else {
Expand Down
5 changes: 5 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import 'db/hive/db.dart';
import 'db/isar/main_db.dart';
import 'db/special_migrations.dart';
import 'db/sqlite/firo_cache.dart';
import 'models/epicbox_server_model.dart';
import 'models/exchange/change_now/exchange_transaction.dart';
import 'models/exchange/change_now/exchange_transaction_status.dart';
import 'models/exchange/response_objects/trade.dart';
Expand Down Expand Up @@ -155,6 +156,9 @@ void main(List<String> args) async {
// node model adapter
DB.instance.hive.registerAdapter(NodeModelAdapter());

// epicbox server model adapter
DB.instance.hive.registerAdapter(EpicBoxServerModelAdapter());

if (!DB.instance.hive.isAdapterRegistered(
lib_monero_compat.WalletInfoAdapter().typeId,
)) {
Expand Down Expand Up @@ -390,6 +394,7 @@ class _MaterialAppWithThemeState extends ConsumerState<MaterialAppWithTheme>
unawaited(ref.read(baseCurrenciesProvider).update());

await _nodeService.updateDefaults();
await _nodeService.updateDefaultEpicBoxes();
await _notificationsService.init(
nodeService: _nodeService,
tradesService: _tradesService,
Expand Down
46 changes: 8 additions & 38 deletions lib/models/isar/models/blockchain_data/v2/transaction_v2.dart
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,8 @@ class TransactionV2 {
if (isConfirmed(currentChainHeight, minConfirms, minCoinbaseConfirms)) {
return "Received";
} else {
if (numberOfMessages == 1) {
if ((onChainNote == null && numberOfMessages == 1) |
(onChainNote != null && numberOfMessages == 2)) {
return "Receiving (waiting for sender)";
} else if ((numberOfMessages ?? 0) > 1) {
return "Receiving (waiting for confirmations)"; // TODO test if the sender still has to open again after the receiver has 2 messages present, ie. sender->receiver->sender->node (yes) vs. sender->receiver->node (no)
Expand All @@ -289,7 +290,8 @@ class TransactionV2 {
if (isConfirmed(currentChainHeight, minConfirms, minCoinbaseConfirms)) {
return "Sent (confirmed)";
} else {
if (numberOfMessages == 1) {
if ((onChainNote == null && numberOfMessages == 1) |
(onChainNote != null && numberOfMessages == 2)) {
return "Sending (waiting for receiver)";
} else if ((numberOfMessages ?? 0) > 1) {
return "Sending (waiting for confirmations)";
Expand All @@ -311,7 +313,8 @@ class TransactionV2 {
if (isConfirmed(currentChainHeight, minConfirms, minCoinbaseConfirms)) {
return "Received";
} else {
if (numberOfMessages == 1) {
if ((onChainNote == null && numberOfMessages == 1) |
(onChainNote != null && numberOfMessages == 2)) {
return "Receiving (waiting for sender)";
} else if ((numberOfMessages ?? 0) > 1) {
return "Receiving (waiting for confirmations)"; // TODO test if the sender still has to open again after the receiver has 2 messages present, ie. sender->receiver->sender->node (yes) vs. sender->receiver->node (no)
Expand All @@ -323,41 +326,8 @@ class TransactionV2 {
if (isConfirmed(currentChainHeight, minConfirms, minCoinbaseConfirms)) {
return "Sent (confirmed)";
} else {
if (numberOfMessages == 1) {
return "Sending (waiting for receiver)";
} else if ((numberOfMessages ?? 0) > 1) {
return "Sending (waiting for confirmations)";
} else {
return "Sending ${prettyConfirms()}";
}
}
}
}

if (isMimblewimblecoinTransaction) {
if (slateId == null) {
return "Restored Funds";
}

if (isCancelled) {
return "Cancelled";
} else if (type == TransactionType.incoming) {
if (isConfirmed(currentChainHeight, minConfirms, minCoinbaseConfirms)) {
return "Received";
} else {
if (numberOfMessages == 1) {
return "Receiving (waiting for sender)";
} else if ((numberOfMessages ?? 0) > 1) {
return "Receiving (waiting for confirmations)"; // TODO test if the sender still has to open again after the receiver has 2 messages present, ie. sender->receiver->sender->node (yes) vs. sender->receiver->node (no)
} else {
return "Receiving ${prettyConfirms()}";
}
}
} else if (type == TransactionType.outgoing) {
if (isConfirmed(currentChainHeight, minConfirms, minCoinbaseConfirms)) {
return "Sent (confirmed)";
} else {
if (numberOfMessages == 1) {
if ((onChainNote == null && numberOfMessages == 1) |
(onChainNote != null && numberOfMessages == 2)) {
return "Sending (waiting for receiver)";
} else if ((numberOfMessages ?? 0) > 1) {
return "Sending (waiting for confirmations)";
Expand Down
4 changes: 4 additions & 0 deletions lib/networking/http.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,12 @@ class HTTP {
required Uri url,
Map<String, String>? headers,
required ({InternetAddress host, int port})? proxyInfo,
Duration? connectionTimeout,
}) async {
final httpClient = HttpClient();
if (connectionTimeout != null) {
httpClient.connectionTimeout = connectionTimeout;
}
try {
if (proxyInfo != null) {
SocksTCPClient.assignToHttpClient(httpClient, [
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/send_view/confirm_transaction_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1181,7 +1181,7 @@ class _ConfirmTransactionViewState
children: [
if (coin is Epiccash || coin is Mimblewimblecoin)
Text(
"On chain Note (optional)",
"On chain Note",
style: STextStyles.smallMed12(context),
textAlign: TextAlign.left,
),
Expand Down
2 changes: 1 addition & 1 deletion lib/pages/send_view/send_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2353,7 +2353,7 @@ class _SendViewState extends ConsumerState<SendView> {
const SizedBox(height: 12),
if (coin is Epiccash)
Text(
"On chain Note (optional)",
"On chain Note",
style: STextStyles.smallMed12(context),
textAlign: TextAlign.left,
),
Expand Down
Loading
Loading