diff --git a/CMakeLists.txt b/CMakeLists.txt index e6f30be..b5d465b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/src/CoinsWidget.cpp b/src/CoinsWidget.cpp index 2a97294..767c4bc 100644 --- a/src/CoinsWidget.cpp +++ b/src/CoinsWidget.cpp @@ -51,8 +51,8 @@ CoinsWidget::CoinsWidget(QSharedPointer 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 indexes = {m_proxyModel->mapToSource(index).row()}; - this->freezeCoins(indexes); +QStringList CoinsWidget::selectedPubkeys() { + QModelIndexList list = ui->coins->selectionModel()->selectedRows(); + + QStringList pubkeys; + for (QModelIndex index: list) { + pubkeys << m_model->entryFromIndex(m_proxyModel->mapToSource(index))->pubKey(); + } + return pubkeys; } void CoinsWidget::freezeAllSelected() { - QModelIndexList list = ui->coins->selectionModel()->selectedRows(); - - QVector indexes; - for (QModelIndex index: list) { - indexes.push_back(m_proxyModel->mapToSource(index).row()); // todo: will segfault if index get invalidated - } - this->freezeCoins(indexes); -} - -void CoinsWidget::thawOutput() { - QModelIndex index = ui->coins->currentIndex(); - QVector indexes = {m_proxyModel->mapToSource(index).row()}; - this->thawCoins(indexes); + QStringList pubkeys = this->selectedPubkeys(); + this->freezeCoins(pubkeys); } void CoinsWidget::thawAllSelected() { - QModelIndexList list = ui->coins->selectionModel()->selectedRows(); - - QVector 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 CoinsWidget::currentEntries() { return selectedCoins; } -void CoinsWidget::freezeCoins(const QVector& 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 &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(); diff --git a/src/CoinsWidget.h b/src/CoinsWidget.h index 90cbb53..6c48e24 100644 --- a/src/CoinsWidget.h +++ b/src/CoinsWidget.h @@ -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& indexes); - void thawCoins(const QVector& 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 currentEntries(); + QStringList selectedPubkeys(); }; diff --git a/src/libwalletqt/Coins.cpp b/src/libwalletqt/Coins.cpp index ac49d27..b95d4f7 100644 --- a/src/libwalletqt/Coins.cpp +++ b/src/libwalletqt/Coins.cpp @@ -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(); } diff --git a/src/libwalletqt/Coins.h b/src/libwalletqt/Coins.h index 1813cb0..7c73af3 100644 --- a/src/libwalletqt/Coins.h +++ b/src/libwalletqt/Coins.h @@ -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 coins_from_txid(const QString &txid); Q_INVOKABLE void setDescription(int index, quint32 accountIndex, const QString &description);