update monero_c to fix unreachable wownero git hosting (#1534)
* update monero_c commit * fix: no element in getAllUnusedSubAddresses * fix: Wallet created with empty seed and 0 as private key The error that was there is caused when wallet is being created, but it errors out, so better handling of errors should be all that's needed, as it is not an error on it's own, but rather lack of handling. * fix: create transaction multi dest function is missing * update monero_c hash * fix: receiving on 2 different addresses shows as 1
cyan committed
Jul 19, 2024 at 21:26 UTC
c0cd68a823d4ccd8d416529e6f146854a446ebf6
8 files changed
+57
-54
cw_core/lib/transaction_info.dart
+1
@@ -3,6 +3,7 @@ import 'package:cw_core/keyable.dart';
3
4
abstract class TransactionInfo extends Object with Keyable {
5
late String id;
6
+ late String txhash = id;
7
late int amount;
8
int? fee;
9
late TransactionDirection direction;
cw_monero/lib/api/wallet_manager.dart
+17
-21
@@ -194,28 +194,24 @@ void loadWallet(
194
wptr = openedWalletsByPath[path]!;
195
return;
196
}
197
- try {
198
- if (wptr == null || path != _lastOpenedWallet) {
199
- if (wptr != null) {
200
- final addr = wptr!.address;
201
- Isolate.run(() {
202
- monero.Wallet_store(Pointer.fromAddress(addr));
203
- });
204
- }
205
- txhistory = null;
206
- wptr = monero.WalletManager_openWallet(wmPtr,
207
- path: path, password: password);
208
- openedWalletsByPath[path] = wptr!;
209
- _lastOpenedWallet = path;
197
+ if (wptr == null || path != _lastOpenedWallet) {
198
+ if (wptr != null) {
199
+ final addr = wptr!.address;
200
+ Isolate.run(() {
201
+ monero.Wallet_store(Pointer.fromAddress(addr));
202
+ });
203
}
211
- } catch (e) {
212
- print(e);
213
- }
214
- final status = monero.Wallet_status(wptr!);
215
- if (status != 0) {
216
- final err = monero.Wallet_errorString(wptr!);
217
- print(err);
218
- throw WalletOpeningException(message: err);
204
+ txhistory = null;
205
+ wptr = monero.WalletManager_openWallet(wmPtr,
206
+ path: path, password: password);
207
+ _lastOpenedWallet = path;
208
+ final status = monero.Wallet_status(wptr!);
209
+ if (status != 0) {
210
+ final err = monero.Wallet_errorString(wptr!);
211
+ print(err);
212
+ throw WalletOpeningException(message: err);
213
+ }
214
+ openedWalletsByPath[path] = wptr!;
215
}
216
}
217
cw_monero/lib/monero_subaddress_list.dart
+1
-1
@@ -124,7 +124,7 @@ abstract class MoneroSubaddressListBase with Store {
124
Future<List<Subaddress>> _getAllUnusedAddresses(
125
{required int accountIndex, required String label}) async {
126
final allAddresses = subaddress_list.getAllSubaddresses();
127
- final lastAddress = allAddresses.last.address;
127
+ final lastAddress = allAddresses.length == 0 ? allAddresses.last.address : Subaddress(id: -1, address: "", label: "");
128
if (allAddresses.isEmpty || _usedAddresses.contains(lastAddress)) {
129
final isAddressUnused = await _newSubaddress(accountIndex: accountIndex, label: label);
130
if (!isAddressUnused) {
cw_monero/lib/monero_transaction_info.dart
+10
-4
@@ -1,3 +1,5 @@
1
+import 'dart:math';
2
+
3
import 'package:cw_core/transaction_info.dart';
4
import 'package:cw_core/monero_amount_format.dart';
5
import 'package:cw_monero/api/structs/transaction_info_row.dart';
@@ -7,12 +9,14 @@ import 'package:cw_core/format_amount.dart';
9
import 'package:cw_monero/api/transaction_history.dart';
10
11
class MoneroTransactionInfo extends TransactionInfo {
10
- MoneroTransactionInfo(this.id, this.height, this.direction, this.date,
12
+ MoneroTransactionInfo(this.txhash, this.height, this.direction, this.date,
13
this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee,
12
- this.confirmations);
14
+ this.confirmations) :
15
+ id = "${txhash}_${amount}_${accountIndex}_${addressIndex}";
16
17
MoneroTransactionInfo.fromMap(Map<String, Object?> map)
15
- : id = (map['hash'] ?? '') as String,
18
+ : id = "${map['hash']}_${map['amount']}_${map['accountIndex']}_${map['addressIndex']}",
19
+ txhash = map['hash'] as String,
20
height = (map['height'] ?? 0) as int,
21
direction = map['direction'] != null
22
? parseTransactionDirectionFromNumber(map['direction'] as String)
@@ -34,7 +38,8 @@ class MoneroTransactionInfo extends TransactionInfo {
38
}
39
40
MoneroTransactionInfo.fromRow(TransactionInfoRow row)
37
- : id = row.getHash(),
41
+ : id = "${row.getHash()}_${row.getAmount()}_${row.subaddrAccount}_${row.subaddrIndex}",
42
+ txhash = row.getHash(),
43
height = row.blockHeight,
44
direction = parseTransactionDirectionFromInt(row.direction),
45
date = DateTime.fromMillisecondsSinceEpoch(row.getDatetime() * 1000),
@@ -53,6 +58,7 @@ class MoneroTransactionInfo extends TransactionInfo {
58
}
59
60
final String id;
61
+ final String txhash;
62
final int height;
63
final TransactionDirection direction;
64
final DateTime date;
cw_wownero/lib/api/wallet_manager.dart
+17
-21
@@ -208,28 +208,24 @@ void loadWallet(
208
wptr = openedWalletsByPath[path]!;
209
return;
210
}
211
- try {
212
- if (wptr == null || path != _lastOpenedWallet) {
213
- if (wptr != null) {
214
- final addr = wptr!.address;
215
- Isolate.run(() {
216
- wownero.Wallet_store(Pointer.fromAddress(addr));
217
- });
218
- }
219
- txhistory = null;
220
- wptr = wownero.WalletManager_openWallet(wmPtr,
221
- path: path, password: password);
222
- openedWalletsByPath[path] = wptr!;
223
- _lastOpenedWallet = path;
211
+ if (wptr == null || path != _lastOpenedWallet) {
212
+ if (wptr != null) {
213
+ final addr = wptr!.address;
214
+ Isolate.run(() {
215
+ wownero.Wallet_store(Pointer.fromAddress(addr));
216
+ });
217
}
225
- } catch (e) {
226
- print(e);
227
- }
228
- final status = wownero.Wallet_status(wptr!);
229
- if (status != 0) {
230
- final err = wownero.Wallet_errorString(wptr!);
231
- print(err);
232
- throw WalletOpeningException(message: err);
218
+ txhistory = null;
219
+ wptr = wownero.WalletManager_openWallet(wmPtr,
220
+ path: path, password: password);
221
+ _lastOpenedWallet = path;
222
+ final status = wownero.Wallet_status(wptr!);
223
+ if (status != 0) {
224
+ final err = wownero.Wallet_errorString(wptr!);
225
+ print(err);
226
+ throw WalletOpeningException(message: err);
227
+ }
228
+ openedWalletsByPath[path] = wptr!;
229
}
230
}
231
cw_wownero/lib/wownero_transaction_info.dart
+8
-4
@@ -7,12 +7,14 @@ import 'package:cw_core/format_amount.dart';
7
import 'package:cw_wownero/api/transaction_history.dart';
8
9
class WowneroTransactionInfo extends TransactionInfo {
10
- WowneroTransactionInfo(this.id, this.height, this.direction, this.date,
10
+ WowneroTransactionInfo(this.txhash, this.height, this.direction, this.date,
11
this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee,
12
- this.confirmations);
12
+ this.confirmations) :
13
+ id = "${txhash}_${amount}_${accountIndex}_${addressIndex}";
14
15
WowneroTransactionInfo.fromMap(Map<String, Object?> map)
15
- : id = (map['hash'] ?? '') as String,
16
+ : id = "${map['hash']}_${map['amount']}_${map['accountIndex']}_${map['addressIndex']}",
17
+ txhash = map['hash'] as String,
18
height = (map['height'] ?? 0) as int,
19
direction = map['direction'] != null
20
? parseTransactionDirectionFromNumber(map['direction'] as String)
@@ -34,7 +36,8 @@ class WowneroTransactionInfo extends TransactionInfo {
36
}
37
38
WowneroTransactionInfo.fromRow(TransactionInfoRow row)
37
- : id = row.getHash(),
39
+ : id = "${row.getHash()}_${row.getAmount()}_${row.subaddrAccount}_${row.subaddrIndex}",
40
+ txhash = row.getHash(),
41
height = row.blockHeight,
42
direction = parseTransactionDirectionFromInt(row.direction),
43
date = DateTime.fromMillisecondsSinceEpoch(row.getDatetime() * 1000),
@@ -53,6 +56,7 @@ class WowneroTransactionInfo extends TransactionInfo {
56
}
57
58
final String id;
59
+ final String txhash;
60
final int height;
61
final TransactionDirection direction;
62
final DateTime date;
lib/view_model/transaction_details_view_model.dart
+2
-2
@@ -214,7 +214,7 @@ abstract class TransactionDetailsViewModelBase with Store {
214
final addressIndex = tx.additionalInfo['addressIndex'] as int;
215
final feeFormatted = tx.feeFormatted();
216
final _items = [
217
- StandartListItem(title: S.current.transaction_details_transaction_id, value: tx.id),
217
+ StandartListItem(title: S.current.transaction_details_transaction_id, value: tx.txhash),
218
StandartListItem(
219
title: S.current.transaction_details_date, value: dateFormat.format(tx.date)),
220
StandartListItem(title: S.current.transaction_details_height, value: '${tx.height}'),
@@ -455,7 +455,7 @@ abstract class TransactionDetailsViewModelBase with Store {
455
final addressIndex = tx.additionalInfo['addressIndex'] as int;
456
final feeFormatted = tx.feeFormatted();
457
final _items = [
458
- StandartListItem(title: S.current.transaction_details_transaction_id, value: tx.id),
458
+ StandartListItem(title: S.current.transaction_details_transaction_id, value: tx.txhash),
459
StandartListItem(
460
title: S.current.transaction_details_date, value: dateFormat.format(tx.date)),
461
StandartListItem(title: S.current.transaction_details_height, value: '${tx.height}'),
scripts/prepare_moneroc.sh
+1
-1
@@ -8,7 +8,7 @@ if [[ ! -d "monero_c" ]];
8
then
9
git clone https://github.com/mrcyjanek/monero_c --branch rewrite-wip
10
cd monero_c
11
- git checkout eaa7bdb8be3479418445ddb18bf33d453f64afcf
11
+ git checkout d1e246aaf4c53b60ff9e4ab4a4ac3ae4a1f94a33
12
git reset --hard
13
git submodule update --init --force --recursive
14
./apply_patches.sh monero