Add to/from/via in turnstile progress dialog
This commit is contained in:
@@ -106,6 +106,9 @@ void MainWindow::turnstileProgress() {
|
|||||||
|
|
||||||
auto nextTxBlock = curProgress.nextBlock - Settings::getInstance()->getBlockNumber();
|
auto nextTxBlock = curProgress.nextBlock - Settings::getInstance()->getBlockNumber();
|
||||||
|
|
||||||
|
progress.fromAddr->setText(curProgress.from);
|
||||||
|
progress.toAddr->setText(curProgress.to);
|
||||||
|
|
||||||
if (curProgress.step == curProgress.totalSteps) {
|
if (curProgress.step == curProgress.totalSteps) {
|
||||||
auto txt = QString("Turnstile migration finished");
|
auto txt = QString("Turnstile migration finished");
|
||||||
if (curProgress.hasErrors) {
|
if (curProgress.hasErrors) {
|
||||||
@@ -115,7 +118,7 @@ void MainWindow::turnstileProgress() {
|
|||||||
} else {
|
} else {
|
||||||
progress.nextTx->setText(QString("Next transaction in ")
|
progress.nextTx->setText(QString("Next transaction in ")
|
||||||
% QString::number(nextTxBlock < 0 ? 0 : nextTxBlock)
|
% QString::number(nextTxBlock < 0 ? 0 : nextTxBlock)
|
||||||
% " blocks\n"
|
% " blocks via " % curProgress.via % "\n"
|
||||||
% (nextTxBlock <= 0 ? "(waiting for confirmations)" : ""));
|
% (nextTxBlock <= 0 ? "(waiting for confirmations)" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -138,6 +141,7 @@ void MainWindow::turnstileProgress() {
|
|||||||
progress.buttonBox->button(QDialogButtonBox::Discard)->setText("Abort");
|
progress.buttonBox->button(QDialogButtonBox::Discard)->setText("Abort");
|
||||||
else
|
else
|
||||||
progress.buttonBox->button(QDialogButtonBox::Discard)->setVisible(false);
|
progress.buttonBox->button(QDialogButtonBox::Discard)->setVisible(false);
|
||||||
|
|
||||||
QObject::connect(progress.buttonBox->button(QDialogButtonBox::Discard), &QPushButton::clicked, [&] () {
|
QObject::connect(progress.buttonBox->button(QDialogButtonBox::Discard), &QPushButton::clicked, [&] () {
|
||||||
if (curProgress.step != curProgress.totalSteps) {
|
if (curProgress.step != curProgress.totalSteps) {
|
||||||
auto abort = QMessageBox::warning(this, "Are you sure you want to Abort?",
|
auto abort = QMessageBox::warning(this, "Are you sure you want to Abort?",
|
||||||
@@ -520,7 +524,7 @@ void MainWindow::setupBalancesTab() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Settings::getInstance()->isSproutAddress(addr)) {
|
if (Settings::getInstance()->isTestnet() && Settings::getInstance()->isSproutAddress(addr)) {
|
||||||
menu.addAction("Migrate to Sapling", [=] () {
|
menu.addAction("Migrate to Sapling", [=] () {
|
||||||
this->turnstileDoMigration(addr);
|
this->turnstileDoMigration(addr);
|
||||||
});
|
});
|
||||||
|
|||||||
56
src/rpc.cpp
56
src/rpc.cpp
@@ -194,7 +194,7 @@ void RPC::importZPrivKey(QString addr, bool rescan, const std::function<void(jso
|
|||||||
|
|
||||||
qDebug() << QString::fromStdString(payload.dump());
|
qDebug() << QString::fromStdString(payload.dump());
|
||||||
|
|
||||||
doRPC(payload, cb);
|
doSendRPC(payload, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -207,7 +207,7 @@ void RPC::importTPrivKey(QString addr, bool rescan, const std::function<void(jso
|
|||||||
};
|
};
|
||||||
|
|
||||||
qDebug() << QString::fromStdString(payload.dump());
|
qDebug() << QString::fromStdString(payload.dump());
|
||||||
doRPC(payload, cb);
|
doSendRPC(payload, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -232,30 +232,36 @@ void RPC::getTransactions(const std::function<void(json)>& cb) {
|
|||||||
doRPC(payload, cb);
|
doRPC(payload, cb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RPC::doSendRPC(const json& payload, const std::function<void(json)>& cb, const std::function<void(QString)>& err) {
|
||||||
|
QNetworkReply *reply = restclient->post(request, QByteArray::fromStdString(payload.dump()));
|
||||||
|
|
||||||
|
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
||||||
|
reply->deleteLater();
|
||||||
|
|
||||||
|
if (reply->error() != QNetworkReply::NoError) {
|
||||||
|
auto parsed = json::parse(reply->readAll(), nullptr, false);
|
||||||
|
if (!parsed.is_discarded() && !parsed["error"]["message"].is_null()) {
|
||||||
|
err(QString::fromStdString(parsed["error"]["message"]));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
err(reply->errorString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto parsed = json::parse(reply->readAll(), nullptr, false);
|
||||||
|
if (parsed.is_discarded()) {
|
||||||
|
err("Unknown error");
|
||||||
|
}
|
||||||
|
|
||||||
|
cb(parsed["result"]);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Default implementation of a Send RPC that default shows an error message box with the error.
|
||||||
void RPC::doSendRPC(const json& payload, const std::function<void(json)>& cb) {
|
void RPC::doSendRPC(const json& payload, const std::function<void(json)>& cb) {
|
||||||
QNetworkReply *reply = restclient->post(request, QByteArray::fromStdString(payload.dump()));
|
doSendRPC(payload, cb, [=](auto error) { this->handleTxError(error); });
|
||||||
|
|
||||||
QObject::connect(reply, &QNetworkReply::finished, [=] {
|
|
||||||
reply->deleteLater();
|
|
||||||
|
|
||||||
if (reply->error() != QNetworkReply::NoError) {
|
|
||||||
auto parsed = json::parse(reply->readAll(), nullptr, false);
|
|
||||||
if (!parsed.is_discarded() && !parsed["error"]["message"].is_null()) {
|
|
||||||
handleTxError(QString::fromStdString(parsed["error"]["message"]));
|
|
||||||
} else {
|
|
||||||
handleTxError(reply->errorString());
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto parsed = json::parse(reply->readAll(), nullptr, false);
|
|
||||||
if (parsed.is_discarded()) {
|
|
||||||
handleTxError("Unknown error");
|
|
||||||
}
|
|
||||||
|
|
||||||
cb(parsed["result"]);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RPC::sendZTransaction(json params, const std::function<void(json)>& cb) {
|
void RPC::sendZTransaction(json params, const std::function<void(json)>& cb) {
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
void doRPC (const json& payload, const std::function<void(json)>& cb);
|
void doRPC (const json& payload, const std::function<void(json)>& cb);
|
||||||
void doSendRPC (const json& payload, const std::function<void(json)>& cb);
|
void doSendRPC (const json& payload, const std::function<void(json)>& cb);
|
||||||
|
void doSendRPC(const json& payload, const std::function<void(json)>& cb, const std::function<void(QString)>& err);
|
||||||
|
|
||||||
void refreshBalances();
|
void refreshBalances();
|
||||||
|
|
||||||
|
|||||||
@@ -243,7 +243,9 @@ ProgressReport Turnstile::getPlanProgress() {
|
|||||||
i.status == TurnstileMigrationItemStatus::UnknownError;
|
i.status == TurnstileMigrationItemStatus::UnknownError;
|
||||||
}) != plan.end();
|
}) != plan.end();
|
||||||
|
|
||||||
return ProgressReport{(int)step, total*2, nextBlock, hasErrors};
|
auto stepData = (nextStep == plan.end() ? std::prev(nextStep) : nextStep);
|
||||||
|
|
||||||
|
return ProgressReport{(int)step, total*2, nextBlock, hasErrors, stepData->fromAddr, stepData->destAddr, stepData->intTAddr};
|
||||||
}
|
}
|
||||||
|
|
||||||
void Turnstile::executeMigrationStep() {
|
void Turnstile::executeMigrationStep() {
|
||||||
|
|||||||
@@ -30,6 +30,9 @@ struct ProgressReport {
|
|||||||
int totalSteps;
|
int totalSteps;
|
||||||
int nextBlock;
|
int nextBlock;
|
||||||
bool hasErrors;
|
bool hasErrors;
|
||||||
|
QString from;
|
||||||
|
QString to;
|
||||||
|
QString via;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Turnstile
|
class Turnstile
|
||||||
|
|||||||
@@ -14,14 +14,38 @@
|
|||||||
<string>Turnstile Migration Progress</string>
|
<string>Turnstile Migration Progress</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="3" column="0" colspan="3">
|
<item row="0" column="0">
|
||||||
<widget class="QProgressBar" name="progressBar">
|
<widget class="QLabel" name="label">
|
||||||
<property name="value">
|
<property name="text">
|
||||||
<number>33</number>
|
<string>From</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="1" colspan="2">
|
<item row="2" column="0">
|
||||||
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="text">
|
||||||
|
<string>To</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0" colspan="3">
|
||||||
|
<widget class="QLabel" name="fromAddr">
|
||||||
|
<property name="text">
|
||||||
|
<string>From Address</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="2">
|
||||||
|
<widget class="QLabel" name="progressTxt">
|
||||||
|
<property name="text">
|
||||||
|
<string>4 / 12</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="12" column="1" colspan="2">
|
||||||
<widget class="QLabel" name="label_4">
|
<widget class="QLabel" name="label_4">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
@@ -37,38 +61,48 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" colspan="3">
|
<item row="9" column="0" colspan="3">
|
||||||
<widget class="Line" name="line">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="5" column="0" colspan="3">
|
|
||||||
<widget class="QLabel" name="nextTx">
|
<widget class="QLabel" name="nextTx">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Next Transaction in 4 hours</string>
|
<string>Next Transaction in 4 hours</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="2">
|
<item row="7" column="0" colspan="3">
|
||||||
<widget class="QLabel" name="progressTxt">
|
<widget class="QProgressBar" name="progressBar">
|
||||||
<property name="text">
|
<property name="value">
|
||||||
<string>4 / 12</string>
|
<number>33</number>
|
||||||
</property>
|
|
||||||
<property name="alignment">
|
|
||||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="2">
|
<item row="13" column="0" colspan="3">
|
||||||
|
<widget class="Line" name="line_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="6" column="0" colspan="2">
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Migration Progress</string>
|
<string>Migration Progress</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="7" column="0">
|
<item row="14" column="0" colspan="3">
|
||||||
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Close|QDialogButtonBox::Discard</set>
|
||||||
|
</property>
|
||||||
|
<property name="centerButtons">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="12" column="0">
|
||||||
<widget class="QLabel" name="msgIcon">
|
<widget class="QLabel" name="msgIcon">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
@@ -84,20 +118,7 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="9" column="0" colspan="3">
|
<item row="11" column="0" colspan="3">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
|
||||||
<property name="orientation">
|
|
||||||
<enum>Qt::Horizontal</enum>
|
|
||||||
</property>
|
|
||||||
<property name="standardButtons">
|
|
||||||
<set>QDialogButtonBox::Close|QDialogButtonBox::Discard</set>
|
|
||||||
</property>
|
|
||||||
<property name="centerButtons">
|
|
||||||
<bool>false</bool>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
|
||||||
<item row="6" column="0" colspan="3">
|
|
||||||
<spacer name="verticalSpacer">
|
<spacer name="verticalSpacer">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Vertical</enum>
|
<enum>Qt::Vertical</enum>
|
||||||
@@ -110,8 +131,22 @@
|
|||||||
</property>
|
</property>
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item row="8" column="0" colspan="3">
|
<item row="5" column="0" colspan="3">
|
||||||
<widget class="Line" name="line_2">
|
<widget class="Line" name="line_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="0" colspan="3">
|
||||||
|
<widget class="QLabel" name="toAddr">
|
||||||
|
<property name="text">
|
||||||
|
<string>To Address</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="10" column="0" colspan="3">
|
||||||
|
<widget class="Line" name="line">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
|||||||
@@ -98,7 +98,10 @@ void TxTableModel::updateAllData() {
|
|||||||
else
|
else
|
||||||
return addr;
|
return addr;
|
||||||
}
|
}
|
||||||
case 2: return QDateTime::fromMSecsSinceEpoch(modeldata->at(index.row()).datetime * 1000).toLocalTime().toString();
|
case 2: {
|
||||||
|
qDebug() << modeldata->at(index.row()).datetime;
|
||||||
|
return QDateTime::fromMSecsSinceEpoch(modeldata->at(index.row()).datetime * 1000).toLocalTime().toString();
|
||||||
|
}
|
||||||
case 3: return Settings::getInstance()->getZECDisplayFormat(modeldata->at(index.row()).amount);
|
case 3: return Settings::getInstance()->getZECDisplayFormat(modeldata->at(index.row()).amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user