mirror of
https://github.com/feather-wallet/feather.git
synced 2024-12-22 11:39:25 +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)
|
||||
endif()
|
||||
|
||||
set(MONERO_HEAD "d4257af2e7503fc6dc09fc704606230d353a0a02")
|
||||
set(MONERO_HEAD "ed8859318349a5f01e9fd90e898603d4142b0951")
|
||||
set(BUILD_GUI_DEPS ON)
|
||||
option(ARCH "Target architecture" "x86-64")
|
||||
set(BUILD_64 ON)
|
||||
|
|
|
@ -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);
|
||||
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<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);
|
||||
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();
|
||||
|
|
|
@ -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();
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue