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 {
late String id;
late String txhash = id;
late int amount;
int? fee;
late TransactionDirection direction;

View file

@ -194,7 +194,6 @@ void loadWallet(
wptr = openedWalletsByPath[path]!;
return;
}
try {
if (wptr == null || path != _lastOpenedWallet) {
if (wptr != null) {
final addr = wptr!.address;
@ -205,18 +204,15 @@ void loadWallet(
txhistory = null;
wptr = monero.WalletManager_openWallet(wmPtr,
path: path, password: password);
openedWalletsByPath[path] = wptr!;
_lastOpenedWallet = path;
}
} catch (e) {
print(e);
}
final status = monero.Wallet_status(wptr!);
if (status != 0) {
final err = monero.Wallet_errorString(wptr!);
print(err);
throw WalletOpeningException(message: err);
}
openedWalletsByPath[path] = wptr!;
}
}
void _createWallet(Map<String, dynamic> args) {

View file

@ -124,7 +124,7 @@ abstract class MoneroSubaddressListBase with Store {
Future<List<Subaddress>> _getAllUnusedAddresses(
{required int accountIndex, required String label}) async {
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)) {
final isAddressUnused = await _newSubaddress(accountIndex: accountIndex, label: label);
if (!isAddressUnused) {

View file

@ -1,3 +1,5 @@
import 'dart:math';
import 'package:cw_core/transaction_info.dart';
import 'package:cw_core/monero_amount_format.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';
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.confirmations);
this.confirmations) :
id = "${txhash}_${amount}_${accountIndex}_${addressIndex}";
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,
direction = map['direction'] != null
? parseTransactionDirectionFromNumber(map['direction'] as String)
@ -34,7 +38,8 @@ class MoneroTransactionInfo extends TransactionInfo {
}
MoneroTransactionInfo.fromRow(TransactionInfoRow row)
: id = row.getHash(),
: id = "${row.getHash()}_${row.getAmount()}_${row.subaddrAccount}_${row.subaddrIndex}",
txhash = row.getHash(),
height = row.blockHeight,
direction = parseTransactionDirectionFromInt(row.direction),
date = DateTime.fromMillisecondsSinceEpoch(row.getDatetime() * 1000),
@ -53,6 +58,7 @@ class MoneroTransactionInfo extends TransactionInfo {
}
final String id;
final String txhash;
final int height;
final TransactionDirection direction;
final DateTime date;

View file

@ -208,7 +208,6 @@ void loadWallet(
wptr = openedWalletsByPath[path]!;
return;
}
try {
if (wptr == null || path != _lastOpenedWallet) {
if (wptr != null) {
final addr = wptr!.address;
@ -219,18 +218,15 @@ void loadWallet(
txhistory = null;
wptr = wownero.WalletManager_openWallet(wmPtr,
path: path, password: password);
openedWalletsByPath[path] = wptr!;
_lastOpenedWallet = path;
}
} catch (e) {
print(e);
}
final status = wownero.Wallet_status(wptr!);
if (status != 0) {
final err = wownero.Wallet_errorString(wptr!);
print(err);
throw WalletOpeningException(message: err);
}
openedWalletsByPath[path] = wptr!;
}
}
void _createWallet(Map<String, dynamic> args) {

View file

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

View file

@ -214,7 +214,7 @@ abstract class TransactionDetailsViewModelBase with Store {
final addressIndex = tx.additionalInfo['addressIndex'] as int;
final feeFormatted = tx.feeFormatted();
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(
title: S.current.transaction_details_date, value: dateFormat.format(tx.date)),
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 feeFormatted = tx.feeFormatted();
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(
title: S.current.transaction_details_date, value: dateFormat.format(tx.date)),
StandartListItem(title: S.current.transaction_details_height, value: '${tx.height}'),

View file

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