coins: don't refresh for each freeze/thaw
Some checks are pending
ci/gh-actions/build / build-ubuntu-without-scanner (push) Waiting to run
ci/gh-actions/guix / cache-sources (push) Waiting to run
ci/gh-actions/guix / aarch64-linux-gnu (push) Blocked by required conditions
ci/gh-actions/guix / arm-linux-gnueabihf (push) Blocked by required conditions
ci/gh-actions/guix / arm64-apple-darwin (push) Blocked by required conditions
ci/gh-actions/guix / i686-linux-gnu (push) Blocked by required conditions
ci/gh-actions/guix / riscv64-linux-gnu (push) Blocked by required conditions
ci/gh-actions/guix / x86_64-apple-darwin (push) Blocked by required conditions
ci/gh-actions/guix / x86_64-linux-gnu.no-tor-bundle (push) Blocked by required conditions
ci/gh-actions/guix / x86_64-linux-gnu.pack (push) Blocked by required conditions
ci/gh-actions/guix / x86_64-linux-gnu (push) Blocked by required conditions
ci/gh-actions/guix / x86_64-w64-mingw32.installer (push) Blocked by required conditions
ci/gh-actions/guix / x86_64-w64-mingw32 (push) Blocked by required conditions
ci/gh-actions/guix / bundle-logs (push) Blocked by required conditions

This commit is contained in:
tobtoht 2024-10-10 14:22:47 +02:00
parent 796d4dd3f0
commit fdc7a09c6c
No known key found for this signature in database
GPG key ID: E45B10DD027D2472
4 changed files with 43 additions and 45 deletions

View file

@ -324,18 +324,12 @@ QVector<CoinsInfo*> CoinsWidget::currentEntries() {
} }
void CoinsWidget::freezeCoins(QStringList &pubkeys) { void CoinsWidget::freezeCoins(QStringList &pubkeys) {
for (auto &pubkey : pubkeys) { m_wallet->coins()->freeze(pubkeys);
m_wallet->coins()->freeze(pubkey);
}
m_wallet->coins()->refresh();
m_wallet->updateBalance(); m_wallet->updateBalance();
} }
void CoinsWidget::thawCoins(QStringList &pubkeys) { void CoinsWidget::thawCoins(QStringList &pubkeys) {
for (auto &pubkey : pubkeys) { m_wallet->coins()->thaw(pubkeys);
m_wallet->coins()->thaw(pubkey);
}
m_wallet->coins()->refresh();
m_wallet->updateBalance(); m_wallet->updateBalance();
} }

View file

@ -49,7 +49,7 @@ public slots:
void disallowSending(); void disallowSending();
private slots: private slots:
void onDataPasted(const QString &data); void onDataFromQR(const QString &data);
private: private:
void setupComboBox(); void setupComboBox();

View file

@ -105,48 +105,52 @@ quint64 Coins::count() const
return m_rows.length(); return m_rows.length();
} }
void Coins::freeze(QString &publicKey) void Coins::freeze(QStringList &publicKeys)
{ {
crypto::public_key pk; crypto::public_key pk;
for (const auto& publicKey : publicKeys) {
if (!epee::string_tools::hex_to_pod(publicKey.toStdString(), pk)) if (!epee::string_tools::hex_to_pod(publicKey.toStdString(), pk))
{ {
qWarning() << "Invalid public key: " << publicKey; qWarning() << "Invalid public key: " << publicKey;
return; continue;
} }
try try
{ {
m_wallet2->freeze(pk); m_wallet2->freeze(pk);
refresh();
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
qWarning() << "freeze: " << e.what(); qWarning() << "freeze: " << e.what();
} }
emit coinFrozen();
} }
void Coins::thaw(QString &publicKey) refresh();
}
void Coins::thaw(QStringList &publicKeys)
{ {
crypto::public_key pk; crypto::public_key pk;
for (const auto& publicKey : publicKeys) {
if (!epee::string_tools::hex_to_pod(publicKey.toStdString(), pk)) if (!epee::string_tools::hex_to_pod(publicKey.toStdString(), pk))
{ {
qWarning() << "Invalid public key: " << publicKey; qWarning() << "Invalid public key: " << publicKey;
return; continue;
} }
try try
{ {
m_wallet2->thaw(pk); m_wallet2->thaw(pk);
refresh();
} }
catch (const std::exception& e) catch (const std::exception& e)
{ {
qWarning() << "thaw: " << e.what(); qWarning() << "thaw: " << e.what();
} }
}
emit coinThawed(); refresh();
} }
QVector<CoinsInfo*> Coins::coins_from_txid(const QString &txid) QVector<CoinsInfo*> Coins::coins_from_txid(const QString &txid)

View file

@ -31,8 +31,10 @@ public:
CoinsInfo * coin(int index); CoinsInfo * coin(int index);
void refresh(); void refresh();
void refreshUnlocked(); void refreshUnlocked();
void freeze(QString &publicKey);
void thaw(QString &publicKey); void freeze(QStringList &publicKeys);
void thaw(QStringList &publicKeys);
QVector<CoinsInfo*> coins_from_txid(const QString &txid); QVector<CoinsInfo*> coins_from_txid(const QString &txid);
QVector<CoinsInfo*> coinsFromKeyImage(const QStringList &keyimages); QVector<CoinsInfo*> coinsFromKeyImage(const QStringList &keyimages);
void setDescription(const QString &publicKey, quint32 accountIndex, const QString &description); void setDescription(const QString &publicKey, quint32 accountIndex, const QString &description);
@ -43,8 +45,6 @@ public:
signals: signals:
void refreshStarted() const; void refreshStarted() const;
void refreshFinished() const; void refreshFinished() const;
void coinFrozen() const;
void coinThawed() const;
void descriptionChanged() const; void descriptionChanged() const;
private: private: