mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-03 17:40:43 +00:00
Merge branch 'main' into CW-685-passphrase-support-for-monero-wownero-wallets
This commit is contained in:
commit
2591b53e9f
3 changed files with 52 additions and 37 deletions
|
@ -32,13 +32,14 @@ void createWalletSync(
|
||||||
required String language,
|
required String language,
|
||||||
int nettype = 0}) {
|
int nettype = 0}) {
|
||||||
txhistory = null;
|
txhistory = null;
|
||||||
wptr = monero.WalletManager_createWallet(wmPtr,
|
final newWptr = monero.WalletManager_createWallet(wmPtr,
|
||||||
path: path, password: password, language: language, networkType: 0);
|
path: path, password: password, language: language, networkType: 0);
|
||||||
|
|
||||||
final status = monero.Wallet_status(wptr!);
|
final status = monero.Wallet_status(newWptr);
|
||||||
if (status != 0) {
|
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);
|
monero.Wallet_store(wptr!, path: path);
|
||||||
openedWalletsByPath[path] = wptr!;
|
openedWalletsByPath[path] = wptr!;
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ void restoreWalletFromSeedSync(
|
||||||
int nettype = 0,
|
int nettype = 0,
|
||||||
int restoreHeight = 0}) {
|
int restoreHeight = 0}) {
|
||||||
txhistory = null;
|
txhistory = null;
|
||||||
wptr = monero.WalletManager_recoveryWallet(
|
final newWptr = monero.WalletManager_recoveryWallet(
|
||||||
wmPtr,
|
wmPtr,
|
||||||
path: path,
|
path: path,
|
||||||
password: password,
|
password: password,
|
||||||
|
@ -68,12 +69,13 @@ void restoreWalletFromSeedSync(
|
||||||
networkType: 0,
|
networkType: 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
final status = monero.Wallet_status(wptr!);
|
final status = monero.Wallet_status(newWptr);
|
||||||
|
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
final error = monero.Wallet_errorString(wptr!);
|
final error = monero.Wallet_errorString(newWptr);
|
||||||
throw WalletRestoreFromSeedException(message: error);
|
throw WalletRestoreFromSeedException(message: error);
|
||||||
}
|
}
|
||||||
|
wptr = newWptr;
|
||||||
|
|
||||||
monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.passphrase", value: passphrase);
|
monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.passphrase", value: passphrase);
|
||||||
|
|
||||||
|
@ -90,7 +92,7 @@ void restoreWalletFromKeysSync(
|
||||||
int nettype = 0,
|
int nettype = 0,
|
||||||
int restoreHeight = 0}) {
|
int restoreHeight = 0}) {
|
||||||
txhistory = null;
|
txhistory = null;
|
||||||
wptr = monero.WalletManager_createWalletFromKeys(
|
final newWptr = monero.WalletManager_createWalletFromKeys(
|
||||||
wmPtr,
|
wmPtr,
|
||||||
path: path,
|
path: path,
|
||||||
password: password,
|
password: password,
|
||||||
|
@ -101,12 +103,14 @@ void restoreWalletFromKeysSync(
|
||||||
nettype: 0,
|
nettype: 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
final status = monero.Wallet_status(wptr!);
|
final status = monero.Wallet_status(newWptr);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
throw WalletRestoreFromKeysException(
|
throw WalletRestoreFromKeysException(
|
||||||
message: monero.Wallet_errorString(wptr!));
|
message: monero.Wallet_errorString(newWptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wptr = newWptr;
|
||||||
|
|
||||||
openedWalletsByPath[path] = wptr!;
|
openedWalletsByPath[path] = wptr!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -131,7 +135,7 @@ void restoreWalletFromSpendKeySync(
|
||||||
// );
|
// );
|
||||||
|
|
||||||
txhistory = null;
|
txhistory = null;
|
||||||
wptr = monero.WalletManager_createDeterministicWalletFromSpendKey(
|
final newWptr = monero.WalletManager_createDeterministicWalletFromSpendKey(
|
||||||
wmPtr,
|
wmPtr,
|
||||||
path: path,
|
path: path,
|
||||||
password: password,
|
password: password,
|
||||||
|
@ -141,14 +145,16 @@ void restoreWalletFromSpendKeySync(
|
||||||
restoreHeight: restoreHeight,
|
restoreHeight: restoreHeight,
|
||||||
);
|
);
|
||||||
|
|
||||||
final status = monero.Wallet_status(wptr!);
|
final status = monero.Wallet_status(newWptr);
|
||||||
|
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
final err = monero.Wallet_errorString(wptr!);
|
final err = monero.Wallet_errorString(newWptr);
|
||||||
print("err: $err");
|
print("err: $err");
|
||||||
throw WalletRestoreFromKeysException(message: err);
|
throw WalletRestoreFromKeysException(message: err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wptr = newWptr;
|
||||||
|
|
||||||
monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed);
|
monero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed);
|
||||||
|
|
||||||
storeSync();
|
storeSync();
|
||||||
|
@ -206,15 +212,16 @@ void loadWallet(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
txhistory = null;
|
txhistory = null;
|
||||||
wptr = monero.WalletManager_openWallet(wmPtr,
|
final newWptr = monero.WalletManager_openWallet(wmPtr,
|
||||||
path: path, password: password);
|
path: path, password: password);
|
||||||
_lastOpenedWallet = path;
|
_lastOpenedWallet = path;
|
||||||
final status = monero.Wallet_status(wptr!);
|
final status = monero.Wallet_status(newWptr);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
final err = monero.Wallet_errorString(wptr!);
|
final err = monero.Wallet_errorString(newWptr);
|
||||||
print(err);
|
print(err);
|
||||||
throw WalletOpeningException(message: err);
|
throw WalletOpeningException(message: err);
|
||||||
}
|
}
|
||||||
|
wptr = newWptr;
|
||||||
openedWalletsByPath[path] = wptr!;
|
openedWalletsByPath[path] = wptr!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,14 @@ void createWalletSync(
|
||||||
required String language,
|
required String language,
|
||||||
int nettype = 0}) {
|
int nettype = 0}) {
|
||||||
txhistory = null;
|
txhistory = null;
|
||||||
wptr = wownero.WalletManager_createWallet(wmPtr,
|
final newWptr = wownero.WalletManager_createWallet(wmPtr,
|
||||||
path: path, password: password, language: language, networkType: 0);
|
path: path, password: password, language: language, networkType: 0);
|
||||||
|
|
||||||
final status = wownero.Wallet_status(wptr!);
|
final status = wownero.Wallet_status(newWptr);
|
||||||
if (status != 0) {
|
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);
|
wownero.Wallet_store(wptr!, path: path);
|
||||||
openedWalletsByPath[path] = wptr!;
|
openedWalletsByPath[path] = wptr!;
|
||||||
|
|
||||||
|
@ -57,9 +58,10 @@ void restoreWalletFromSeedSync(
|
||||||
required String seed,
|
required String seed,
|
||||||
int nettype = 0,
|
int nettype = 0,
|
||||||
int restoreHeight = 0}) {
|
int restoreHeight = 0}) {
|
||||||
|
var newWptr;
|
||||||
if (seed.split(" ").length == 14) {
|
if (seed.split(" ").length == 14) {
|
||||||
txhistory = null;
|
txhistory = null;
|
||||||
wptr = wownero.WOWNERO_deprecated_restore14WordSeed(
|
newWptr = wownero.WOWNERO_deprecated_restore14WordSeed(
|
||||||
path: path,
|
path: path,
|
||||||
password: password,
|
password: password,
|
||||||
language: seed, // I KNOW - this is supposed to be called seed
|
language: seed, // I KNOW - this is supposed to be called seed
|
||||||
|
@ -71,7 +73,7 @@ void restoreWalletFromSeedSync(
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
txhistory = null;
|
txhistory = null;
|
||||||
wptr = wownero.WalletManager_recoveryWallet(
|
newWptr = wownero.WalletManager_recoveryWallet(
|
||||||
wmPtr,
|
wmPtr,
|
||||||
path: path,
|
path: path,
|
||||||
password: password,
|
password: password,
|
||||||
|
@ -82,13 +84,14 @@ void restoreWalletFromSeedSync(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
final status = wownero.Wallet_status(wptr!);
|
final status = wownero.Wallet_status(newWptr);
|
||||||
|
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
final error = wownero.Wallet_errorString(wptr!);
|
final error = wownero.Wallet_errorString(newWptr);
|
||||||
throw WalletRestoreFromSeedException(message: error);
|
throw WalletRestoreFromSeedException(message: error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wptr = newWptr;
|
||||||
wownero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.passphrase", value: passphrase);
|
wownero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.passphrase", value: passphrase);
|
||||||
|
|
||||||
openedWalletsByPath[path] = wptr!;
|
openedWalletsByPath[path] = wptr!;
|
||||||
|
@ -104,7 +107,7 @@ void restoreWalletFromKeysSync(
|
||||||
int nettype = 0,
|
int nettype = 0,
|
||||||
int restoreHeight = 0}) {
|
int restoreHeight = 0}) {
|
||||||
txhistory = null;
|
txhistory = null;
|
||||||
wptr = wownero.WalletManager_createWalletFromKeys(
|
final newWptr = wownero.WalletManager_createWalletFromKeys(
|
||||||
wmPtr,
|
wmPtr,
|
||||||
path: path,
|
path: path,
|
||||||
password: password,
|
password: password,
|
||||||
|
@ -115,12 +118,14 @@ void restoreWalletFromKeysSync(
|
||||||
nettype: 0,
|
nettype: 0,
|
||||||
);
|
);
|
||||||
|
|
||||||
final status = wownero.Wallet_status(wptr!);
|
final status = wownero.Wallet_status(newWptr);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
throw WalletRestoreFromKeysException(
|
throw WalletRestoreFromKeysException(
|
||||||
message: wownero.Wallet_errorString(wptr!));
|
message: wownero.Wallet_errorString(newWptr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wptr = newWptr;
|
||||||
|
|
||||||
openedWalletsByPath[path] = wptr!;
|
openedWalletsByPath[path] = wptr!;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +150,7 @@ void restoreWalletFromSpendKeySync(
|
||||||
// );
|
// );
|
||||||
|
|
||||||
txhistory = null;
|
txhistory = null;
|
||||||
wptr = wownero.WalletManager_createDeterministicWalletFromSpendKey(
|
final newWptr = wownero.WalletManager_createDeterministicWalletFromSpendKey(
|
||||||
wmPtr,
|
wmPtr,
|
||||||
path: path,
|
path: path,
|
||||||
password: password,
|
password: password,
|
||||||
|
@ -155,14 +160,16 @@ void restoreWalletFromSpendKeySync(
|
||||||
restoreHeight: restoreHeight,
|
restoreHeight: restoreHeight,
|
||||||
);
|
);
|
||||||
|
|
||||||
final status = wownero.Wallet_status(wptr!);
|
final status = wownero.Wallet_status(newWptr);
|
||||||
|
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
final err = wownero.Wallet_errorString(wptr!);
|
final err = wownero.Wallet_errorString(newWptr);
|
||||||
print("err: $err");
|
print("err: $err");
|
||||||
throw WalletRestoreFromKeysException(message: err);
|
throw WalletRestoreFromKeysException(message: err);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wptr = newWptr;
|
||||||
|
|
||||||
wownero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed);
|
wownero.Wallet_setCacheAttribute(wptr!, key: "cakewallet.seed", value: seed);
|
||||||
|
|
||||||
storeSync();
|
storeSync();
|
||||||
|
@ -220,15 +227,16 @@ void loadWallet(
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
txhistory = null;
|
txhistory = null;
|
||||||
wptr = wownero.WalletManager_openWallet(wmPtr,
|
final newWptr = wownero.WalletManager_openWallet(wmPtr,
|
||||||
path: path, password: password);
|
path: path, password: password);
|
||||||
_lastOpenedWallet = path;
|
_lastOpenedWallet = path;
|
||||||
final status = wownero.Wallet_status(wptr!);
|
final status = wownero.Wallet_status(newWptr);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
final err = wownero.Wallet_errorString(wptr!);
|
final err = wownero.Wallet_errorString(newWptr);
|
||||||
print(err);
|
print(err);
|
||||||
throw WalletOpeningException(message: err);
|
throw WalletOpeningException(message: err);
|
||||||
}
|
}
|
||||||
|
wptr = newWptr;
|
||||||
openedWalletsByPath[path] = wptr!;
|
openedWalletsByPath[path] = wptr!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -83,8 +83,8 @@ abstract class WalletKeysViewModelBase with Store {
|
||||||
StandartListItem(
|
StandartListItem(
|
||||||
title: S.current.view_key_private,
|
title: S.current.view_key_private,
|
||||||
value: keys['privateViewKey']!),
|
value: keys['privateViewKey']!),
|
||||||
StandartListItem(
|
if (_appStore.wallet!.seed!.isNotEmpty)
|
||||||
title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
|
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (_appStore.wallet?.seed != null &&
|
if (_appStore.wallet?.seed != null &&
|
||||||
|
@ -129,8 +129,8 @@ abstract class WalletKeysViewModelBase with Store {
|
||||||
StandartListItem(
|
StandartListItem(
|
||||||
title: S.current.view_key_private,
|
title: S.current.view_key_private,
|
||||||
value: keys['privateViewKey']!),
|
value: keys['privateViewKey']!),
|
||||||
StandartListItem(
|
if (_appStore.wallet!.seed!.isNotEmpty)
|
||||||
title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
|
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,8 +153,8 @@ abstract class WalletKeysViewModelBase with Store {
|
||||||
StandartListItem(
|
StandartListItem(
|
||||||
title: S.current.view_key_private,
|
title: S.current.view_key_private,
|
||||||
value: keys['privateViewKey']!),
|
value: keys['privateViewKey']!),
|
||||||
StandartListItem(
|
if (_appStore.wallet!.seed!.isNotEmpty)
|
||||||
title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
|
StandartListItem(title: S.current.wallet_seed, value: _appStore.wallet!.seed!),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if (_appStore.wallet?.seed != null &&
|
if (_appStore.wallet?.seed != null &&
|
||||||
|
|
Loading…
Reference in a new issue