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();
|
||||
|
||||
progress.fromAddr->setText(curProgress.from);
|
||||
progress.toAddr->setText(curProgress.to);
|
||||
|
||||
if (curProgress.step == curProgress.totalSteps) {
|
||||
auto txt = QString("Turnstile migration finished");
|
||||
if (curProgress.hasErrors) {
|
||||
@@ -115,7 +118,7 @@ void MainWindow::turnstileProgress() {
|
||||
} else {
|
||||
progress.nextTx->setText(QString("Next transaction in ")
|
||||
% QString::number(nextTxBlock < 0 ? 0 : nextTxBlock)
|
||||
% " blocks\n"
|
||||
% " blocks via " % curProgress.via % "\n"
|
||||
% (nextTxBlock <= 0 ? "(waiting for confirmations)" : ""));
|
||||
}
|
||||
|
||||
@@ -138,6 +141,7 @@ void MainWindow::turnstileProgress() {
|
||||
progress.buttonBox->button(QDialogButtonBox::Discard)->setText("Abort");
|
||||
else
|
||||
progress.buttonBox->button(QDialogButtonBox::Discard)->setVisible(false);
|
||||
|
||||
QObject::connect(progress.buttonBox->button(QDialogButtonBox::Discard), &QPushButton::clicked, [&] () {
|
||||
if (curProgress.step != curProgress.totalSteps) {
|
||||
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", [=] () {
|
||||
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());
|
||||
|
||||
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());
|
||||
doRPC(payload, cb);
|
||||
doSendRPC(payload, cb);
|
||||
}
|
||||
|
||||
|
||||
@@ -232,30 +232,36 @@ void RPC::getTransactions(const std::function<void(json)>& cb) {
|
||||
doRPC(payload, cb);
|
||||
}
|
||||
|
||||
void RPC::doSendRPC(const json& payload, const std::function<void(json)>& cb) {
|
||||
QNetworkReply *reply = restclient->post(request, QByteArray::fromStdString(payload.dump()));
|
||||
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()) {
|
||||
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"]);
|
||||
});
|
||||
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) {
|
||||
doSendRPC(payload, cb, [=](auto error) { this->handleTxError(error); });
|
||||
}
|
||||
|
||||
void RPC::sendZTransaction(json params, const std::function<void(json)>& cb) {
|
||||
|
||||
@@ -110,6 +110,7 @@ public:
|
||||
private:
|
||||
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, const std::function<void(QString)>& err);
|
||||
|
||||
void refreshBalances();
|
||||
|
||||
|
||||
@@ -243,7 +243,9 @@ ProgressReport Turnstile::getPlanProgress() {
|
||||
i.status == TurnstileMigrationItemStatus::UnknownError;
|
||||
}) != 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() {
|
||||
|
||||
@@ -30,6 +30,9 @@ struct ProgressReport {
|
||||
int totalSteps;
|
||||
int nextBlock;
|
||||
bool hasErrors;
|
||||
QString from;
|
||||
QString to;
|
||||
QString via;
|
||||
};
|
||||
|
||||
class Turnstile
|
||||
|
||||
@@ -14,14 +14,38 @@
|
||||
<string>Turnstile Migration Progress</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="3" column="0" colspan="3">
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="value">
|
||||
<number>33</number>
|
||||
<item row="0" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>From</string>
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||
@@ -37,38 +61,48 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" 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">
|
||||
<item row="9" column="0" colspan="3">
|
||||
<widget class="QLabel" name="nextTx">
|
||||
<property name="text">
|
||||
<string>Next Transaction in 4 hours</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" 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>
|
||||
<item row="7" column="0" colspan="3">
|
||||
<widget class="QProgressBar" name="progressBar">
|
||||
<property name="value">
|
||||
<number>33</number>
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<property name="text">
|
||||
<string>Migration Progress</string>
|
||||
</property>
|
||||
</widget>
|
||||
</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">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||
@@ -84,20 +118,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" 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">
|
||||
<item row="11" column="0" colspan="3">
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
@@ -110,8 +131,22 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="3">
|
||||
<widget class="Line" name="line_2">
|
||||
<item row="5" column="0" colspan="3">
|
||||
<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">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
|
||||
@@ -98,7 +98,10 @@ void TxTableModel::updateAllData() {
|
||||
else
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user