Merge branch 'main' into linux_monero_dart

This commit is contained in:
Omar Hatem 2024-07-27 01:42:42 +03:00 committed by GitHub
commit d754773b03
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 53 additions and 37 deletions

View file

@ -34,13 +34,14 @@ void createWalletSync(
required String language,
int nettype = 0}) {
txhistory = null;
wptr = monero.WalletManager_createWallet(wmPtr,
final newWptr = monero.WalletManager_createWallet(wmPtr,
path: path, password: password, language: language, networkType: 0);
final status = monero.Wallet_status(wptr!);
final status = monero.Wallet_status(newWptr);
if (status != 0) {
throw WalletCreationException(message: monero.Wallet_errorString(wptr!));
throw WalletCreationException(message: monero.Wallet_errorString(newWptr));
}
wptr = newWptr;
monero.Wallet_store(wptr!, path: path);
openedWalletsByPath[path] = wptr!;
@ -59,7 +60,7 @@ void restoreWalletFromSeedSync(
int nettype = 0,
int restoreHeight = 0}) {
txhistory = null;
wptr = monero.WalletManager_recoveryWallet(
final newWptr = monero.WalletManager_recoveryWallet(
wmPtr,
path: path,
password: password,
@ -69,12 +70,13 @@ void restoreWalletFromSeedSync(
networkType: 0,
);
final status = monero.Wallet_status(wptr!);
final status = monero.Wallet_status(newWptr);
if (status != 0) {
final error = monero.Wallet_errorString(wptr!);
final error = monero.Wallet_errorString(newWptr);
throw WalletRestoreFromSeedException(message: error);
}
wptr = newWptr;
openedWalletsByPath[path] = wptr!;
}
@ -89,7 +91,7 @@ void restoreWalletFromKeysSync(
int nettype = 0,
int restoreHeight = 0}) {
txhistory = null;
wptr = monero.WalletManager_createWalletFromKeys(
final newWptr = monero.WalletManager_createWalletFromKeys(
wmPtr,
path: path,
password: password,
@ -100,12 +102,14 @@ void restoreWalletFromKeysSync(
nettype: 0,
);
final status = monero.Wallet_status(wptr!);
final status = monero.Wallet_status(newWptr);
if (status != 0) {
throw WalletRestoreFromKeysException(
message: monero.Wallet_errorString(wptr!));
message: monero.Wallet_errorString(newWptr));
}
wptr = newWptr;
openedWalletsByPath[path] = wptr!;
}
@ -130,7 +134,7 @@ void restoreWalletFromSpendKeySync(
// );
txhistory = null;
wptr = monero.WalletManager_createDeterministicWalletFromSpendKey(
final newWptr = monero.WalletManager_createDeterministicWalletFromSpendKey(
wmPtr,
path: path,
password: password,
@ -140,14 +144,16 @@ void restoreWalletFromSpendKeySync(
restoreHeight: restoreHeight,
);
final status = monero.Wallet_status(wptr!);
final status = monero.Wallet_status(newWptr);
if (status != 0) {
final err = monero.Wallet_errorString(wptr!);
final err = monero.Wallet_errorString(newWptr);
print("err: $err");
throw WalletRestoreFromKeysException(message: err);
}
wptr = newWptr;
monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed);
storeSync();
@ -205,15 +211,16 @@ void loadWallet(
});
}
txhistory = null;
wptr = monero.WalletManager_openWallet(wmPtr,
final newWptr = monero.WalletManager_openWallet(wmPtr,
path: path, password: password);
_lastOpenedWallet = path;
final status = monero.Wallet_status(wptr!);
final status = monero.Wallet_status(newWptr);
if (status != 0) {
final err = monero.Wallet_errorString(wptr!);
final err = monero.Wallet_errorString(newWptr);
print(err);
throw WalletOpeningException(message: err);
}
wptr = newWptr;
openedWalletsByPath[path] = wptr!;
}
}

View file

@ -32,13 +32,14 @@ void createWalletSync(
required String language,
int nettype = 0}) {
txhistory = null;
wptr = wownero.WalletManager_createWallet(wmPtr,
final newWptr = wownero.WalletManager_createWallet(wmPtr,
path: path, password: password, language: language, networkType: 0);
final status = wownero.Wallet_status(wptr!);
final status = wownero.Wallet_status(newWptr);
if (status != 0) {
throw WalletCreationException(message: wownero.Wallet_errorString(wptr!));
throw WalletCreationException(message: wownero.Wallet_errorString(newWptr));
}
wptr = newWptr;
wownero.Wallet_store(wptr!, path: path);
openedWalletsByPath[path] = wptr!;
@ -56,9 +57,10 @@ void restoreWalletFromSeedSync(
required String seed,
int nettype = 0,
int restoreHeight = 0}) {
var newWptr;
if (seed.split(" ").length == 14) {
txhistory = null;
wptr = wownero.WOWNERO_deprecated_restore14WordSeed(
newWptr = wownero.WOWNERO_deprecated_restore14WordSeed(
path: path,
password: password,
language: seed, // I KNOW - this is supposed to be called seed
@ -70,7 +72,7 @@ void restoreWalletFromSeedSync(
);
} else {
txhistory = null;
wptr = wownero.WalletManager_recoveryWallet(
newWptr = wownero.WalletManager_recoveryWallet(
wmPtr,
path: path,
password: password,
@ -81,13 +83,15 @@ void restoreWalletFromSeedSync(
);
}
final status = wownero.Wallet_status(wptr!);
final status = wownero.Wallet_status(newWptr);
if (status != 0) {
final error = wownero.Wallet_errorString(wptr!);
final error = wownero.Wallet_errorString(newWptr);
throw WalletRestoreFromSeedException(message: error);
}
wptr = newWptr;
openedWalletsByPath[path] = wptr!;
}
@ -101,7 +105,7 @@ void restoreWalletFromKeysSync(
int nettype = 0,
int restoreHeight = 0}) {
txhistory = null;
wptr = wownero.WalletManager_createWalletFromKeys(
final newWptr = wownero.WalletManager_createWalletFromKeys(
wmPtr,
path: path,
password: password,
@ -112,12 +116,14 @@ void restoreWalletFromKeysSync(
nettype: 0,
);
final status = wownero.Wallet_status(wptr!);
final status = wownero.Wallet_status(newWptr);
if (status != 0) {
throw WalletRestoreFromKeysException(
message: wownero.Wallet_errorString(wptr!));
message: wownero.Wallet_errorString(newWptr));
}
wptr = newWptr;
openedWalletsByPath[path] = wptr!;
}
@ -142,7 +148,7 @@ void restoreWalletFromSpendKeySync(
// );
txhistory = null;
wptr = wownero.WalletManager_createDeterministicWalletFromSpendKey(
final newWptr = wownero.WalletManager_createDeterministicWalletFromSpendKey(
wmPtr,
path: path,
password: password,
@ -152,14 +158,16 @@ void restoreWalletFromSpendKeySync(
restoreHeight: restoreHeight,
);
final status = wownero.Wallet_status(wptr!);
final status = wownero.Wallet_status(newWptr);
if (status != 0) {
final err = wownero.Wallet_errorString(wptr!);
final err = wownero.Wallet_errorString(newWptr);
print("err: $err");
throw WalletRestoreFromKeysException(message: err);
}
wptr = newWptr;
wownero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed);
storeSync();
@ -217,15 +225,16 @@ void loadWallet(
});
}
txhistory = null;
wptr = wownero.WalletManager_openWallet(wmPtr,
final newWptr = wownero.WalletManager_openWallet(wmPtr,
path: path, password: password);
_lastOpenedWallet = path;
final status = wownero.Wallet_status(wptr!);
final status = wownero.Wallet_status(newWptr);
if (status != 0) {
final err = wownero.Wallet_errorString(wptr!);
final err = wownero.Wallet_errorString(newWptr);
print(err);
throw WalletOpeningException(message: err);
}
wptr = newWptr;
openedWalletsByPath[path] = wptr!;
}
}

View file

@ -83,8 +83,8 @@ abstract class WalletKeysViewModelBase with Store {
StandartListItem(
title: S.current.view_key_private,
value: keys['privateViewKey']!),
StandartListItem(
title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
if (_appStore.wallet!.seed!.isNotEmpty)
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
]);
if (_appStore.wallet?.seed != null &&
@ -123,8 +123,8 @@ abstract class WalletKeysViewModelBase with Store {
StandartListItem(
title: S.current.view_key_private,
value: keys['privateViewKey']!),
StandartListItem(
title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
if (_appStore.wallet!.seed!.isNotEmpty)
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
]);
}
@ -147,8 +147,8 @@ abstract class WalletKeysViewModelBase with Store {
StandartListItem(
title: S.current.view_key_private,
value: keys['privateViewKey']!),
StandartListItem(
title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
if (_appStore.wallet!.seed!.isNotEmpty)
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
]);
if (_appStore.wallet?.seed != null &&