progress error message
This commit is contained in:
@@ -165,7 +165,11 @@ void MainWindow::setupTurnstileDialog() {
|
||||
auto nextTxBlock = curProgress.nextBlock - Settings::getInstance()->getBlockNumber();
|
||||
|
||||
if (curProgress.step == curProgress.totalSteps) {
|
||||
progress.nextTx->setText("Turnstile migration finished");
|
||||
auto txt = QString("Turnstile migration finished");
|
||||
if (curProgress.hasErrors) {
|
||||
txt = txt + ". There were some errors.\n\nYour funds are all in your wallet, so you should be able to finish moving them manually.";
|
||||
}
|
||||
progress.nextTx->setText(txt);
|
||||
} else {
|
||||
progress.nextTx->setText(QString("Next transaction in ")
|
||||
% QString::number(nextTxBlock < 0 ? 0 : nextTxBlock)
|
||||
|
||||
10
src/rpc.cpp
10
src/rpc.cpp
@@ -523,13 +523,9 @@ bool RPC::processUnspent(const json& reply) {
|
||||
}
|
||||
|
||||
utxos->push_back(
|
||||
UnspentOutput(
|
||||
qsAddr,
|
||||
QString::fromStdString(it["txid"]),
|
||||
QString::number(it["amount"].get<json::number_float_t>(), 'g', 8),
|
||||
confirmations
|
||||
)
|
||||
);
|
||||
UnspentOutput{ qsAddr, QString::fromStdString(it["txid"]),
|
||||
QString::number(it["amount"].get<json::number_float_t>(), 'g', 8),
|
||||
(int)confirmations, it["spendable"].get<json::boolean_t>() });
|
||||
|
||||
(*allBalances)[qsAddr] = (*allBalances)[qsAddr] + it["amount"].get<json::number_float_t>();
|
||||
}
|
||||
|
||||
@@ -233,7 +233,12 @@ ProgressReport Turnstile::getPlanProgress() {
|
||||
|
||||
auto nextBlock = nextStep == plan.end() ? 0 : nextStep->blockNumber;
|
||||
|
||||
return ProgressReport{(int)step*2, total*2, nextBlock};
|
||||
bool hasErrors = std::find_if(plan.begin(), plan.end(), [=] (auto i) {
|
||||
return i.status == TurnstileMigrationItemStatus::NotEnoughBalance ||
|
||||
i.status == TurnstileMigrationItemStatus::UnknownError;
|
||||
}) != plan.end();
|
||||
|
||||
return ProgressReport{(int)step*2, total*2, nextBlock, hasErrors};
|
||||
}
|
||||
|
||||
void Turnstile::executeMigrationStep() {
|
||||
@@ -252,7 +257,7 @@ void Turnstile::executeMigrationStep() {
|
||||
auto fnHasUnconfirmed = [=] (QString addr) {
|
||||
auto utxoset = rpc->getUTXOs();
|
||||
return std::find_if(utxoset->begin(), utxoset->end(), [=] (auto utxo) {
|
||||
return utxo.address == addr && utxo.confirmations == 0;
|
||||
return utxo.address == addr && utxo.confirmations == 0 && utxo.spendable;
|
||||
}) != utxoset->end();
|
||||
};
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ struct ProgressReport {
|
||||
int step;
|
||||
int totalSteps;
|
||||
int nextBlock;
|
||||
bool hasErrors;
|
||||
};
|
||||
|
||||
class Turnstile
|
||||
|
||||
@@ -1,9 +1 @@
|
||||
#include "unspentoutput.h"
|
||||
|
||||
UnspentOutput::UnspentOutput(QString address, QString txid, QString amount, int confirmations)
|
||||
{
|
||||
this->address = address;
|
||||
this->txid = txid;
|
||||
this->amount = amount;
|
||||
this->confirmations = confirmations;
|
||||
}
|
||||
|
||||
@@ -3,15 +3,12 @@
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
class UnspentOutput
|
||||
{
|
||||
public:
|
||||
UnspentOutput(QString address, QString txid, QString amount, int confirmations);
|
||||
|
||||
struct UnspentOutput {
|
||||
QString address;
|
||||
QString txid;
|
||||
QString amount;
|
||||
int confirmations;
|
||||
bool spendable;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user