automatically export outputs

This commit is contained in:
Czarek Nakamoto 2024-12-16 07:30:57 -05:00
parent ae80fb3b55
commit 9a45915b0c
5 changed files with 31 additions and 2 deletions

View file

@ -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) {

View file

@ -265,6 +265,15 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
return str;
}
bool needExportOutputs(int? amount) {
print("monero.Wallet_hasUnknownKeyImages(wptr!): ${monero.Wallet_hasUnknownKeyImages(wptr!)}");
print("monero.Wallet_viewOnlyBalance(wptr!, accountIndex: walletAddresses.account!.id): ${monero.Wallet_viewOnlyBalance(wptr!, accountIndex: walletAddresses.account!.id)}");
return monero.Wallet_hasUnknownKeyImages(wptr!) ||
(monero.Wallet_viewOnlyBalance(wptr!,
accountIndex: walletAddresses.account!.id) <
(amount ?? monero.Wallet_balance(wptr!, accountIndex: walletAddresses.account!.id)));
}
@override
Future<PendingTransaction> createTransaction(Object credentials) async {
final _credentials = credentials as MoneroTransactionCreationCredentials;

View file

@ -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();

View file

@ -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,15 @@ class SendPage extends BasePage {
}
}
if (sendViewModel.wallet.type == WalletType.monero) {
if (monero!.needExportOutputs(sendViewModel.wallet, null)) {
await Navigator.of(context).pushNamed(Routes.urqrAnimatedPage, arguments: 'export-outputs');
}
if (monero!.needExportOutputs(sendViewModel.wallet, null)) {
throw Exception("You need to export outputs first");
}
}
final check = sendViewModel.shouldDisplayTotp();
authService.authenticateAction(
context,

View file

@ -387,6 +387,8 @@ abstract class Monero {
String exportOutputsUR(Object wallet, bool all);
bool needExportOutputs(Object wallet);
bool importKeyImagesUR(Object wallet, String ur);
WalletCredentials createMoneroRestoreWalletFromKeysCredentials({