Update logic behind import/export keyimages/outputs

This commit is contained in:
Czarek Nakamoto 2025-01-02 16:08:22 +01:00
parent 2e4c5c4470
commit b722d2180c
4 changed files with 13 additions and 7 deletions

View file

@ -252,6 +252,7 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
final err = monero.Wallet_errorString(wptr!);
throw Exception("unable to import key images: $err");
}
monero.Wallet_store(wptr!);
return retStatus;
}
@ -265,11 +266,12 @@ abstract class MoneroWalletBase extends WalletBase<MoneroBalance,
return str;
}
bool needExportOutputs(int? amount) {
bool needExportOutputs(int amount) {
// printV("viewOnlyBalance: ${monero.Wallet_viewOnlyBalance(wptr!, accountIndex: walletAddresses.account!.id)}");
// printV(" balance: ${monero.Wallet_balance(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)));
accountIndex: walletAddresses.account!.id) < amount);
}
@override

View file

@ -392,7 +392,7 @@ class CWMonero extends Monero {
}
@override
bool needExportOutputs(Object wallet, int? amount) {
bool needExportOutputs(Object wallet, int amount) {
final moneroWallet = wallet as MoneroWallet;
return moneroWallet.needExportOutputs(amount);
}

View file

@ -414,10 +414,14 @@ class SendPage extends BasePage {
}
if (sendViewModel.wallet.type == WalletType.monero) {
if (monero!.needExportOutputs(sendViewModel.wallet, null)) {
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');
}
if (monero!.needExportOutputs(sendViewModel.wallet, null)) {
if (monero!.needExportOutputs(sendViewModel.wallet, amount)) {
throw Exception("You need to export outputs first");
}
}

View file

@ -387,7 +387,7 @@ abstract class Monero {
String exportOutputsUR(Object wallet, bool all);
bool needExportOutputs(Object wallet, int? amount);
bool needExportOutputs(Object wallet, int amount);
bool importKeyImagesUR(Object wallet, String ur);