From ca2c16acf09115a5eb1d57eb391152f991270629 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Sun, 15 Dec 2024 08:49:13 -0500 Subject: [PATCH 1/4] Prevent wownero wallet from crashing while syncing --- cw_wownero/lib/api/transaction_history.dart | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cw_wownero/lib/api/transaction_history.dart b/cw_wownero/lib/api/transaction_history.dart index 3cebdd8112..4da8948b4e 100644 --- a/cw_wownero/lib/api/transaction_history.dart +++ b/cw_wownero/lib/api/transaction_history.dart @@ -10,6 +10,7 @@ import 'package:cw_wownero/exceptions/wownero_transaction_creation_exception.dar import 'package:ffi/ffi.dart'; import 'package:monero/wownero.dart' as wownero; import 'package:monero/src/generated_bindings_wownero.g.dart' as wownero_gen; +import 'package:mutex/mutex.dart'; String getTxKey(String txId) { @@ -18,29 +19,32 @@ String getTxKey(String txId) { return ret; } +final txHistoryMutex = Mutex(); wownero.TransactionHistory? txhistory; - bool isRefreshingTx = false; Future refreshTransactions() async { if (isRefreshingTx == true) return; isRefreshingTx = true; txhistory ??= wownero.Wallet_history(wptr!); final ptr = txhistory!.address; + await txHistoryMutex.acquire(); await Isolate.run(() { wownero.TransactionHistory_refresh(Pointer.fromAddress(ptr)); }); + txHistoryMutex.release(); isRefreshingTx = false; } int countOfTransactions() => wownero.TransactionHistory_count(txhistory!); -List getAllTransactions() { +Future> getAllTransactions() async { List dummyTxs = []; + await txHistoryMutex.acquire(); txhistory ??= wownero.Wallet_history(wptr!); - wownero.TransactionHistory_refresh(txhistory!); int size = countOfTransactions(); final list = List.generate(size, (index) => Transaction(txInfo: wownero.TransactionHistory_transaction(txhistory!, index: index))); + txHistoryMutex.release(); final accts = wownero.Wallet_numSubaddressAccounts(wptr!); for (var i = 0; i < accts; i++) { From 13b608495ba6b24332089902a93527bf5eb62b40 Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Sun, 15 Dec 2024 10:00:33 -0500 Subject: [PATCH 2/4] use async code --- cw_wownero/lib/wownero_wallet.dart | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cw_wownero/lib/wownero_wallet.dart b/cw_wownero/lib/wownero_wallet.dart index c4c79af11a..790ac95507 100644 --- a/cw_wownero/lib/wownero_wallet.dart +++ b/cw_wownero/lib/wownero_wallet.dart @@ -557,7 +557,7 @@ abstract class WowneroWalletBase @override Future> fetchTransactions() async { transaction_history.refreshTransactions(); - return _getAllTransactionsOfAccount(walletAddresses.account?.id) + return (await _getAllTransactionsOfAccount(walletAddresses.account?.id)) .fold>({}, (Map acc, WowneroTransactionInfo tx) { acc[tx.id] = tx; @@ -586,9 +586,9 @@ abstract class WowneroWalletBase String getSubaddressLabel(int accountIndex, int addressIndex) => wownero_wallet.getSubaddressLabel(accountIndex, addressIndex); - List _getAllTransactionsOfAccount(int? accountIndex) => - transaction_history - .getAllTransactions() + Future> _getAllTransactionsOfAccount(int? accountIndex) async => + (await transaction_history + .getAllTransactions()) .map( (row) => WowneroTransactionInfo( row.hash, From 384bf9b7ba554dfa67e9035b9de9eb3bca9cfd0b Mon Sep 17 00:00:00 2001 From: Czarek Nakamoto Date: Fri, 20 Dec 2024 10:00:59 +0100 Subject: [PATCH 3/4] store 14 word seed in wownero --- cw_wownero/lib/api/wallet_manager.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/cw_wownero/lib/api/wallet_manager.dart b/cw_wownero/lib/api/wallet_manager.dart index 6681652dbc..12c4e69d5c 100644 --- a/cw_wownero/lib/api/wallet_manager.dart +++ b/cw_wownero/lib/api/wallet_manager.dart @@ -127,6 +127,7 @@ void restoreWalletFromSeedSync( } wptr = newWptr; + wownero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed); openedWalletsByPath[path] = wptr!; } From 648ac216939940a728aa4ad2216914a2fab78b18 Mon Sep 17 00:00:00 2001 From: cyan Date: Fri, 27 Dec 2024 16:26:18 +0000 Subject: [PATCH 4/4] monero_c bump --- cw_monero/pubspec.lock | 4 ++-- cw_monero/pubspec.yaml | 2 +- cw_wownero/pubspec.lock | 4 ++-- cw_wownero/pubspec.yaml | 2 +- scripts/prepare_moneroc.sh | 2 +- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/cw_monero/pubspec.lock b/cw_monero/pubspec.lock index 24be1c0dd0..9006d2dee8 100644 --- a/cw_monero/pubspec.lock +++ b/cw_monero/pubspec.lock @@ -503,8 +503,8 @@ packages: dependency: "direct main" description: path: "impls/monero.dart" - ref: af5277f96073917185864d3596e82b67bee54e78 - resolved-ref: af5277f96073917185864d3596e82b67bee54e78 + ref: 1193898122baaff465aa698fc3fab1a86da22395 + resolved-ref: 1193898122baaff465aa698fc3fab1a86da22395 url: "https://github.com/mrcyjanek/monero_c" source: git version: "0.0.0" diff --git a/cw_monero/pubspec.yaml b/cw_monero/pubspec.yaml index 61caf93da5..e038222ec0 100644 --- a/cw_monero/pubspec.yaml +++ b/cw_monero/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: monero: git: url: https://github.com/mrcyjanek/monero_c - ref: af5277f96073917185864d3596e82b67bee54e78 + ref: 1193898122baaff465aa698fc3fab1a86da22395 # ref: 6eb571ea498ed7b854934785f00fabfd0dadf75b # monero_c hash path: impls/monero.dart mutex: ^3.1.0 diff --git a/cw_wownero/pubspec.lock b/cw_wownero/pubspec.lock index 1e16fa089f..b01c25a0fb 100644 --- a/cw_wownero/pubspec.lock +++ b/cw_wownero/pubspec.lock @@ -463,8 +463,8 @@ packages: dependency: "direct main" description: path: "impls/monero.dart" - ref: af5277f96073917185864d3596e82b67bee54e78 - resolved-ref: af5277f96073917185864d3596e82b67bee54e78 + ref: 1193898122baaff465aa698fc3fab1a86da22395 + resolved-ref: 1193898122baaff465aa698fc3fab1a86da22395 url: "https://github.com/mrcyjanek/monero_c" source: git version: "0.0.0" diff --git a/cw_wownero/pubspec.yaml b/cw_wownero/pubspec.yaml index a92f530f68..f3e9c36c8b 100644 --- a/cw_wownero/pubspec.yaml +++ b/cw_wownero/pubspec.yaml @@ -25,7 +25,7 @@ dependencies: monero: git: url: https://github.com/mrcyjanek/monero_c - ref: af5277f96073917185864d3596e82b67bee54e78 + ref: 1193898122baaff465aa698fc3fab1a86da22395 # ref: 6eb571ea498ed7b854934785f00fabfd0dadf75b # monero_c hash path: impls/monero.dart mutex: ^3.1.0 diff --git a/scripts/prepare_moneroc.sh b/scripts/prepare_moneroc.sh index c345408dd5..962d5e094d 100755 --- a/scripts/prepare_moneroc.sh +++ b/scripts/prepare_moneroc.sh @@ -8,7 +8,7 @@ if [[ ! -d "monero_c" ]]; then git clone https://github.com/mrcyjanek/monero_c --branch master cd monero_c - git checkout af5277f96073917185864d3596e82b67bee54e78 + git checkout 1193898122baaff465aa698fc3fab1a86da22395 git reset --hard git submodule update --init --force --recursive ./apply_patches.sh monero