Add support for testnet
This commit is contained in:
@@ -51,3 +51,5 @@ ssh -L8232:127.0.0.1:8232 user@remotehost
|
|||||||
### 2. "Not enough balance" when sending transactions
|
### 2. "Not enough balance" when sending transactions
|
||||||
The most likely cause for this is that you are trying to spend unconfirmed funds. Unlike bitcoin, the zcash protocol doesn't let you spent unconfirmed funds yet. Please wait for
|
The most likely cause for this is that you are trying to spend unconfirmed funds. Unlike bitcoin, the zcash protocol doesn't let you spent unconfirmed funds yet. Please wait for
|
||||||
1-2 blocks for the funds to confirm and retry the transaction.
|
1-2 blocks for the funds to confirm and retry the transaction.
|
||||||
|
|
||||||
|
PS: zcash-qt-wallet is NOT an official wallet, and is not affiliated with the ZCash Company in any way.
|
||||||
@@ -8,6 +8,7 @@ BalancesTableModel::BalancesTableModel(QObject *parent)
|
|||||||
void BalancesTableModel::setNewData(const QMap<QString, double>* balances,
|
void BalancesTableModel::setNewData(const QMap<QString, double>* balances,
|
||||||
const QList<UnspentOutput>* outputs)
|
const QList<UnspentOutput>* outputs)
|
||||||
{
|
{
|
||||||
|
int currentRows = rowCount(QModelIndex());
|
||||||
// Copy over the utxos for our use
|
// Copy over the utxos for our use
|
||||||
delete utxos;
|
delete utxos;
|
||||||
utxos = new QList<UnspentOutput>();
|
utxos = new QList<UnspentOutput>();
|
||||||
@@ -23,7 +24,10 @@ void BalancesTableModel::setNewData(const QMap<QString, double>* balances,
|
|||||||
|
|
||||||
// And then update the data
|
// And then update the data
|
||||||
dataChanged(index(0, 0), index(modeldata->size()-1, columnCount(index(0,0))-1));
|
dataChanged(index(0, 0), index(modeldata->size()-1, columnCount(index(0,0))-1));
|
||||||
layoutChanged();
|
|
||||||
|
// Change the layout only if the number of rows changed
|
||||||
|
if (modeldata && modeldata->size() != currentRows)
|
||||||
|
layoutChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
BalancesTableModel::~BalancesTableModel() {
|
BalancesTableModel::~BalancesTableModel() {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
#include "mainwindow.h"
|
#include "mainwindow.h"
|
||||||
|
#include "settings.h"
|
||||||
#include "precompiled.h"
|
#include "precompiled.h"
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
@@ -21,7 +22,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
|
|
||||||
MainWindow w;
|
MainWindow w;
|
||||||
|
w.setWindowTitle("zcash-qt-wallet v" + QString(APP_VERSION));
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
return QApplication::exec();
|
return QApplication::exec();
|
||||||
|
|||||||
17
src/rpc.cpp
17
src/rpc.cpp
@@ -240,7 +240,8 @@ void RPC::handleConnectionError(const QString& error) {
|
|||||||
% "\n\nThis is most likely an internal error. Are you using zcashd v2.0 or higher? You might "
|
% "\n\nThis is most likely an internal error. Are you using zcashd v2.0 or higher? You might "
|
||||||
% "need to file a bug report here: https://github.com/adityapk00/zcash-qt-wallet/issues";
|
% "need to file a bug report here: https://github.com/adityapk00/zcash-qt-wallet/issues";
|
||||||
} else if (error.contains("internal server error", Qt::CaseInsensitive) ||
|
} else if (error.contains("internal server error", Qt::CaseInsensitive) ||
|
||||||
error.contains("rewinding")) {
|
error.contains("rewinding", Qt::CaseInsensitive) ||
|
||||||
|
error.contains("loading", Qt::CaseInsensitive)) {
|
||||||
explanation = QString()
|
explanation = QString()
|
||||||
% "\n\nIf you just started zcashd, then it's still loading and you might have to wait a while. If zcashd is ready, then you've run into "
|
% "\n\nIf you just started zcashd, then it's still loading and you might have to wait a while. If zcashd is ready, then you've run into "
|
||||||
% "something unexpected, and might need to file a bug report here: https://github.com/adityapk00/zcash-qt-wallet/issues";
|
% "something unexpected, and might need to file a bug report here: https://github.com/adityapk00/zcash-qt-wallet/issues";
|
||||||
@@ -313,8 +314,6 @@ void RPC::refreshAddresses() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RPC::refreshBalances() {
|
void RPC::refreshBalances() {
|
||||||
ui->unconfirmedWarning->setVisible(false);
|
|
||||||
|
|
||||||
// 1. Get the Balances
|
// 1. Get the Balances
|
||||||
getBalance([=] (json reply) {
|
getBalance([=] (json reply) {
|
||||||
ui->balSheilded ->setText(QString::fromStdString(reply["private"]) % " ZEC");
|
ui->balSheilded ->setText(QString::fromStdString(reply["private"]) % " ZEC");
|
||||||
@@ -331,11 +330,12 @@ void RPC::refreshBalances() {
|
|||||||
|
|
||||||
// Function to process reply of the listunspent and z_listunspent API calls, used below.
|
// Function to process reply of the listunspent and z_listunspent API calls, used below.
|
||||||
auto processUnspent = [=] (const json& reply) {
|
auto processUnspent = [=] (const json& reply) {
|
||||||
|
bool anyUnconfirmed = false;
|
||||||
for (auto& it : reply.get<json::array_t>()) {
|
for (auto& it : reply.get<json::array_t>()) {
|
||||||
QString qsAddr = QString::fromStdString(it["address"]);
|
QString qsAddr = QString::fromStdString(it["address"]);
|
||||||
auto confirmations = it["confirmations"].get<json::number_unsigned_t>();
|
auto confirmations = it["confirmations"].get<json::number_unsigned_t>();
|
||||||
if (confirmations == 0) {
|
if (confirmations == 0) {
|
||||||
ui->unconfirmedWarning->setVisible(true);
|
anyUnconfirmed = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
utxos->push_back(
|
utxos->push_back(
|
||||||
@@ -348,6 +348,7 @@ void RPC::refreshBalances() {
|
|||||||
);
|
);
|
||||||
|
|
||||||
(*allBalances)[qsAddr] = (*allBalances)[qsAddr] + it["amount"].get<json::number_float_t>();
|
(*allBalances)[qsAddr] = (*allBalances)[qsAddr] + it["amount"].get<json::number_float_t>();
|
||||||
|
ui->unconfirmedWarning->setVisible(anyUnconfirmed);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -406,7 +407,6 @@ void RPC::refreshTransactions() {
|
|||||||
|
|
||||||
void RPC::refreshTxStatus(const QString& newOpid) {
|
void RPC::refreshTxStatus(const QString& newOpid) {
|
||||||
if (!newOpid.isEmpty()) {
|
if (!newOpid.isEmpty()) {
|
||||||
qDebug() << QString::fromStdString("Adding opid ") % newOpid;
|
|
||||||
watchingOps.insert(newOpid);
|
watchingOps.insert(newOpid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -418,8 +418,6 @@ void RPC::refreshTxStatus(const QString& newOpid) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
doRPC(payload, [=] (const json& reply) {
|
doRPC(payload, [=] (const json& reply) {
|
||||||
int numExecuting = 0;
|
|
||||||
|
|
||||||
// There's an array for each item in the status
|
// There's an array for each item in the status
|
||||||
for (auto& it : reply.get<json::array_t>()) {
|
for (auto& it : reply.get<json::array_t>()) {
|
||||||
// If we were watching this Tx and it's status became "success", then we'll show a status bar alert
|
// If we were watching this Tx and it's status became "success", then we'll show a status bar alert
|
||||||
@@ -457,17 +455,16 @@ void RPC::refreshTxStatus(const QString& newOpid) {
|
|||||||
} else if (status == "executing") {
|
} else if (status == "executing") {
|
||||||
// If the operation is executing, then watch every second.
|
// If the operation is executing, then watch every second.
|
||||||
txTimer->start(1 * 1000);
|
txTimer->start(1 * 1000);
|
||||||
numExecuting++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// If there is some op that we are watching, then show the loading bar, otherwise hide it
|
// If there is some op that we are watching, then show the loading bar, otherwise hide it
|
||||||
if (numExecuting == 0) {
|
if (watchingOps.size() == 0) {
|
||||||
main->loadingLabel->setVisible(false);
|
main->loadingLabel->setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
main->loadingLabel->setVisible(true);
|
main->loadingLabel->setVisible(true);
|
||||||
main->loadingLabel->setToolTip(QString::number(numExecuting) + " tx computing. This can take several minutes.");
|
main->loadingLabel->setToolTip(QString::number(watchingOps.size()) + " tx computing. This can take several minutes.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,13 +278,15 @@ void MainWindow::sendButton() {
|
|||||||
|
|
||||||
QString MainWindow::doSendTxValidations(QString fromAddr, QList<QPair<QString, double>> toAddrs) {
|
QString MainWindow::doSendTxValidations(QString fromAddr, QList<QPair<QString, double>> toAddrs) {
|
||||||
// 1. Addresses are valid format.
|
// 1. Addresses are valid format.
|
||||||
QRegExp zcexp("^zc[a-z0-9]{93}$", Qt::CaseInsensitive);
|
QRegExp zcexp("^z[a-z0-9]{94}$", Qt::CaseInsensitive);
|
||||||
QRegExp zsexp("^zc[a-z0-9]{76}$", Qt::CaseInsensitive);
|
QRegExp zsexp("^z[a-z0-9]{77}$", Qt::CaseInsensitive);
|
||||||
|
QRegExp ztsexp("^ztestsapling[a-z0-9]{76}", Qt::CaseInsensitive);
|
||||||
QRegExp texp("^t[a-z0-9]{34}$", Qt::CaseInsensitive);
|
QRegExp texp("^t[a-z0-9]{34}$", Qt::CaseInsensitive);
|
||||||
|
|
||||||
auto matchesAnyAddr = [&] (QString addr) {
|
auto matchesAnyAddr = [&] (QString addr) {
|
||||||
return zcexp.exactMatch(addr) ||
|
return zcexp.exactMatch(addr) ||
|
||||||
texp.exactMatch(addr) ||
|
texp.exactMatch(addr) ||
|
||||||
|
ztsexp.exactMatch(addr) ||
|
||||||
zsexp.exactMatch(addr);
|
zsexp.exactMatch(addr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ QString Settings::getHost() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QString Settings::getPort() {
|
QString Settings::getPort() {
|
||||||
|
// If the override port is set, we'll always return it
|
||||||
|
if (!overridePort.isEmpty()) return overridePort;
|
||||||
|
|
||||||
if (port.isNull() || port == "") return "8232";
|
if (port.isNull() || port == "") return "8232";
|
||||||
return port;
|
return port;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
#ifndef SETTINGS_H
|
#ifndef SETTINGS_H
|
||||||
#define SETTINGS_H
|
#define SETTINGS_H
|
||||||
|
|
||||||
|
#include "precompiled.h"
|
||||||
|
|
||||||
class Settings
|
class Settings
|
||||||
{
|
{
|
||||||
@@ -11,6 +12,8 @@ public:
|
|||||||
QString getHost();
|
QString getHost();
|
||||||
QString getPort();
|
QString getPort();
|
||||||
|
|
||||||
|
void setDefaultPort(int port) {overridePort = QString::number(port);}
|
||||||
|
|
||||||
double fees() { return 0.0001; }
|
double fees() { return 0.0001; }
|
||||||
void refresh();
|
void refresh();
|
||||||
private:
|
private:
|
||||||
@@ -19,6 +22,8 @@ private:
|
|||||||
QString port;
|
QString port;
|
||||||
QString username;
|
QString username;
|
||||||
QString password;
|
QString password;
|
||||||
|
|
||||||
|
QString overridePort;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // SETTINGS_H
|
#endif // SETTINGS_H
|
||||||
Reference in New Issue
Block a user