Browse Source

Merge branch 'duke' into market

Conflicts:
	src/mainwindow.cpp
pull/140/head
Duke Leto 4 years ago
parent
commit
5e092323b5
  1. 1247
      res/silentdragon_template.ts
  2. 6
      src/connection.cpp
  3. 59
      src/mainwindow.cpp
  4. 2
      src/mainwindow.h
  5. 4
      src/rpc.cpp
  6. 2
      src/rpc.h
  7. 0
      src/scripts/dotranslations.sh
  8. 46
      src/scripts/mkmacdmg.sh
  9. 7
      src/scripts/signbinaries.sh
  10. 10
      src/sendtab.cpp
  11. 12
      src/settings.cpp
  12. 3
      src/websockets.cpp

1247
res/silentdragon_template.ts

File diff suppressed because it is too large

6
src/connection.cpp

@ -21,7 +21,7 @@ ConnectionLoader::ConnectionLoader(MainWindow* main, RPC* rpc) {
connD->setupUi(d);
QPixmap logo(":/img/res/logobig.gif");
connD->topIcon->setBasePixmap(logo.scaled(512, 512, Qt::KeepAspectRatio, Qt::SmoothTransformation));
main->logger->write("set topIcon");
//main->logger->write("set topIcon");
}
ConnectionLoader::~ConnectionLoader() {
@ -129,7 +129,7 @@ QString randomPassword() {
}
/**
* This will create a new HUSH3.conf, download Zcash parameters.
* This will create a new HUSH3.conf and download params if they cannot be found
*/
void ConnectionLoader::createZcashConf() {
main->logger->write("createZcashConf");
@ -460,7 +460,7 @@ Connection* ConnectionLoader::makeConnection(std::shared_ptr<ConnectionConfig> c
}
void ConnectionLoader::refreshZcashdState(Connection* connection, std::function<void(void)> refused) {
main->logger->write("refreshZcashdState");
main->logger->write("refreshing state");
json payload = {
{"jsonrpc", "1.0"},

59
src/mainwindow.cpp

@ -1,4 +1,4 @@
// Copyright 2019 The Hush Developers
// Copyright 2019-2020 The Hush Developers
// Released under the GPLv3
#include "mainwindow.h"
#include "addressbook.h"
@ -227,13 +227,22 @@ void MainWindow::setupStatusBar() {
menu.addAction("Copy txid", [=]() {
QGuiApplication::clipboard()->setText(txid);
});
menu.addAction("View tx on block explorer", [=]() {
menu.addAction("Copy block explorer link", [=]() {
QString url;
auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) {
url = explorer.testnetTxExplorerUrl + txid;
} else {
url = explorer.txExplorerUrl + txid;
}
else {
QGuiApplication::clipboard()->setText(url);
});
menu.addAction("View tx on block explorer", [=]() {
QString url;
auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) {
url = explorer.testnetTxExplorerUrl + txid;
} else {
url = explorer.txExplorerUrl + txid;
}
QDesktopServices::openUrl(QUrl(url));
@ -462,7 +471,7 @@ void MainWindow::setupSettingsModal() {
void MainWindow::addressBook() {
// Check to see if there is a target.
QRegExp re("Address[0-9]+", Qt::CaseInsensitive);
QRegularExpression re("Address[0-9]+", QRegularExpression::CaseInsensitiveOption);
for (auto target: ui->sendToWidgets->findChildren<QLineEdit *>(re)) {
if (target->hasFocus()) {
AddressBook::open(this, target);
@ -909,7 +918,6 @@ void MainWindow::setupBalancesTab() {
QString url;
auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) {
//TODO
url = explorer.testnetAddressExplorerUrl + addr;
} else {
url = explorer.addressExplorerUrl + addr;
@ -917,6 +925,17 @@ void MainWindow::setupBalancesTab() {
QDesktopServices::openUrl(QUrl(url));
});
menu.addAction("Copy explorer link", [=]() {
QString url;
auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) {
url = explorer.testnetAddressExplorerUrl + addr;
} else {
url = explorer.addressExplorerUrl + addr;
}
QGuiApplication::clipboard()->setText(url);
});
menu.addAction(tr("Address Asset Viewer"), [=] () {
QString url;
url = "https://dexstats.info/assetviewer.php?address=" + addr;
@ -1001,6 +1020,17 @@ void MainWindow::setupTransactionsTab() {
QDesktopServices::openUrl(QUrl(url));
});
menu.addAction(tr("Copy block explorer link"), [=] () {
QString url;
auto explorer = Settings::getInstance()->getExplorer();
if (Settings::getInstance()->isTestnet()) {
url = explorer.testnetTxExplorerUrl + txid;
} else {
url = explorer.txExplorerUrl + txid;
}
QGuiApplication::clipboard()->setText(url);
});
// Payment Request
if (!memo.isEmpty() && memo.startsWith("hush:")) {
menu.addAction(tr("View Payment Request"), [=] () {
@ -1023,8 +1053,7 @@ void MainWindow::setupTransactionsTab() {
int lastPost = memo.trimmed().lastIndexOf(QRegExp("[\r\n]+"));
QString lastWord = memo.right(memo.length() - lastPost - 1);
if (Settings::getInstance()->isSaplingAddress(lastWord) ||
Settings::getInstance()->isSproutAddress(lastWord)) {
if (Settings::getInstance()->isSaplingAddress(lastWord)) {
menu.addAction(tr("Reply to ") + lastWord.left(25) + "...", [=]() {
// First, cancel any pending stuff in the send tab by pretending to click
// the cancel button
@ -1050,26 +1079,24 @@ void MainWindow::setupTransactionsTab() {
});
}
void MainWindow::addNewZaddr(bool sapling) {
rpc->newZaddr(sapling, [=] (json reply) {
void MainWindow::addNewZaddr() {
rpc->newZaddr( [=] (json reply) {
QString addr = QString::fromStdString(reply.get<json::string_t>());
// Make sure the RPC class reloads the z-addrs for future use
rpc->refreshAddresses();
// Just double make sure the z-address is still checked
if ( sapling && ui->rdioZSAddr->isChecked() ) {
if ( ui->rdioZSAddr->isChecked() ) {
ui->listReceiveAddresses->insertItem(0, addr);
ui->listReceiveAddresses->setCurrentIndex(0);
ui->statusBar->showMessage(QString::fromStdString("Created new zAddr") %
(sapling ? "(Sapling)" : "(Sprout)"),
10 * 1000);
ui->statusBar->showMessage(QString::fromStdString("Created new Sapling zaddr"), 10 * 1000);
}
});
}
// Adds sapling or sprout z-addresses to the combo box. Technically, returns a
// Adds z-addresses to the combo box. Technically, returns a
// lambda, which can be connected to the appropriate signal
std::function<void(bool)> MainWindow::addZAddrsToComboList(bool sapling) {
return [=] (bool checked) {
@ -1089,7 +1116,7 @@ std::function<void(bool)> MainWindow::addZAddrsToComboList(bool sapling) {
// If z-addrs are empty, then create a new one.
if (addrs->isEmpty()) {
addNewZaddr(sapling);
addNewZaddr();
}
}
};
@ -1174,7 +1201,7 @@ void MainWindow::setupReceiveTab() {
return;
if (ui->rdioZSAddr->isChecked()) {
addNewZaddr(true);
addNewZaddr();
} else if (ui->rdioTAddr->isChecked()) {
addNewTAddr();
}

2
src/mainwindow.h

@ -108,7 +108,7 @@ private:
void addressChanged(int number, const QString& text);
void amountChanged (int number, const QString& text);
void addNewZaddr(bool sapling);
void addNewZaddr();
std::function<void(bool)> addZAddrsToComboList(bool sapling);
void memoButtonClicked(int number, bool includeReplyTo = false);

4
src/rpc.cpp

@ -154,12 +154,12 @@ void RPC::getZUnspent(const std::function<void(json)>& cb) {
conn->doRPCWithDefaultErrorHandling(payload, cb);
}
void RPC::newZaddr(bool sapling, const std::function<void(json)>& cb) {
void RPC::newZaddr(const std::function<void(json)>& cb) {
json payload = {
{"jsonrpc", "1.0"},
{"id", "someid"},
{"method", "z_getnewaddress"},
{"params", { sapling ? "sapling" : "sprout" }},
{"params", { "sapling" }},
};
conn->doRPCWithDefaultErrorHandling(payload, cb);

2
src/rpc.h

@ -68,7 +68,7 @@ public:
const QMap<QString, double>* getAllBalances() { return allBalances; }
const QMap<QString, bool>* getUsedAddresses() { return usedAddresses; }
void newZaddr(bool sapling, const std::function<void(json)>& cb);
void newZaddr(const std::function<void(json)>& cb);
void newTaddr(const std::function<void(json)>& cb);
void getZPrivKey(QString addr, const std::function<void(json)>& cb);

0
src/scripts/dotranslations.sh

46
src/scripts/mkmacdmg.sh

@ -17,7 +17,17 @@ case $key in
shift # past argument
shift # past value
;;
-c|--certificate)
-u|--username)
APPLE_USERNAME="$2"
shift # past argument
shift # past value
;;
-p|--password)
APPLE_PASSWORD="$2"
shift # past argument
shift # past value
;;
-c|--certificate)
CERTIFICATE="$2"
shift # past argument
shift # past value
@ -45,6 +55,16 @@ if [ -z $HUSH_DIR ]; then
exit 1;
fi
if [ -z "$APPLE_USERNAME" ]; then
echo "APPLE_USERNAME is not set. Please set it the name of the MacOS developer login email to submit the binary for Apple for notarization";
exit 1;
fi
if [ -z "$APPLE_PASSWORD" ]; then
echo "APPLE_PASSWORD is not set. Please set it the name of the MacOS developer Application password to submit the binary for Apple for notarization";
exit 1;
fi
if [ -z "$CERTIFICATE" ]; then
echo "CERTIFICATE is not set. Please set it the name of the MacOS developer certificate to sign the binary with";
exit 1;
@ -94,31 +114,25 @@ cp $HUSH_DIR/src/hushd silentdragon.app/Contents/MacOS/
cp $HUSH_DIR/src/hush-cli silentdragon.app/Contents/MacOS/
cp $HUSH_DIR/src/komodod silentdragon.app/Contents/MacOS/
cp $HUSH_DIR/src/komodo-cli silentdragon.app/Contents/MacOS/
cp $HUSH_DIR/sapling-output.params silentdragon.app/Contents/MacOS/
cp $HUSH_DIR/sapling-spend.params silentdragon.app/Contents/MacOS/
$QT_PATH/bin/macdeployqt silentdragon.app
codesign --deep --force --verify --verbose -s "$CERTIFICATE" --options runtime --timestamp silentdragon.app
echo "[OK]"
# Code Signing Note:
# On MacOS, you still need to run these 3 commands:
# xcrun altool --notarize-app -t osx -f macOS-zecwallet-v0.8.0.dmg --primary-bundle-id="com.yourcompany.zecwallet" -u "apple developer id@email.com" -p "one time password"
# xcrun altool --notarization-info <output from pervious command> -u "apple developer id@email.com" -p "one time password"
#...wait for the notarization to finish...
# xcrun stapler staple macOS-zecwallet-v0.8.0.dmg
# On MacOS, you still need to run signbinaries.sh to staple.
#
echo -n "Building dmg..........."
mv silentdragon.app silentdragon.app
create-dmg --volname "silentdragon-v$APP_VERSION" --volicon "res/logo.icns" --window-pos 200 120 --icon "silentdragon.app" 200 190 --app-drop-link 600 185 --hide-extension "silentdragon.app" --window-size 800 400 --hdiutil-quiet --background res/dmgbg.png artifacts/macOS-silentdragon-v$APP_VERSION.dmg silentdragon.app >/dev/null 2>&1
#mkdir bin/dmgbuild >/dev/null 2>&1
#sed "s/RELEASE_VERSION/${APP_VERSION}/g" res/appdmg.json > bin/dmgbuild/appdmg.json
#cp res/logo.icns bin/dmgbuild/
#cp res/dmgbg.png bin/dmgbuild/
#cp -r silentdragon.app bin/dmgbuild/
#appdmg --quiet bin/dmgbuild/appdmg.json artifacts/macOS-silentdragon-v$APP_VERSION.dmg >/dev/null
if [ ! -f artifacts/macOS-silentdragon-v$APP_VERSION.dmg ]; then
echo "[ERROR]"
exit 1
fi
echo "[OK]"
# Submit to Apple for notarization
echo -n "Apple notarization....."
xcrun altool --notarize-app -t osx -f artifacts/macOS-silentdragon-v$APP_VERSION.dmg --primary-bundle-id="com.myHush.silentdragon" -u "$APPLE_USERNAME" -p "$APPLE_PASSWORD"
echo "[OK]"

7
src/scripts/signbinaries.sh

@ -24,7 +24,12 @@ if [ -z $APP_VERSION ]; then echo "APP_VERSION is not set"; exit 1; fi
# Store the hash and signatures here
rm -rf release/signatures
mkdir -p release/signatures
mkdir -p release/signatures
# Staple the notarization
xcrun stapler staple artifacts/macOS-silentdragon-v$APP_VERSION.dmg
cd artifacts
cd artifacts

10
src/sendtab.cpp

@ -132,7 +132,7 @@ void MainWindow::updateLabelsAutoComplete() {
labelCompleter->setCaseSensitivity(Qt::CaseInsensitive);
// Then, find all the address fields and update the completer.
QRegExp re("Address[0-9]+", Qt::CaseInsensitive);
QRegularExpression re("Address[0-9]+", QRegularExpression::CaseInsensitiveOption);
for (auto target: ui->sendToWidgets->findChildren<QLineEdit *>(re)) {
target->setCompleter(labelCompleter);
}
@ -497,9 +497,6 @@ Tx MainWindow::createTxFromSendPage() {
// Remove label if it exists
addr = AddressBook::addressFromAddressLabel(addr);
// If address is sprout, then we can't send change to sapling, because of turnstile.
//sendChangeToSapling = sendChangeToSapling && !Settings::getInstance()->isSproutAddress(addr);
double amt = ui->sendToWidgets->findChild<QLineEdit*>(QString("Amount") % QString::number(i+1))->text().trimmed().toDouble();
totalAmt += amt;
QString memo = ui->sendToWidgets->findChild<QLabel*>(QString("MemoTxt") % QString::number(i+1))->text().trimmed();
@ -732,7 +729,10 @@ void MainWindow::sendButton() {
QString MainWindow::doSendTxValidations(Tx tx) {
//TODO: Feedback fromAddr is empty for some reason
if (!Settings::isValidAddress(tx.fromAddr)) return QString(tr("From Address is Invalid"));
if (!Settings::isValidAddress(tx.fromAddr)){
qDebug() << "address is invalid! " << tx.fromAddr;
return QString(tr("From Address is Invalid!"));
}
for (auto toAddr : tx.toAddrs) {
if (!Settings::isValidAddress(toAddr.addr)) {

12
src/settings.cpp

@ -35,9 +35,11 @@ void Settings::setAllowFetchPrices(bool allow) {
Explorer Settings::getExplorer() {
// Load from the QT Settings.
QSettings s;
//TODO: make it easy for people to use other explorers like komodod.com
QString explorer = "https://explorer.myhush.org";
auto txExplorerUrl = s.value("explorer/txExplorerUrl").toString();
auto addressExplorerUrl = s.value("explorer/addressExplorerUrl").toString();
auto txExplorerUrl = s.value("explorer/txExplorerUrl", explorer + "/tx/").toString();
auto addressExplorerUrl = s.value("explorer/addressExplorerUrl", explorer + "/address/").toString();
auto testnetTxExplorerUrl = s.value("explorer/testnetTxExplorerUrl").toString();
auto testnetAddressExplorerUrl = s.value("explorer/testnetAddressExplorerUrl").toString();
@ -225,7 +227,7 @@ unsigned int Settings::getBTCPrice() {
bool Settings::getAutoShield() {
// Load from Qt settings
return QSettings().value("options/autoshield", false).toBool();
return QSettings().value("options/autoshield", true).toBool();
}
void Settings::setAutoShield(bool allow) {
@ -234,7 +236,7 @@ void Settings::setAutoShield(bool allow) {
bool Settings::getAllowCustomFees() {
// Load from the QT Settings.
return QSettings().value("options/customfees", false).toBool();
return QSettings().value("options/customfees", true).toBool();
}
void Settings::setAllowCustomFees(bool allow) {
@ -399,7 +401,7 @@ bool Settings::isValidAddress(QString addr) {
QRegExp zsexp("^zs1[a-z0-9]{75}$", Qt::CaseInsensitive);
QRegExp ztsexp("^ztestsapling[a-z0-9]{76}", Qt::CaseInsensitive);
QRegExp texp("^R[a-z0-9]{33}$", Qt::CaseInsensitive);
//qDebug() << "isValidAddress(" << addr << ")";
qDebug() << "isValidAddress(" << addr << ")";
return texp.exactMatch(addr) || ztsexp.exactMatch(addr) || zsexp.exactMatch(addr);
}

3
src/websockets.cpp

@ -747,9 +747,6 @@ void AppDataServer::processSendTx(QJsonObject sendTx, MainWindow* mainwindow, st
auto allBalances = mainwindow->getRPC()->getAllBalances();
QList<QPair<QString, double>> bals;
for (auto i : allBalances->keys()) {
// Filter out sprout addresses
if (Settings::getInstance()->isSproutAddress(i))
continue;
// Filter out balances that don't have the requisite amount
// TODO: should this be amt+tx.fee?
if (allBalances->value(i) < amt)

Loading…
Cancel
Save