seed fixes (#1594)
Some checks are pending
Cache Dependencies / test (push) Waiting to run

* seed fixes + jCenter removal

* set seed language to English if none
show error when requesting seed

---------

Co-authored-by: Omar Hatem <omarh.ismail1@gmail.com>
This commit is contained in:
cyan 2024-08-15 01:41:22 +02:00 committed by GitHub
parent d96bab43c9
commit 4fa487fa27
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 36 additions and 9 deletions

View file

@ -39,7 +39,7 @@ String getSeed() {
if (polyseed != "") { if (polyseed != "") {
return polyseed; return polyseed;
} }
final legacy = monero.Wallet_seed(wptr!, seedOffset: ''); final legacy = getSeedLegacy("English");
return legacy; return legacy;
} }
@ -49,6 +49,9 @@ String getSeedLegacy(String? language) {
monero.Wallet_setSeedLanguage(wptr!, language: language ?? "English"); monero.Wallet_setSeedLanguage(wptr!, language: language ?? "English");
legacy = monero.Wallet_seed(wptr!, seedOffset: ''); legacy = monero.Wallet_seed(wptr!, seedOffset: '');
} }
if (monero.Wallet_status(wptr!) != 0) {
return monero.Wallet_errorString(wptr!);
}
return legacy; return legacy;
} }

View file

@ -123,7 +123,16 @@ void restoreWalletFromKeysSync(
int nettype = 0, int nettype = 0,
int restoreHeight = 0}) { int restoreHeight = 0}) {
txhistory = null; txhistory = null;
final newWptr = monero.WalletManager_createWalletFromKeys( final newWptr = spendKey != ""
? monero.WalletManager_createDeterministicWalletFromSpendKey(
wmPtr,
path: path,
password: password,
language: language,
spendKeyString: spendKey,
newWallet: true, // TODO(mrcyjanek): safe to remove
restoreHeight: restoreHeight)
: monero.WalletManager_createWalletFromKeys(
wmPtr, wmPtr,
path: path, path: path,
password: password, password: password,

View file

@ -41,7 +41,7 @@ String getSeed() {
if (polyseed != "") { if (polyseed != "") {
return polyseed; return polyseed;
} }
final legacy = wownero.Wallet_seed(wptr!, seedOffset: ''); final legacy = getSeedLegacy(null);
return legacy; return legacy;
} }
@ -51,6 +51,9 @@ String getSeedLegacy(String? language) {
wownero.Wallet_setSeedLanguage(wptr!, language: language ?? "English"); wownero.Wallet_setSeedLanguage(wptr!, language: language ?? "English");
legacy = wownero.Wallet_seed(wptr!, seedOffset: ''); legacy = wownero.Wallet_seed(wptr!, seedOffset: '');
} }
if (wownero.Wallet_status(wptr!) != 0) {
return wownero.Wallet_errorString(wptr!);
}
return legacy; return legacy;
} }

View file

@ -140,7 +140,16 @@ void restoreWalletFromKeysSync(
int nettype = 0, int nettype = 0,
int restoreHeight = 0}) { int restoreHeight = 0}) {
txhistory = null; txhistory = null;
final newWptr = wownero.WalletManager_createWalletFromKeys( final newWptr = spendKey != ""
? wownero.WalletManager_createDeterministicWalletFromSpendKey(
wmPtr,
path: path,
password: password,
language: language,
spendKeyString: spendKey,
newWallet: true, // TODO(mrcyjanek): safe to remove
restoreHeight: restoreHeight)
: wownero.WalletManager_createWalletFromKeys(
wmPtr, wmPtr,
path: path, path: path,
password: password, password: password,

View file

@ -362,12 +362,15 @@ abstract class DashboardViewModelBase with Store {
if (wallet.type != WalletType.monero) return []; if (wallet.type != WalletType.monero) return [];
final keys = monero!.getKeys(wallet); final keys = monero!.getKeys(wallet);
List<String> errors = [ List<String> errors = [
if (keys['privateSpendKey'] == List.generate(64, (index) => "0").join("")) "Private spend key is 0", // leaving these commented out for now, I'll be able to fix that properly in the airgap update
// to not cause work duplication, this will do the job as well, it will be slightly less precise
// about what happened - but still enough.
// if (keys['privateSpendKey'] == List.generate(64, (index) => "0").join("")) "Private spend key is 0",
if (keys['privateViewKey'] == List.generate(64, (index) => "0").join("")) "private view key is 0", if (keys['privateViewKey'] == List.generate(64, (index) => "0").join("")) "private view key is 0",
if (keys['publicSpendKey'] == List.generate(64, (index) => "0").join("")) "public spend key is 0", // if (keys['publicSpendKey'] == List.generate(64, (index) => "0").join("")) "public spend key is 0",
if (keys['publicViewKey'] == List.generate(64, (index) => "0").join("")) "private view key is 0", if (keys['publicViewKey'] == List.generate(64, (index) => "0").join("")) "public view key is 0",
if (wallet.seed == null) "wallet seed is null", // if (wallet.seed == null) "wallet seed is null",
if (wallet.seed == "") "wallet seed is empty", // if (wallet.seed == "") "wallet seed is empty",
if (monero!.getSubaddressList(wallet).getAll(wallet)[0].address == "41d7FXjswpK1111111111111111111111111111111111111111111111111111111111111111111111111111112KhNi4") if (monero!.getSubaddressList(wallet).getAll(wallet)[0].address == "41d7FXjswpK1111111111111111111111111111111111111111111111111111111111111111111111111111112KhNi4")
"primary address is invalid, you won't be able to receive / spend funds", "primary address is invalid, you won't be able to receive / spend funds",
]; ];