]> Nutra Git (v2) - gamesguru/feather.git/commitdiff
Coins: freeze/thaw based on pubkey
authortobtoht <thotbot@protonmail.com>
Fri, 1 Oct 2021 13:37:20 +0000 (15:37 +0200)
committertobtoht <thotbot@protonmail.com>
Fri, 1 Oct 2021 13:37:20 +0000 (15:37 +0200)
CMakeLists.txt
src/CoinsWidget.cpp
src/CoinsWidget.h
src/libwalletqt/Coins.cpp
src/libwalletqt/Coins.h

index e6f30be672f54e883aeeaaa8c3de41b3c683308b..b5d465b90a0dccdf3358ab3f722d8e15acc5fd34 100644 (file)
@@ -32,7 +32,7 @@ if(DEBUG)
     set(CMAKE_VERBOSE_MAKEFILE ON)
 endif()
 
-set(MONERO_HEAD "d4257af2e7503fc6dc09fc704606230d353a0a02")
+set(MONERO_HEAD "ed8859318349a5f01e9fd90e898603d4142b0951")
 set(BUILD_GUI_DEPS ON)
 option(ARCH "Target architecture" "x86-64")
 set(BUILD_64 ON)
index 2a972943e110ff011b00e5ea1a1438f97cfb6bfd..767c4bc5ab2122a1bf044e2f5c50b5e3d2b46574 100644 (file)
@@ -51,8 +51,8 @@ CoinsWidget::CoinsWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
     m_sweepOutputAction = new QAction("Sweep output", this);
     m_sweepOutputsAction = new QAction("Sweep selected outputs", this);
 
-    connect(m_freezeOutputAction, &QAction::triggered, this, &CoinsWidget::freezeOutput);
-    connect(m_thawOutputAction, &QAction::triggered, this, &CoinsWidget::thawOutput);
+    connect(m_freezeOutputAction, &QAction::triggered, this, &CoinsWidget::freezeAllSelected);
+    connect(m_thawOutputAction, &QAction::triggered, this, &CoinsWidget::thawAllSelected);
     connect(m_viewOutputAction, &QAction::triggered, this, &CoinsWidget::viewOutput);
     connect(m_sweepOutputAction, &QAction::triggered, this, &CoinsWidget::onSweepOutputs);
     connect(m_sweepOutputsAction, &QAction::triggered, this, &CoinsWidget::onSweepOutputs);
@@ -155,36 +155,24 @@ void CoinsWidget::setSearchFilter(const QString &filter) {
     m_proxyModel->setSearchFilter(filter);
 }
 
