Support 2.0.5 sapling turnstile
This commit is contained in:
@@ -3,6 +3,8 @@
|
||||
#include "balancestablemodel.h"
|
||||
#include "rpc.h"
|
||||
#include "settings.h"
|
||||
#include "ui_migration.h"
|
||||
|
||||
|
||||
using json = nlohmann::json;
|
||||
|
||||
@@ -375,3 +377,91 @@ void Turnstile::doSendTx(Tx tx, std::function<void(void)> cb) {
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
// Methods for zcashd native Migration
|
||||
void Turnstile::showZcashdMigration(MainWindow* parent) {
|
||||
// If it is not enabled, don't show the dialog
|
||||
if (! parent->getRPC()->getMigrationStatus()->available)
|
||||
return;
|
||||
|
||||
Ui_MigrationDialog md;
|
||||
QDialog d(parent);
|
||||
md.setupUi(&d);
|
||||
Settings::saveRestore(&d);
|
||||
|
||||
MigrationTxns model(md.tblTxids, parent->getRPC()->getMigrationStatus()->txids);
|
||||
md.tblTxids->setModel(&model);
|
||||
|
||||
// Table right click
|
||||
md.tblTxids->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
QObject::connect(md.tblTxids, &QTableView::customContextMenuRequested, [=, &model] (QPoint pos) {
|
||||
QModelIndex index = md.tblTxids->indexAt(pos);
|
||||
if (index.row() < 0) return;
|
||||
|
||||
QMenu menu(parent);
|
||||
QString txid = model.getTxid(index.row());
|
||||
|
||||
menu.addAction(QObject::tr("View on block explorer"), [=] () {
|
||||
QString url;
|
||||
if (Settings::getInstance()->isTestnet()) {
|
||||
url = "https://explorer.testnet.z.cash/tx/" + txid;
|
||||
} else {
|
||||
url = "https://explorer.zcha.in/transactions/" + txid;
|
||||
}
|
||||
QDesktopServices::openUrl(QUrl(url));
|
||||
});
|
||||
});
|
||||
|
||||
auto* status = parent->getRPC()->getMigrationStatus();
|
||||
|
||||
md.chkEnabled->setChecked(status->enabled);
|
||||
md.lblSaplingAddress->setText(status->saplingAddress);
|
||||
md.lblUnMigrated->setText(Settings::getZECDisplayFormat(status->unmigrated));
|
||||
md.lblMigrated->setText(Settings::getZECDisplayFormat(status->migrated));
|
||||
|
||||
if (d.exec() == QDialog::Accepted) {
|
||||
// Update the migration status if it changed
|
||||
if (md.chkEnabled->isChecked() != status->enabled) {
|
||||
parent->getRPC()->setMigrationStatus(md.chkEnabled->isChecked());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MigrationTxns::MigrationTxns(QTableView *parent, QList<QString> txids)
|
||||
: QAbstractTableModel(parent) {
|
||||
headers << tr("Txid");
|
||||
this->txids = txids;
|
||||
}
|
||||
|
||||
|
||||
int MigrationTxns::rowCount(const QModelIndex&) const {
|
||||
return txids.size();
|
||||
}
|
||||
|
||||
int MigrationTxns::columnCount(const QModelIndex&) const {
|
||||
return headers.size();
|
||||
}
|
||||
|
||||
QString MigrationTxns::getTxid(int row) const {
|
||||
return txids.at(row);
|
||||
}
|
||||
|
||||
QVariant MigrationTxns::data(const QModelIndex &index, int role) const {
|
||||
if (role == Qt::DisplayRole) {
|
||||
switch(index.column()) {
|
||||
case 0: return txids.at(index.row());
|
||||
}
|
||||
}
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
|
||||
QVariant MigrationTxns::headerData(int section, Qt::Orientation orientation, int role) const {
|
||||
if (role == Qt::DisplayRole && orientation == Qt::Horizontal) {
|
||||
return headers.at(section);
|
||||
}
|
||||
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user