Add support for testnet
This commit is contained in:
parent
f29d2708c5
commit
46ff75b109
|
@ -51,3 +51,5 @@ ssh -L8232:127.0.0.1:8232 user@remotehost
|
|||
### 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
|
||||
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,
|
||||
const QList<UnspentOutput>* outputs)
|
||||
{
|
||||
int currentRows = rowCount(QModelIndex());
|
||||
// Copy over the utxos for our use
|
||||
delete utxos;
|
||||
utxos = new QList<UnspentOutput>();
|
||||
|
@ -23,7 +24,10 @@ void BalancesTableModel::setNewData(const QMap<QString, double>* balances,
|
|||
|
||||
// And then update the data
|
||||
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() {
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "mainwindow.h"
|
||||
#include "settings.h"
|
||||
#include "precompiled.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
|
@ -21,7 +22,7 @@ int main(int argc, char *argv[])
|
|||
|
||||
|
||||
MainWindow w;
|
||||
|
||||
w.setWindowTitle("zcash-qt-wallet v" + QString(APP_VERSION));
|
||||
w.show();
|
||||
|
||||
return QApplication::exec();
|
||||
|
|
19
src/rpc.cpp
19
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 "
|
||||
% "need to file a bug report here: https://github.com/adityapk00/zcash-qt-wallet/issues";
|
||||
} else if (error.contains("internal server error", Qt::CaseInsensitive) ||
|
||||
error.contains("rewinding")) {
|
||||
error.contains("rewinding", Qt::CaseInsensitive) ||
|
||||
error.contains("loading", Qt::CaseInsensitive)) {
|
||||
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 "
|
||||
% "something unexpected, and might need to file a bug report here: https://github.com/adityapk00/zcash-qt-wallet/issues";
|
||||
|
@ -312,9 +313,7 @@ void RPC::refreshAddresses() {
|
|||
});
|
||||
}
|
||||
|
||||
void RPC::refreshBalances() {
|
||||
ui->unconfirmedWarning->setVisible(false);
|
||||
|
||||
void RPC::refreshBalances() {
|
||||
// 1. Get the Balances
|
||||
getBalance([=] (json reply) {
|
||||
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.
|
||||
auto processUnspent = [=] (const json& reply) {
|
||||
bool anyUnconfirmed = false;
|
||||
for (auto& it : reply.get<json::array_t>()) {
|
||||
QString qsAddr = QString::fromStdString(it["address"]);
|
||||
auto confirmations = it["confirmations"].get<json::number_unsigned_t>();
|
||||
if (confirmations == 0) {
|
||||
ui->unconfirmedWarning->setVisible(true);
|
||||
anyUnconfirmed = true;
|
||||
}
|
||||
|
||||
utxos->push_back(
|
||||
|
@ -348,6 +348,7 @@ void RPC::refreshBalances() {
|
|||
);
|
||||
|
||||
(*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) {
|
||||
if (!newOpid.isEmpty()) {
|
||||
qDebug() << QString::fromStdString("Adding opid ") % newOpid;
|
||||
watchingOps.insert(newOpid);
|
||||
}
|
||||
|
||||
|
@ -418,8 +418,6 @@ void RPC::refreshTxStatus(const QString& newOpid) {
|
|||
};
|
||||
|
||||
doRPC(payload, [=] (const json& reply) {
|
||||
int numExecuting = 0;
|
||||
|
||||
// There's an array for each item in the status
|
||||
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
|
||||
|
@ -457,17 +455,16 @@ void RPC::refreshTxStatus(const QString& newOpid) {
|
|||
} else if (status == "executing") {
|
||||
// If the operation is executing, then watch every second.
|
||||
txTimer->start(1 * 1000);
|
||||
numExecuting++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 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);
|
||||
} else {
|
||||
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) {
|
||||
// 1. Addresses are valid format.
|
||||
QRegExp zcexp("^zc[a-z0-9]{93}$", Qt::CaseInsensitive);
|
||||
QRegExp zsexp("^zc[a-z0-9]{76}$", Qt::CaseInsensitive);
|
||||
QRegExp zcexp("^z[a-z0-9]{94}$", 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);
|
||||
|
||||
auto matchesAnyAddr = [&] (QString addr) {
|
||||
return zcexp.exactMatch(addr) ||
|
||||
texp.exactMatch(addr) ||
|
||||
ztsexp.exactMatch(addr) ||
|
||||
zsexp.exactMatch(addr);
|
||||
};
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@ QString Settings::getHost() {
|
|||
}
|
||||
|
||||
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";
|
||||
return port;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#ifndef SETTINGS_H
|
||||
#define SETTINGS_H
|
||||
|
||||
#include "precompiled.h"
|
||||
|
||||
class Settings
|
||||
{
|
||||
|
@ -11,6 +12,8 @@ public:
|
|||
QString getHost();
|
||||
QString getPort();
|
||||
|
||||
void setDefaultPort(int port) {overridePort = QString::number(port);}
|
||||
|
||||
double fees() { return 0.0001; }
|
||||
void refresh();
|
||||
private:
|
||||
|
@ -18,7 +21,9 @@ private:
|
|||
QString host;
|
||||
QString port;
|
||||
QString username;
|
||||
QString password;
|
||||
QString password;
|
||||
|
||||
QString overridePort;
|
||||
};
|
||||
|
||||
#endif // SETTINGS_H
|
Loading…
Reference in New Issue