-void CoinsWidget::freezeOutput() {
-    QModelIndex index = ui->coins->currentIndex();
-    QVector<int> indexes = {m_proxyModel->mapToSource(index).row()};
-    this->freezeCoins(indexes);
-}
-
-void CoinsWidget::freezeAllSelected() {
+QStringList CoinsWidget::selectedPubkeys() {
     QModelIndexList list = ui->coins->selectionModel()->selectedRows();
 
-    QVector<int> indexes;
+    QStringList pubkeys;
     for (QModelIndex index: list) {
-        indexes.push_back(m_proxyModel->mapToSource(index).row()); // todo: will segfault if index get invalidated
+        pubkeys << m_model->entryFromIndex(m_proxyModel->mapToSource(index))->pubKey();
     }
-    this->freezeCoins(indexes);
+    return pubkeys;
 }
 
-void CoinsWidget::thawOutput() {
-    QModelIndex index = ui->coins->currentIndex();
-    QVector<int> indexes = {m_proxyModel->mapToSource(index).row()};
-    this->thawCoins(indexes);
+void CoinsWidget::freezeAllSelected() {
+    QStringList pubkeys = this->selectedPubkeys();
+    this->freezeCoins(pubkeys);
 }
 
 void CoinsWidget::thawAllSelected() {
-    QModelIndexList list = ui->coins->selectionModel()->selectedRows();
-
-    QVector<int> indexes;
-    for (QModelIndex index: list) {
-        indexes.push_back(m_proxyModel->mapToSource(index).row());
-    }
-    this->thawCoins(indexes);
+    QStringList pubkeys = this->selectedPubkeys();
+    this->thawCoins(pubkeys);
 }
 
 void CoinsWidget::viewOutput() {
@@ -291,17 +279,17 @@ QVector<CoinsInfo*> CoinsWidget::currentEntries() {
     return selectedCoins;
 }
 
-void CoinsWidget::freezeCoins(const QVector<int>& indexes) {
-    for (int i : indexes) {
-        m_ctx->wallet->coins()->freeze(i);
+void CoinsWidget::freezeCoins(QStringList &pubkeys) {
+    for (auto &pubkey : pubkeys) {
+        m_ctx->wallet->coins()->freeze(pubkey);
     }
     m_ctx->wallet->coins()->refresh(m_ctx->wallet->currentSubaddressAccount());
     m_ctx->updateBalance();
 }
 
-void CoinsWidget::thawCoins(const QVector<int> &indexes) {
-    for (int i : indexes) {
-        m_ctx->wallet->coins()->thaw(i);
+void CoinsWidget::thawCoins(QStringList &pubkeys) {
+    for (auto &pubkey : pubkeys) {
+        m_ctx->wallet->coins()->thaw(pubkey);
     }
     m_ctx->wallet->coins()->refresh(m_ctx->wallet->currentSubaddressAccount());
     m_ctx->updateBalance();
index 90cbb53412fa6c48c4e5b3afc3a5373a0a5d1145..6c48e24c66a4c0b58eda54f5d0680793f4b068b8 100644 (file)
@@ -33,9 +33,7 @@ public slots:
 private slots:
     void showHeaderMenu(const QPoint& position);
     void setShowSpent(bool show);
-    void freezeOutput();
     void freezeAllSelected();
-    void thawOutput();
     void thawAllSelected();
     void viewOutput();
     void onSweepOutputs();
@@ -43,8 +41,8 @@ private slots:
     void editLabel();
 
 private:
-    void freezeCoins(const QVector<int>& indexes);
-    void thawCoins(const QVector<int>& indexes);
+    void freezeCoins(QStringList &pubkeys);
+    void thawCoins(QStringList &pubkeys);
 
     enum copyField {
         PubKey = 0,
@@ -79,6 +77,7 @@ private:
     void copy(copyField field);
     CoinsInfo* currentEntry();
     QVector<CoinsInfo*> currentEntries();
+    QStringList selectedPubkeys();
 };
 
 
index ac49d272ffdfc63ee0834cee81219a53d8acb724..b95d4f7c95333afaa0cb5364536105cd8614d1b0 100644 (file)
@@ -71,15 +71,15 @@ quint64 Coins::count() const
     return m_tinfo.count();
 }
 
-void Coins::freeze(int index) const
+void Coins::freeze(QString &publicKey) const
 {
-    m_pimpl->setFrozen(index);
+    m_pimpl->setFrozen(publicKey.toStdString());
     emit coinFrozen();
 }
 
-void Coins::thaw(int index) const
+void Coins::thaw(QString &publicKey) const
 {
-    m_pimpl->thaw(index);
+    m_pimpl->thaw(publicKey.toStdString());
     emit coinThawed();
 }
 
index 1813cb05364ee7bc42f4f97b99122930b198487f..7c73af358cf837b786b13ca05f4fe7405048e404 100644 (file)
@@ -28,8 +28,8 @@ public:
     Q_INVOKABLE CoinsInfo * coin(int index);
     Q_INVOKABLE void refresh(quint32 accountIndex);
     Q_INVOKABLE void refreshUnlocked();
-    Q_INVOKABLE void freeze(int index) const;
-    Q_INVOKABLE void thaw(int index) const;
+    Q_INVOKABLE void freeze(QString &publicKey) const;
+    Q_INVOKABLE void thaw(QString &publicKey) const;
     Q_INVOKABLE QVector<CoinsInfo*> coins_from_txid(const QString &txid);
     Q_INVOKABLE void setDescription(int index, quint32 accountIndex, const QString &description);