diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index b721438..ba41ba3 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -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) diff --git a/src/rpc.cpp b/src/rpc.cpp index 94f21f4..016a263 100644 --- a/src/rpc.cpp +++ b/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(), 'g', 8), - confirmations - ) - ); + UnspentOutput{ qsAddr, QString::fromStdString(it["txid"]), + QString::number(it["amount"].get(), 'g', 8), + (int)confirmations, it["spendable"].get() }); (*allBalances)[qsAddr] = (*allBalances)[qsAddr] + it["amount"].get(); } diff --git a/src/turnstile.cpp b/src/turnstile.cpp index c1b278a..b9cede9 100644 --- a/src/turnstile.cpp +++ b/src/turnstile.cpp @@ -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(); }; diff --git a/src/turnstile.h b/src/turnstile.h index 09ed1a0..fd14597 100644 --- a/src/turnstile.h +++ b/src/turnstile.h @@ -27,6 +27,7 @@ struct ProgressReport { int step; int totalSteps; int nextBlock; + bool hasErrors; }; class Turnstile diff --git a/src/unspentoutput.cpp b/src/unspentoutput.cpp index 67068f3..7b3a2d6 100644 --- a/src/unspentoutput.cpp +++ b/src/unspentoutput.cpp @@ -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; -} diff --git a/src/unspentoutput.h b/src/unspentoutput.h index d6af3b1..e106e5d 100644 --- a/src/unspentoutput.h +++ b/src/unspentoutput.h @@ -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; };