mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
do not restore deterministic wallet if it's not one (#1676)
* do not restore deterministic wallet if it's not one * [skip ci] update comment
This commit is contained in:
parent
7bf2fb9dce
commit
417de3669c
2 changed files with 53 additions and 3 deletions
|
@ -123,7 +123,7 @@ void restoreWalletFromKeysSync(
|
|||
int nettype = 0,
|
||||
int restoreHeight = 0}) {
|
||||
txhistory = null;
|
||||
final newWptr = spendKey != ""
|
||||
var newWptr = (spendKey != "")
|
||||
? monero.WalletManager_createDeterministicWalletFromSpendKey(
|
||||
wmPtr,
|
||||
path: path,
|
||||
|
@ -149,6 +149,32 @@ void restoreWalletFromKeysSync(
|
|||
message: monero.Wallet_errorString(newWptr));
|
||||
}
|
||||
|
||||
// CW-712 - Try to restore deterministic wallet first, if the view key doesn't
|
||||
// match the view key provided
|
||||
if (spendKey != "") {
|
||||
final viewKeyRestored = monero.Wallet_secretViewKey(newWptr);
|
||||
if (viewKey != viewKeyRestored && viewKey != "") {
|
||||
monero.WalletManager_closeWallet(wmPtr, newWptr, false);
|
||||
File(path).deleteSync();
|
||||
File(path+".keys").deleteSync();
|
||||
newWptr = monero.WalletManager_createWalletFromKeys(
|
||||
wmPtr,
|
||||
path: path,
|
||||
password: password,
|
||||
restoreHeight: restoreHeight,
|
||||
addressString: address,
|
||||
viewKeyString: viewKey,
|
||||
spendKeyString: spendKey,
|
||||
nettype: 0,
|
||||
);
|
||||
final status = monero.Wallet_status(newWptr);
|
||||
if (status != 0) {
|
||||
throw WalletRestoreFromKeysException(
|
||||
message: monero.Wallet_errorString(newWptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
wptr = newWptr;
|
||||
|
||||
openedWalletsByPath[path] = wptr!;
|
||||
|
|
|
@ -140,7 +140,7 @@ void restoreWalletFromKeysSync(
|
|||
int nettype = 0,
|
||||
int restoreHeight = 0}) {
|
||||
txhistory = null;
|
||||
final newWptr = spendKey != ""
|
||||
var newWptr = (spendKey != "")
|
||||
? wownero.WalletManager_createDeterministicWalletFromSpendKey(
|
||||
wmPtr,
|
||||
path: path,
|
||||
|
@ -165,7 +165,31 @@ void restoreWalletFromKeysSync(
|
|||
throw WalletRestoreFromKeysException(
|
||||
message: wownero.Wallet_errorString(newWptr));
|
||||
}
|
||||
|
||||
// CW-712 - Try to restore deterministic wallet first, if the view key doesn't
|
||||
// match the view key provided
|
||||
if (spendKey != "") {
|
||||
final viewKeyRestored = wownero.Wallet_secretViewKey(newWptr);
|
||||
if (viewKey != viewKeyRestored && viewKey != "") {
|
||||
wownero.WalletManager_closeWallet(wmPtr, newWptr, false);
|
||||
File(path).deleteSync();
|
||||
File(path+".keys").deleteSync();
|
||||
newWptr = wownero.WalletManager_createWalletFromKeys(
|
||||
wmPtr,
|
||||
path: path,
|
||||
password: password,
|
||||
restoreHeight: restoreHeight,
|
||||
addressString: address,
|
||||
viewKeyString: viewKey,
|
||||
spendKeyString: spendKey,
|
||||
nettype: 0,
|
||||
);
|
||||
final status = wownero.Wallet_status(newWptr);
|
||||
if (status != 0) {
|
||||
throw WalletRestoreFromKeysException(
|
||||
message: wownero.Wallet_errorString(newWptr));
|
||||
}
|
||||
}
|
||||
}
|
||||
wptr = newWptr;
|
||||
|
||||
openedWalletsByPath[path] = wptr!;
|
||||
|
|
Loading…
Reference in a new issue