mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-31 16:09:56 +00:00
Coins: freeze/thaw based on pubkey
This commit is contained in:
parent
2ae4f7d757
commit
3767e736c2
5 changed files with 30 additions and 43 deletions
|
@ -32,7 +32,7 @@ if(DEBUG)
|
||||||
set(CMAKE_VERBOSE_MAKEFILE ON)
|
set(CMAKE_VERBOSE_MAKEFILE ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(MONERO_HEAD "d4257af2e7503fc6dc09fc704606230d353a0a02")
|
set(MONERO_HEAD "ed8859318349a5f01e9fd90e898603d4142b0951")
|
||||||
set(BUILD_GUI_DEPS ON)
|
set(BUILD_GUI_DEPS ON)
|
||||||
option(ARCH "Target architecture" "x86-64")
|
option(ARCH "Target architecture" "x86-64")
|
||||||
set(BUILD_64 ON)
|
set(BUILD_64 ON)
|
||||||
|
|
|
@ -51,8 +51,8 @@ CoinsWidget::CoinsWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
|
||||||
m_sweepOutputAction = new QAction("Sweep output", this);
|
m_sweepOutputAction = new QAction("Sweep output", this);
|
||||||
m_sweepOutputsAction = new QAction("Sweep selected outputs", this);
|
m_sweepOutputsAction = new QAction("Sweep selected outputs", this);
|
||||||
|
|
||||||
connect(m_freezeOutputAction, &QAction::triggered, this, &CoinsWidget::freezeOutput);
|
connect(m_freezeOutputAction, &QAction::triggered, this, &CoinsWidget::freezeAllSelected);
|
||||||
connect(m_thawOutputAction, &QAction::triggered, this, &CoinsWidget::thawOutput);
|
connect(m_thawOutputAction, &QAction::triggered, this, &CoinsWidget::thawAllSelected);
|
||||||
connect(m_viewOutputAction, &QAction::triggered, this, &CoinsWidget::viewOutput);
|
connect(m_viewOutputAction, &QAction::triggered, this, &CoinsWidget::viewOutput);
|
||||||
connect(m_sweepOutputAction, &QAction::triggered, this, &CoinsWidget::onSweepOutputs);
|
connect(m_sweepOutputAction, &QAction::triggered, this, &CoinsWidget::onSweepOutputs);
|
||||||
connect(m_sweepOutputsAction, &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);
|
m_proxyModel->setSearchFilter(filter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoinsWidget::freezeOutput() {
|
QStringList CoinsWidget::selectedPubkeys() {
|
||||||
QModelIndex index = ui->coins->currentIndex();
|
QModelIndexList list = ui->coins->selectionModel()->selectedRows();
|
||||||
QVector<int> indexes = {m_proxyModel->mapToSource(index).row()};
|
|
||||||
this->freezeCoins(indexes);
|
QStringList pubkeys;
|
||||||
|
for (QModelIndex index: list) {
|
||||||
|
pubkeys << m_model->entryFromIndex(m_proxyModel->mapToSource(index))->pubKey();
|
||||||
|
}
|
||||||
|
return pubkeys;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoinsWidget::freezeAllSelected() {
|
void CoinsWidget::freezeAllSelected() {
|
||||||
QModelIndexList list = ui->coins->selectionModel()->selectedRows();
|
QStringList pubkeys = this->selectedPubkeys();
|
||||||
|
this->freezeCoins(pubkeys);
|
||||||
QVector<int> 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<int> indexes = {m_proxyModel->mapToSource(index).row()};
|
|
||||||
this->thawCoins(indexes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoinsWidget::thawAllSelected() {
|
void CoinsWidget::thawAllSelected() {
|
||||||
QModelIndexList list = ui->coins->selectionModel()->selectedRows();
|
QStringList pubkeys = this->selectedPubkeys();
|
||||||
|
this->thawCoins(pubkeys);
|
||||||
QVector<int> indexes;
|
|
||||||
for (QModelIndex index: list) {
|
|
||||||
indexes.push_back(m_proxyModel->mapToSource(index).row());
|
|
||||||
}
|
|
||||||
this->thawCoins(indexes);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoinsWidget::viewOutput() {
|
void CoinsWidget::viewOutput() {
|
||||||
|
@ -291,17 +279,17 @@ QVector<CoinsInfo*> CoinsWidget::currentEntries() {
|
||||||
return selectedCoins;
|
return selectedCoins;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoinsWidget::freezeCoins(const QVector<int>& indexes) {
|
void CoinsWidget::freezeCoins(QStringList &pubkeys) {
|
||||||
for (int i : indexes) {
|
for (auto &pubkey : pubkeys) {
|
||||||
m_ctx->wallet->coins()->freeze(i);
|
m_ctx->wallet->coins()->freeze(pubkey);
|
||||||
}
|
}
|
||||||
m_ctx->wallet->coins()->refresh(m_ctx->wallet->currentSubaddressAccount());
|
m_ctx->wallet->coins()->refresh(m_ctx->wallet->currentSubaddressAccount());
|
||||||
m_ctx->updateBalance();
|
m_ctx->updateBalance();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CoinsWidget::thawCoins(const QVector<int> &indexes) {
|
void CoinsWidget::thawCoins(QStringList &pubkeys) {
|
||||||
for (int i : indexes) {
|
for (auto &pubkey : pubkeys) {
|
||||||
m_ctx->wallet->coins()->thaw(i);
|
m_ctx->wallet->coins()->thaw(pubkey);
|
||||||
}
|
}
|
||||||
m_ctx->wallet->coins()->refresh(m_ctx->wallet->currentSubaddressAccount());
|
m_ctx->wallet->coins()->refresh(m_ctx->wallet->currentSubaddressAccount());
|
||||||
m_ctx->updateBalance();
|
m_ctx->updateBalance();
|
||||||
|
|
|
@ -33,9 +33,7 @@ public slots:
|
||||||
private slots:
|
private slots:
|
||||||
void showHeaderMenu(const QPoint& position);
|
void showHeaderMenu(const QPoint& position);
|
||||||
void setShowSpent(bool show);
|
void setShowSpent(bool show);
|
||||||
void freezeOutput();
|
|
||||||
void freezeAllSelected();
|
void freezeAllSelected();
|
||||||
void thawOutput();
|
|
||||||
void thawAllSelected();
|
void thawAllSelected();
|
||||||
void viewOutput();
|
void viewOutput();
|
||||||
void onSweepOutputs();
|
void onSweepOutputs();
|
||||||
|
@ -43,8 +41,8 @@ private slots:
|
||||||
void editLabel();
|
void editLabel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void freezeCoins(const QVector<int>& indexes);
|
void freezeCoins(QStringList &pubkeys);
|
||||||
void thawCoins(const QVector<int>& indexes);
|
void thawCoins(QStringList &pubkeys);
|
||||||
|
|
||||||
enum copyField {
|
enum copyField {
|
||||||
PubKey = 0,
|
PubKey = 0,
|
||||||
|
@ -79,6 +77,7 @@ private:
|
||||||
void copy(copyField field);
|
void copy(copyField field);
|
||||||
CoinsInfo* currentEntry();
|
CoinsInfo* currentEntry();
|
||||||
QVector<CoinsInfo*> currentEntries();
|
QVector<CoinsInfo*> currentEntries();
|
||||||
|
QStringList selectedPubkeys();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,15 +71,15 @@ quint64 Coins::count() const
|
||||||
return m_tinfo.count();
|
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();
|
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();
|
emit coinThawed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ public:
|
||||||
Q_INVOKABLE CoinsInfo * coin(int index);
|
Q_INVOKABLE CoinsInfo * coin(int index);
|
||||||
Q_INVOKABLE void refresh(quint32 accountIndex);
|
Q_INVOKABLE void refresh(quint32 accountIndex);
|
||||||
Q_INVOKABLE void refreshUnlocked();
|
Q_INVOKABLE void refreshUnlocked();
|
||||||
Q_INVOKABLE void freeze(int index) const;
|
Q_INVOKABLE void freeze(QString &publicKey) const;
|
||||||
Q_INVOKABLE void thaw(int index) const;
|
Q_INVOKABLE void thaw(QString &publicKey) const;
|
||||||
Q_INVOKABLE QVector<CoinsInfo*> coins_from_txid(const QString &txid);
|
Q_INVOKABLE QVector<CoinsInfo*> coins_from_txid(const QString &txid);
|
||||||
Q_INVOKABLE void setDescription(int index, quint32 accountIndex, const QString &description);
|
Q_INVOKABLE void setDescription(int index, quint32 accountIndex, const QString &description);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue