mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2024-12-22 11:39:22 +00:00
Merge branch 'wownero' of https://github.com/cake-tech/cake_wallet into wownero_breez
This commit is contained in:
commit
03e25b4adc
7 changed files with 69 additions and 21 deletions
|
@ -53,15 +53,28 @@ void restoreWalletFromSeedSync(
|
|||
required String seed,
|
||||
int nettype = 0,
|
||||
int restoreHeight = 0}) {
|
||||
wptr = wownero.WalletManager_recoveryWallet(
|
||||
wmPtr,
|
||||
path: path,
|
||||
password: password,
|
||||
mnemonic: seed,
|
||||
restoreHeight: restoreHeight,
|
||||
seedOffset: '',
|
||||
networkType: 0,
|
||||
);
|
||||
if (seed.split(" ").length == 14) {
|
||||
wptr = wownero.WOWNERO_deprecated_restore14WordSeed(
|
||||
path: path,
|
||||
password: password,
|
||||
language: seed, // I KNOW - this is supposed to be called seed
|
||||
networkType: 0,
|
||||
);
|
||||
|
||||
setRefreshFromBlockHeight(
|
||||
height: wownero.WOWNERO_deprecated_14WordSeedHeight(seed: seed),
|
||||
);
|
||||
} else {
|
||||
wptr = wownero.WalletManager_recoveryWallet(
|
||||
wmPtr,
|
||||
path: path,
|
||||
password: password,
|
||||
mnemonic: seed,
|
||||
restoreHeight: restoreHeight,
|
||||
seedOffset: '',
|
||||
networkType: 0,
|
||||
);
|
||||
}
|
||||
|
||||
final status = wownero.Wallet_status(wptr!);
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ class SeedType extends EnumerableItem<int> with Serializable<int> {
|
|||
|
||||
static const legacy = SeedType(raw: 0, title: 'Legacy (25 words)');
|
||||
static const polyseed = SeedType(raw: 1, title: 'Polyseed (16 words)');
|
||||
static const wowneroSeed = SeedType(raw: 1, title: 'Wownero (14 words)');
|
||||
|
||||
static SeedType deserialize({required int raw}) {
|
||||
switch (raw) {
|
||||
|
@ -17,6 +18,8 @@ class SeedType extends EnumerableItem<int> with Serializable<int> {
|
|||
return legacy;
|
||||
case 1:
|
||||
return polyseed;
|
||||
case 2:
|
||||
return wowneroSeed;
|
||||
default:
|
||||
throw Exception('Unexpected token: $raw for SeedType deserialize');
|
||||
}
|
||||
|
@ -29,6 +32,8 @@ class SeedType extends EnumerableItem<int> with Serializable<int> {
|
|||
return S.current.seedtype_legacy;
|
||||
case SeedType.polyseed:
|
||||
return S.current.seedtype_polyseed;
|
||||
case SeedType.wowneroSeed:
|
||||
return S.current.seedtype_wownero;
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
|
|
|
@ -90,6 +90,10 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
|
|||
_changeSeedType(SeedType.polyseed);
|
||||
_changeLanguage(lang.nameEnglish);
|
||||
}
|
||||
if (widget.type == WalletType.wownero && seed.split(" ").length == 14) {
|
||||
_changeSeedType(SeedType.wowneroSeed);
|
||||
_changeLanguage("English");
|
||||
}
|
||||
widget.onSeedChange?.call(seed);
|
||||
}
|
||||
|
||||
|
@ -149,8 +153,20 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
|
|||
await showPopUp<void>(
|
||||
context: context,
|
||||
builder: (_) => Picker(
|
||||
items: SeedType.all,
|
||||
selectedAtIndex: isPolyseed ? 1 : 0,
|
||||
items: switch (widget.type) {
|
||||
WalletType.monero => [SeedType.legacy, SeedType.polyseed],
|
||||
WalletType.wownero => [
|
||||
SeedType.legacy,
|
||||
SeedType.polyseed,
|
||||
SeedType.wowneroSeed
|
||||
],
|
||||
_ => [SeedType.legacy]
|
||||
},
|
||||
selectedAtIndex: isPolyseed
|
||||
? 1
|
||||
: seedTypeController.value.text.contains("14")
|
||||
? 2
|
||||
: 0,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
onItemSelected: _changeSeedType,
|
||||
isSeparated: false,
|
||||
|
@ -169,7 +185,7 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (widget.displayLanguageSelector)
|
||||
if (!seedTypeController.value.text.contains("14") && widget.displayLanguageSelector)
|
||||
GestureDetector(
|
||||
onTap: () async {
|
||||
await showPopUp<void>(
|
||||
|
@ -193,7 +209,9 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (!isPolyseed && widget.displayBlockHeightSelector)
|
||||
if ((!isPolyseed) &&
|
||||
widget.displayBlockHeightSelector &&
|
||||
(widget.type == WalletType.wownero && !seedTypeController.value.text.contains("14")))
|
||||
BlockchainHeightWidget(
|
||||
focusNode: widget.blockHeightFocusNode,
|
||||
key: blockchainHeightKey,
|
||||
|
@ -228,7 +246,11 @@ class WalletRestoreFromSeedFormState extends State<WalletRestoreFromSeedForm> {
|
|||
);
|
||||
|
||||
void _changeLanguage(String language) {
|
||||
final setLang = isPolyseed ? "POLYSEED_$language" : language;
|
||||
final setLang = isPolyseed
|
||||
? "POLYSEED_$language"
|
||||
: seedTypeController.value.text.contains("14")
|
||||
? "WOWSEED_" + language
|
||||
: language;
|
||||
setState(() {
|
||||
this.language = setLang;
|
||||
seedWidgetStateKey.currentState!.changeSeedLanguage(setLang);
|
||||
|
|
|
@ -255,6 +255,8 @@ class WalletRestorePage extends BasePage {
|
|||
|
||||
final seedWords = seedPhrase.split(' ');
|
||||
|
||||
if (seedWords.length == 14 && walletRestoreViewModel.type == WalletType.wownero) return true;
|
||||
|
||||
if ((walletRestoreViewModel.type == WalletType.monero ||
|
||||
walletRestoreViewModel.type == WalletType.wownero ||
|
||||
walletRestoreViewModel.type == WalletType.haven) &&
|
||||
|
|
|
@ -44,7 +44,8 @@ abstract class WalletCreationVMBase with Store {
|
|||
final AppStore _appStore;
|
||||
|
||||
bool isPolyseed(String seed) =>
|
||||
(type == WalletType.monero || type == WalletType.wownero) && Polyseed.isValidSeed(seed);
|
||||
(type == WalletType.monero || type == WalletType.wownero) &&
|
||||
(Polyseed.isValidSeed(seed) || (seed.split(" ").length == 14));
|
||||
|
||||
bool nameExists(String name) => walletCreationService.exists(name);
|
||||
|
||||
|
|
|
@ -170,6 +170,10 @@ class CWWownero extends Wownero {
|
|||
final lang = language.replaceAll("POLYSEED_", "");
|
||||
return PolyseedLang.getByEnglishName(lang).words;
|
||||
}
|
||||
if (language.startsWith("WOWSEED_")) {
|
||||
final lang = language.replaceAll("WOWSEED_", "");
|
||||
return PolyseedLang.getByEnglishName(lang).words;
|
||||
}
|
||||
switch (language.toLowerCase()) {
|
||||
case 'english':
|
||||
return EnglishMnemonics.words;
|
||||
|
@ -224,13 +228,13 @@ class CWWownero extends Wownero {
|
|||
name: name, password: password, height: height, mnemonic: mnemonic);
|
||||
|
||||
@override
|
||||
WalletCredentials createWowneroNewWalletCredentials({
|
||||
required String name,
|
||||
required String language,
|
||||
required bool isPolyseed,
|
||||
String? password}) =>
|
||||
WalletCredentials createWowneroNewWalletCredentials(
|
||||
{required String name,
|
||||
required String language,
|
||||
required bool isPolyseed,
|
||||
String? password}) =>
|
||||
WowneroNewWalletCredentials(
|
||||
name: name, password: password, language: language, isPolyseed: isPolyseed);
|
||||
name: name, password: password, language: language, isPolyseed: isPolyseed);
|
||||
|
||||
@override
|
||||
Map<String, String> getKeys(Object wallet) {
|
||||
|
|
|
@ -594,6 +594,7 @@
|
|||
"seedtype": "Seedtype",
|
||||
"seedtype_legacy": "Legacy (25 words)",
|
||||
"seedtype_polyseed": "Polyseed (16 words)",
|
||||
"seedtype_wownero": "Wownero (14 words)",
|
||||
"select_backup_file": "Select backup file",
|
||||
"select_buy_provider_notice": "Select a buy provider above. You can skip this screen by setting your default buy provider in app settings.",
|
||||
"select_destination": "Please select destination for the backup file.",
|
||||
|
|
Loading…
Reference in a new issue