update monero_c to fix unreachable wownero git hosting (#1534)
Some checks are pending
Cache Dependencies / test (push) Waiting to run

* 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
This commit is contained in:
cyan 2024-07-19 21:26:15 +02:00 committed by GitHub
parent d6c5b84188
commit c0cd68a823
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 57 additions and 54 deletions

View file

@ -3,6 +3,7 @@ import 'package:cw_core/keyable.dart';
abstract class TransactionInfo extends Object with Keyable { abstract class TransactionInfo extends Object with Keyable {
late String id; late String id;
late String txhash = id;
late int amount; late int amount;
int? fee; int? fee;
late TransactionDirection direction; late TransactionDirection direction;

View file

@ -194,28 +194,24 @@ void loadWallet(
wptr = openedWalletsByPath[path]!; wptr = openedWalletsByPath[path]!;
return; return;
} }
try { if (wptr == null || path != _lastOpenedWallet) {
if (wptr == null || path != _lastOpenedWallet) { if (wptr != null) {
if (wptr != null) { final addr = wptr!.address;
final addr = wptr!.address; Isolate.run(() {
Isolate.run(() { monero.Wallet_store(Pointer.fromAddress(addr));
monero.Wallet_store(Pointer.fromAddress(addr)); });
});
}
txhistory = null;
wptr = monero.WalletManager_openWallet(wmPtr,
path: path, password: password);
openedWalletsByPath[path] = wptr!;
_lastOpenedWallet = path;
} }
} catch (e) { txhistory = null;
print(e); wptr = monero.WalletManager_openWallet(wmPtr,
} path: path, password: password);
final status = monero.Wallet_status(wptr!); _lastOpenedWallet = path;
if (status != 0) { final status = monero.Wallet_status(wptr!);
final err = monero.Wallet_errorString(wptr!); if (status != 0) {
print(err); final err = monero.Wallet_errorString(wptr!);
throw WalletOpeningException(message: err); print(err);
throw WalletOpeningException(message: err);
}
openedWalletsByPath[path] = wptr!;
} }
} }

View file

