Skip to content

Commit

Permalink
fix find wallets (#46)
Browse files Browse the repository at this point in the history
* Update WalletManager_findWallets
* prevent crash when there are no wallets found
* return List<String> instead of colon separated String
  • Loading branch information
MrCyjaneK authored Sep 4, 2024
1 parent 811ade0 commit 1e22390
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
11 changes: 7 additions & 4 deletions impls/monero.dart/lib/monero.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3585,7 +3585,8 @@ bool WalletManager_verifyWalletPassword(
return s;
}

String WalletManager_findWallets(WalletManager wm_ptr, {required String path}) {
List<String> WalletManager_findWallets(WalletManager wm_ptr,
{required String path}) {
debugStart?.call('MONERO_WalletManager_findWallets');
lib ??= MoneroC(DynamicLibrary.open(libPath));
try {
Expand All @@ -3595,13 +3596,15 @@ String WalletManager_findWallets(WalletManager wm_ptr, {required String path}) {
.cast<Utf8>();
final str = strPtr.toDartString();
calloc.free(path_);
MONERO_free(strPtr.cast());
if (str.isNotEmpty) {
MONERO_free(strPtr.cast());
}
debugEnd?.call('MONERO_WalletManager_findWallets');
return str;
return str.split(";");
} catch (e) {
errorHandler?.call('MONERO_WalletManager_findWallets', e);
debugEnd?.call('MONERO_WalletManager_findWallets');
return "";
return [];
}
}

Expand Down
12 changes: 7 additions & 5 deletions impls/monero.dart/lib/wownero.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3220,7 +3220,8 @@ bool WalletManager_verifyWalletPassword(
return s;
}

String WalletManager_findWallets(WalletManager wm_ptr, {required String path}) {
List<String> WalletManager_findWallets(WalletManager wm_ptr,
{required String path}) {
debugStart?.call('WOWNERO_WalletManager_findWallets');
lib ??= WowneroC(DynamicLibrary.open(libPath));
try {
Expand All @@ -3230,13 +3231,15 @@ String WalletManager_findWallets(WalletManager wm_ptr, {required String path}) {
.cast<Utf8>();
final str = strPtr.toDartString();
calloc.free(path_);
WOWNERO_free(strPtr.cast());
if (str.isNotEmpty) {
WOWNERO_free(strPtr.cast());
}
debugEnd?.call('WOWNERO_WalletManager_findWallets');
return str;
return str.split(";");
} catch (e) {
errorHandler?.call('WOWNERO_WalletManager_findWallets', e);
debugEnd?.call('WOWNERO_WalletManager_findWallets');
return "";
return [];
}
}

Expand Down Expand Up @@ -3606,7 +3609,6 @@ int WOWNERO_deprecated_14WordSeedHeight({
return s;
}


String WOWNERO_checksum_wallet2_api_c_h() {
debugStart?.call('WOWNERO_checksum_wallet2_api_c_h');
lib ??= WowneroC(DynamicLibrary.open(libPath));
Expand Down

0 comments on commit 1e22390

Please sign in to comment.