mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
avoid checkReceivingAddressForTransactions altogether when reuse is set
This commit is contained in:
parent
4f40572366
commit
bb7f0ff46f
4 changed files with 43 additions and 15 deletions
|
@ -787,7 +787,9 @@ class FiroWallet<T extends ElectrumXCurrencyInterface> extends Bip39HDWallet<T>
|
|||
|
||||
for (final tuple in receiveResults) {
|
||||
if (tuple.addresses.isEmpty) {
|
||||
await checkReceivingAddressForTransactions();
|
||||
if (info.otherData[WalletInfoKeys.reuseAddress] != true) {
|
||||
await checkReceivingAddressForTransactions();
|
||||
}
|
||||
} else {
|
||||
highestReceivingIndexWithHistory = max(
|
||||
tuple.index,
|
||||
|
|
|
@ -522,8 +522,10 @@ abstract class Wallet<T extends CryptoCurrency> {
|
|||
|
||||
// TODO: [prio=low] handle this differently. Extra modification of this file for coin specific functionality should be avoided.
|
||||
if (this is MultiAddressInterface) {
|
||||
await (this as MultiAddressInterface)
|
||||
.checkReceivingAddressForTransactions();
|
||||
if (info.otherData[WalletInfoKeys.reuseAddress] != true) {
|
||||
await (this as MultiAddressInterface)
|
||||
.checkReceivingAddressForTransactions();
|
||||
}
|
||||
}
|
||||
|
||||
GlobalEventBus.instance.fire(RefreshPercentChangedEvent(0.2, walletId));
|
||||
|
|
|
@ -25,6 +25,7 @@ import '../../../utilities/amount/amount.dart';
|
|||
import '../../../utilities/logger.dart';
|
||||
import '../../../utilities/stack_file_system.dart';
|
||||
import '../../crypto_currency/intermediate/cryptonote_currency.dart';
|
||||
import '../../isar/models/wallet_info.dart';
|
||||
import '../intermediate/cryptonote_wallet.dart';
|
||||
import 'multi_address_interface.dart';
|
||||
|
||||
|
@ -286,7 +287,9 @@ mixin CwBasedInterface<T extends CryptonoteCurrency> on CryptonoteWallet<T>
|
|||
await updateTransactions();
|
||||
await updateBalance();
|
||||
|
||||
await checkReceivingAddressForTransactions();
|
||||
if (info.otherData[WalletInfoKeys.reuseAddress] != true) {
|
||||
await checkReceivingAddressForTransactions();
|
||||
}
|
||||
|
||||
if (cwWalletBase?.syncStatus is SyncedSyncStatus) {
|
||||
refreshMutex.release();
|
||||
|
@ -342,6 +345,17 @@ mixin CwBasedInterface<T extends CryptonoteCurrency> on CryptonoteWallet<T>
|
|||
|
||||
@override
|
||||
Future<void> checkReceivingAddressForTransactions() async {
|
||||
if (info.otherData[WalletInfoKeys.reuseAddress] == true) {
|
||||
try {
|
||||
throw Exception();
|
||||
} catch (_, s) {
|
||||
Logging.instance.log(
|
||||
"checkReceivingAddressForTransactions called but reuse address flag set: $s",
|
||||
level: LogLevel.Error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
int highestIndex = -1;
|
||||
final entries = cwWalletBase?.transactionHistory?.transactions?.entries;
|
||||
|
@ -380,8 +394,10 @@ mixin CwBasedInterface<T extends CryptonoteCurrency> on CryptonoteWallet<T>
|
|||
// we need to update the address
|
||||
await mainDB.updateAddress(existing, newReceivingAddress);
|
||||
}
|
||||
// keep checking until address with no tx history is set as current
|
||||
await checkReceivingAddressForTransactions();
|
||||
if (info.otherData[WalletInfoKeys.reuseAddress] != true) {
|
||||
// keep checking until address with no tx history is set as current
|
||||
await checkReceivingAddressForTransactions();
|
||||
}
|
||||
}
|
||||
} on SocketException catch (se, s) {
|
||||
Logging.instance.log(
|
||||
|
|
|
@ -1316,6 +1316,17 @@ mixin ElectrumXInterface<T extends ElectrumXCurrencyInterface>
|
|||
|
||||
@override
|
||||
Future<void> checkReceivingAddressForTransactions() async {
|
||||
if (info.otherData[WalletInfoKeys.reuseAddress] == true) {
|
||||
try {
|
||||
throw Exception();
|
||||
} catch (_, s) {
|
||||
Logging.instance.log(
|
||||
"checkReceivingAddressForTransactions called but reuse address flag set: $s",
|
||||
level: LogLevel.Error,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
final currentReceiving = await getCurrentReceivingAddress();
|
||||
|
||||
|
@ -1334,18 +1345,15 @@ mixin ElectrumXInterface<T extends ElectrumXCurrencyInterface>
|
|||
needsGenerate = txCount > 0 || currentReceiving.derivationIndex < 0;
|
||||
}
|
||||
|
||||
// TODO this in the wrong place
|
||||
// If reuseAddress is set, don't generate an address by default.
|
||||
if (info.otherData[WalletInfoKeys.reuseAddress] as bool? ?? false) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (needsGenerate) {
|
||||
await generateNewReceivingAddress();
|
||||
|
||||
// TODO: get rid of this? Could cause problems (long loading/infinite loop or something)
|
||||
// keep checking until address with no tx history is set as current
|
||||
await checkReceivingAddressForTransactions();
|
||||
// TODO: [prio=low] Make sure we scan all addresses but only show one.
|
||||
if (info.otherData[WalletInfoKeys.reuseAddress] != true) {
|
||||
// TODO: get rid of this? Could cause problems (long loading/infinite loop or something)
|
||||
// keep checking until address with no tx history is set as current
|
||||
await checkReceivingAddressForTransactions();
|
||||
}
|
||||
}
|
||||
} catch (e, s) {
|
||||
Logging.instance.log(
|
||||
|
|
Loading…
Reference in a new issue