@ -124,7 +124,7 @@ abstract class MoneroSubaddressListBase with Store {
Future<List<Subaddress>> _getAllUnusedAddresses( Future<List<Subaddress>> _getAllUnusedAddresses(
{required int accountIndex, required String label}) async { {required int accountIndex, required String label}) async {
final allAddresses = subaddress_list.getAllSubaddresses(); final allAddresses = subaddress_list.getAllSubaddresses();
final lastAddress = allAddresses.last.address; final lastAddress = allAddresses.length == 0 ? allAddresses.last.address : Subaddress(id: -1, address: "", label: "");
if (allAddresses.isEmpty || _usedAddresses.contains(lastAddress)) { if (allAddresses.isEmpty || _usedAddresses.contains(lastAddress)) {
final isAddressUnused = await _newSubaddress(accountIndex: accountIndex, label: label); final isAddressUnused = await _newSubaddress(accountIndex: accountIndex, label: label);
if (!isAddressUnused) { if (!isAddressUnused) {

View file

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:cw_core/transaction_info.dart'; import 'package:cw_core/transaction_info.dart';
import 'package:cw_core/monero_amount_format.dart'; import 'package:cw_core/monero_amount_format.dart';
import 'package:cw_monero/api/structs/transaction_info_row.dart'; import 'package:cw_monero/api/structs/transaction_info_row.dart';
@ -7,12 +9,14 @@ import 'package:cw_core/format_amount.dart';
import 'package:cw_monero/api/transaction_history.dart'; import 'package:cw_monero/api/transaction_history.dart';
class MoneroTransactionInfo extends TransactionInfo { class MoneroTransactionInfo extends TransactionInfo {
MoneroTransactionInfo(this.id, this.height, this.direction, this.date, MoneroTransactionInfo(this.txhash, this.height, this.direction, this.date,
this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee, this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee,
this.confirmations); this.confirmations) :
id = "${txhash}_${amount}_${accountIndex}_${addressIndex}";
MoneroTransactionInfo.fromMap(Map<String, Object?> map) MoneroTransactionInfo.fromMap(Map<String, Object?> map)
: id = (map['hash'] ?? '') as String, : id = "${map['hash']}_${map['amount']}_${map['accountIndex']}_${map['addressIndex']}",
txhash = map['hash'] as String,
height = (map['height'] ?? 0) as int, height = (map['height'] ?? 0) as int,
direction = map['direction'] != null direction = map['direction'] != null
? parseTransactionDirectionFromNumber(map['direction'] as String) ? parseTransactionDirectionFromNumber(map['direction'] as String)
@ -34,7 +38,8 @@ class MoneroTransactionInfo extends TransactionInfo {
} }
MoneroTransactionInfo.fromRow(TransactionInfoRow row) MoneroTransactionInfo.fromRow(TransactionInfoRow row)
: id = row.getHash(), : id = "${row.getHash()}_${row.getAmount()}_${row.subaddrAccount}_${row.subaddrIndex}",
txhash = row.getHash(),
height = row.blockHeight, height = row.blockHeight,
direction = parseTransactionDirectionFromInt(row.direction), direction = parseTransactionDirectionFromInt(row.direction),
date = DateTime.fromMillisecondsSinceEpoch(row.getDatetime() * 1000), date = DateTime.fromMillisecondsSinceEpoch(row.getDatetime() * 1000),
@ -53,6 +58,7 @@ class MoneroTransactionInfo extends TransactionInfo {
} }
final String id; final String id;
final String txhash;
final int height; final int height;
final TransactionDirection direction; final TransactionDirection direction;
final DateTime date; final DateTime date;

View file

@ -208,28 +208,24 @@ void loadWallet(
wptr = openedWalletsByPath[path]!; wptr = openedWalletsByPath[path]!;
return; return;
} }
try { if (wptr == null || path != _lastOpenedWallet) {
if (wptr == null || path != _lastOpenedWallet) { if (wptr != null) {
if (wptr != null) { final addr = wptr!.address;
final addr = wptr!.address; Isolate.run(() {
Isolate.run(() { wownero.Wallet_store(Pointer.fromAddress(addr));
wownero.Wallet_store(Pointer.fromAddress(addr)); });
});
}
txhistory = null;
wptr = wownero.WalletManager_openWallet(wmPtr,
path: path, password: password);
openedWalletsByPath[path] = wptr!;
_lastOpenedWallet = path;
} }
} catch (e) { txhistory = null;
print(e); wptr = wownero.WalletManager_openWallet(wmPtr,
} path: path, password: password);
final status = wownero.Wallet_status(wptr!); _lastOpenedWallet = path;
if (status != 0) { final status = wownero.Wallet_status(wptr!);
final err = wownero.Wallet_errorString(wptr!); if (status != 0) {
print(err); final err = wownero.Wallet_errorString(wptr!);
throw WalletOpeningException(message: err); print(err);
throw WalletOpeningException(message: err);
}
openedWalletsByPath[path] = wptr!;
} }
} }

View file

@ -7,12 +7,14 @@ import 'package:cw_core/format_amount.dart';
import 'package:cw_wownero/api/transaction_history.dart'; import 'package:cw_wownero/api/transaction_history.dart';
class WowneroTransactionInfo extends TransactionInfo { class WowneroTransactionInfo extends TransactionInfo {
WowneroTransactionInfo(this.id, this.height, this.direction, this.date, WowneroTransactionInfo(this.txhash, this.height, this.direction, this.date,
this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee, this.isPending, this.amount, this.accountIndex, this.addressIndex, this.fee,
this.confirmations); this.confirmations) :
id = "${txhash}_${amount}_${accountIndex}_${addressIndex}";
WowneroTransactionInfo.fromMap(Map<String, Object?> map) WowneroTransactionInfo.fromMap(Map<String, Object?> map)
: id = (map['hash'] ?? '') as String, : id = "${map['hash']}_${map['amount']}_${map['accountIndex']}_${map['addressIndex']}",
txhash = map['hash'] as String,
height = (map['height'] ?? 0) as int, height = (map['height'] ?? 0) as int,
direction = map['direction'] != null direction = map['direction'] != null
? parseTransactionDirectionFromNumber(map['direction'] as String) ? parseTransactionDirectionFromNumber(map['direction'] as String)
@ -34,7 +36,8 @@ class WowneroTransactionInfo extends TransactionInfo {
} }
WowneroTransactionInfo.fromRow(TransactionInfoRow row) WowneroTransactionInfo.fromRow(TransactionInfoRow row)
: id = row.getHash(), : id = "${row.getHash()}_${row.getAmount()}_${row.subaddrAccount}_${row.subaddrIndex}",
txhash = row.getHash(),
height = row.blockHeight, height = row.blockHeight,
direction = parseTransactionDirectionFromInt(row.direction), direction = parseTransactionDirectionFromInt(row.direction),
date = DateTime.fromMillisecondsSinceEpoch(row.getDatetime() * 1000), date = DateTime.fromMillisecondsSinceEpoch(row.getDatetime() * 1000),
@ -53,6 +56,7 @@ class WowneroTransactionInfo extends TransactionInfo {
} }
final String id; final String id;
final String txhash;
final int height; final int height;
final TransactionDirection direction; final TransactionDirection direction;
final DateTime date; final DateTime date;

View file

@ -214,7 +214,7 @@ abstract class TransactionDetailsViewModelBase with Store {
final addressIndex = tx.additionalInfo['addressIndex'] as int; final addressIndex = tx.additionalInfo['addressIndex'] as int;
final feeFormatted = tx.feeFormatted(); final feeFormatted = tx.feeFormatted();
final _items = [ final _items = [
StandartListItem(title: S.current.transaction_details_transaction_id, value: tx.id), StandartListItem(title: S.current.transaction_details_transaction_id, value: tx.txhash),
StandartListItem( StandartListItem(
title: S.current.transaction_details_date, value: dateFormat.format(tx.date)), title: S.current.transaction_details_date, value: dateFormat.format(tx.date)),
StandartListItem(title: S.current.transaction_details_height, value: '${tx.height}'), StandartListItem(title: S.current.transaction_details_height, value: '${tx.height}'),
@ -455,7 +455,7 @@ abstract class TransactionDetailsViewModelBase with Store {
final addressIndex = tx.additionalInfo['addressIndex'] as int; final addressIndex = tx.additionalInfo['addressIndex'] as int;
final feeFormatted = tx.feeFormatted(); final feeFormatted = tx.feeFormatted();
final _items = [ final _items = [
StandartListItem(title: S.current.transaction_details_transaction_id, value: tx.id), StandartListItem(title: S.current.transaction_details_transaction_id, value: tx.txhash),
StandartListItem( StandartListItem(
title: S.current.transaction_details_date, value: dateFormat.format(tx.date)), title: S.current.transaction_details_date, value: dateFormat.format(tx.date)),
StandartListItem(title: S.current.transaction_details_height, value: '${tx.height}'), StandartListItem(title: S.current.transaction_details_height, value: '${tx.height}'),

View file

@ -8,7 +8,7 @@ if [[ ! -d "monero_c" ]];
then then
git clone https://github.com/mrcyjanek/monero_c --branch rewrite-wip git clone https://github.com/mrcyjanek/monero_c --branch rewrite-wip
cd monero_c cd monero_c
git checkout eaa7bdb8be3479418445ddb18bf33d453f64afcf git checkout d1e246aaf4c53b60ff9e4ab4a4ac3ae4a1f94a33
git reset --hard git reset --hard
git submodule update --init --force --recursive git submodule update --init --force --recursive
./apply_patches.sh monero ./apply_patches.sh monero