mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-03-12 09:32:33 +00:00
CW-873 automatically export outputs (#1885)
* automatically export outputs * remove print statements * update configure script * Update logic behind import/export keyimages/outputs * discussed changes * replace store with just waiting for the wallet to update it's state
This commit is contained in:
parent
e64b87a1b0
commit
da9c309805
5 changed files with 35 additions and 2 deletions
|
@ -126,8 +126,10 @@ Future<bool> setupNodeSync(
|
|||
|
||||
if (status != 0) {
|
||||
final error = monero.Wallet_errorString(wptr!);
|
||||
printV("error: $error");
|
||||
throw SetupWalletException(message: error);
|
||||
if (error != "no tx keys found for this txid") {
|
||||
printV("error: $error");
|
||||
throw SetupWalletException(message: error);
|
||||
}
|
||||
}
|
||||
|
||||
if (kDebugMode) {
|
||||
|
|
|
@ -265,6 +265,14 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
|
|||
return str;
|
||||
}
|
||||
|
||||
bool needExportOutputs(int amount) {
|
||||
// viewOnlyBalance - balance that we can spend
|
||||
// TODO(mrcyjanek): remove hasUnknownKeyImages when we cleanup coin control
|
||||
return (monero.Wallet_viewOnlyBalance(wptr!,
|
||||
accountIndex: walletAddresses.account!.id) < amount) ||
|
||||
monero.Wallet_hasUnknownKeyImages(wptr!);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PendingTransaction> createTransaction(Object credentials) async {
|
||||
final _credentials = credentials as MoneroTransactionCreationCredentials;
|
||||
|
|
|
@ -391,6 +391,12 @@ class CWMonero extends Monero {
|
|||
return moneroWallet.exportOutputsUR(all);
|
||||
}
|
||||
|
||||
@override
|
||||
bool needExportOutputs(Object wallet, int amount) {
|
||||
final moneroWallet = wallet as MoneroWallet;
|
||||
return moneroWallet.needExportOutputs(amount);
|
||||
}
|
||||
|
||||
@override
|
||||
void monerocCheck() {
|
||||
checkIfMoneroCIsFine();
|
||||
|
|
|
@ -4,6 +4,7 @@ import 'package:cake_wallet/entities/contact_record.dart';
|
|||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cake_wallet/entities/fiat_currency.dart';
|
||||
import 'package:cake_wallet/entities/template.dart';
|
||||
import 'package:cake_wallet/monero/monero.dart';
|
||||
import 'package:cake_wallet/reactions/wallet_connect.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
|
@ -412,6 +413,20 @@ class SendPage extends BasePage {
|
|||
}
|
||||
}
|
||||
|
||||
if (sendViewModel.wallet.type == WalletType.monero) {
|
||||
int amount = 0;
|
||||
for (var item in sendViewModel.outputs) {
|
||||
amount += item.formattedCryptoAmount;
|
||||
}
|
||||
if (monero!.needExportOutputs(sendViewModel.wallet, amount)) {
|
||||
await Navigator.of(context).pushNamed(Routes.urqrAnimatedPage, arguments: 'export-outputs');
|
||||
await Future.delayed(Duration(seconds: 1)); // wait for monero to refresh the state
|
||||
}
|
||||
if (monero!.needExportOutputs(sendViewModel.wallet, amount)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final check = sendViewModel.shouldDisplayTotp();
|
||||
authService.authenticateAction(
|
||||
context,
|
||||
|
|
|
@ -387,6 +387,8 @@ abstract class Monero {
|
|||
|
||||
String exportOutputsUR(Object wallet, bool all);
|
||||
|
||||
bool needExportOutputs(Object wallet, int amount);
|
||||
|
||||
bool importKeyImagesUR(Object wallet, String ur);
|
||||
|
||||
WalletCredentials createMoneroRestoreWalletFromKeysCredentials({
|
||||
|
|
Loading…
Reference in a new issue