Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ abstract class SWB {
mnemonic: mnemonic,
mnemonicPassphrase: mnemonicPassphrase,
);

Wallet? wallet;
try {
String? serializedKeys;
String? multisigConfig;
Expand Down Expand Up @@ -491,7 +491,7 @@ abstract class SWB {
});
}

final wallet = await Wallet.create(
wallet = await Wallet.create(
walletInfo: info,
mainDB: MainDB.instance,
secureStorageInterface: secureStorageInterface,
Expand Down Expand Up @@ -614,6 +614,8 @@ abstract class SWB {
mnemonicPassphrase: mnemonicPassphrase,
);
return false;
} finally {
await wallet?.exit();
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,9 +316,10 @@ class _WalletSettingsViewState extends ConsumerState<WalletSettingsView> {
if (wallet is MnemonicInterface) {
if (wallet
is ViewOnlyOptionInterface &&
!(wallet
as ViewOnlyOptionInterface)
(wallet as ViewOnlyOptionInterface)
.isViewOnly) {
// TODO: is something needed here?
} else {
mnemonic = await wallet
.getMnemonicAsWords();
}
Expand Down
26 changes: 20 additions & 6 deletions lib/wallets/wallet/impl/bitcoin_frost_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,26 @@ class BitcoinFrostWallet<T extends FrostCurrency> extends Wallet<T>
await mainDB.isar.frostWalletInfo.put(frostWalletInfo);
});

final address = await _generateAddress(
change: 0,
index: kFrostSecureStartingIndex,
serializedKeys: serializedKeys,
secure: true,
);
Address? address;
int index = kFrostSecureStartingIndex;
while (address == null) {
try {
address = await _generateAddress(
change: 0,
index: index,
serializedKeys: serializedKeys,
secure: true,
);
} on FrostdartException catch (e) {
if (e.errorCode == 72) {
// rust doesn't like the addressDerivationData
index++;
continue;
} else {
rethrow;
}
}
}

await mainDB.putAddresses([address]);
} catch (e, s) {
Expand Down
14 changes: 8 additions & 6 deletions lib/wallets/wallet/impl/epiccash_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,7 @@ class EpiccashWallet extends Bip39Wallet {
isar: mainDB.isar,
);

unawaited(_startScans());
unawaited(refresh(doScan: true));
} else {
await updateNode();
final String password = generatePassword();
Expand Down Expand Up @@ -759,9 +759,8 @@ class EpiccashWallet extends Bip39Wallet {
epicData.receivingIndex,
);
}
unawaited(refresh(doScan: false));
});

unawaited(refresh());
} catch (e, s) {
Logging.instance.log(
"Exception rethrown from electrumx_mixin recover(): $e\n$s",
Expand All @@ -773,7 +772,7 @@ class EpiccashWallet extends Bip39Wallet {
}

@override
Future<void> refresh() async {
Future<void> refresh({bool doScan = true}) async {
// Awaiting this lock could be dangerous.
// Since refresh is periodic (generally)
if (refreshMutex.isLocked) {
Expand Down Expand Up @@ -803,9 +802,11 @@ class EpiccashWallet extends Bip39Wallet {
final int curAdd = await _getCurrentIndex();
await _generateAndStoreReceivingAddressForIndex(curAdd);

await _startScans();
if (doScan) {
await _startScans();

unawaited(_startSync());
unawaited(_startSync());
}

GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.0, walletId));
await updateChainHeight();
Expand Down Expand Up @@ -1157,6 +1158,7 @@ class EpiccashWallet extends Bip39Wallet {

@override
Future<void> exit() async {
epiccash.LibEpiccash.stopEpicboxListener();
timer?.cancel();
timer = null;
await super.exit();
Expand Down
29 changes: 22 additions & 7 deletions lib/wallets/wallet/impl/monero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,28 @@ class MoneroWallet extends LibMoneroWallet {
Future<lib_monero.Wallet> getCreatedWallet({
required String path,
required String password,
}) async =>
await lib_monero.MoneroWallet.create(
path: path,
password: password,
seedType: lib_monero.MoneroSeedType
.sixteen, // TODO: check we want to actually use 16 here
);
required int wordCount,
}) async {
final lib_monero.MoneroSeedType type;
switch (wordCount) {
case 16:
type = lib_monero.MoneroSeedType.sixteen;
break;

case 25:
type = lib_monero.MoneroSeedType.twentyFive;
break;

default:
throw Exception("Invalid mnemonic word count: $wordCount");
}

return await lib_monero.MoneroWallet.create(
path: path,
password: password,
seedType: type,
);
}

@override
Future<lib_monero.Wallet> getRestoredWallet({
Expand Down
35 changes: 27 additions & 8 deletions lib/wallets/wallet/impl/wownero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,33 @@ class WowneroWallet extends LibMoneroWallet {
Future<lib_monero.Wallet> getCreatedWallet({
required String path,
required String password,
}) async =>
await lib_monero.WowneroWallet.create(
path: path,
password: password,
seedType: lib_monero.WowneroSeedType
.fourteen, // TODO: check we want to actually use 14 here
overrideDeprecated14WordSeedException: true,
);
required int wordCount,
}) async {
final lib_monero.WowneroSeedType type;
switch (wordCount) {
case 14:
type = lib_monero.WowneroSeedType.fourteen;
break;

case 16:
type = lib_monero.WowneroSeedType.sixteen;
break;

case 25:
type = lib_monero.WowneroSeedType.twentyFive;
break;

default:
throw Exception("Invalid mnemonic word count: $wordCount");
}

return await lib_monero.WowneroWallet.create(
path: path,
password: password,
seedType: type,
overrideDeprecated14WordSeedException: true,
);
}

@override
Future<lib_monero.Wallet> getRestoredWallet({
Expand Down
12 changes: 10 additions & 2 deletions lib/wallets/wallet/intermediate/lib_monero_wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
Future<lib_monero.Wallet> getCreatedWallet({
required String path,
required String password,
required int wordCount,
});

Future<lib_monero.Wallet> getRestoredWallet({
Expand Down Expand Up @@ -313,19 +314,26 @@ abstract class LibMoneroWallet<T extends CryptonoteCurrency>
}

@override
Future<void> init({bool? isRestore}) async {
Future<void> init({bool? isRestore, int? wordCount}) async {
final path = await pathForWallet(
name: walletId,
type: compatType,
);
if (!(walletExists(path)) && isRestore != true) {
if (wordCount == null) {
throw Exception("Missing word count for new xmr/wow wallet!");
}
try {
final password = generatePassword();
await secureStorageInterface.write(
key: lib_monero_compat.libMoneroWalletPasswordKey(walletId),
value: password,
);
final wallet = await getCreatedWallet(path: path, password: password);
final wallet = await getCreatedWallet(
path: path,
password: password,
wordCount: wordCount,
);

final height = wallet.getRefreshFromBlockHeight();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
android:requestLegacyExternalStorage="true"
android:icon="@mipmap/ic_launcher"
android:allowBackup="false"
android:fullBackupContent="false"
android:extractNativeLibs="true">
android:fullBackupContent="false">
<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
Expand Down
Loading