Add support for z-board.net
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include "mainwindow.h"
|
||||
#include "ui_mainwindow.h"
|
||||
#include "ui_zboard.h"
|
||||
#include "ui_privkey.h"
|
||||
#include "ui_about.h"
|
||||
#include "ui_settings.h"
|
||||
@@ -46,6 +47,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||
// Export All Private Keys
|
||||
QObject::connect(ui->actionExport_All_Private_Keys, &QAction::triggered, this, &MainWindow::exportAllKeys);
|
||||
|
||||
// z-Board.net
|
||||
QObject::connect(ui->actionz_board_net, &QAction::triggered, this, &MainWindow::postToZBoard);
|
||||
|
||||
// Set up about action
|
||||
QObject::connect(ui->actionAbout, &QAction::triggered, [=] () {
|
||||
QDialog aboutDialog(this);
|
||||
@@ -417,6 +421,59 @@ void MainWindow::donate() {
|
||||
ui->tabWidget->setCurrentIndex(1);
|
||||
}
|
||||
|
||||
void MainWindow::postToZBoard() {
|
||||
QDialog d(this);
|
||||
Ui_zboard zb;
|
||||
zb.setupUi(&d);
|
||||
|
||||
// Fill the from field with sapling addresses.
|
||||
for (auto i = rpc->getAllBalances()->keyBegin(); i != rpc->getAllBalances()->keyEnd(); i++) {
|
||||
if (Settings::getInstance()->isSaplingAddress(*i) && rpc->getAllBalances()->value(*i) > 0) {
|
||||
zb.fromAddr->addItem(*i);
|
||||
}
|
||||
}
|
||||
|
||||
// Testnet warning
|
||||
if (Settings::getInstance()->isTestnet()) {
|
||||
zb.testnetWarning->setText("You are on testnet, your post won't actually appear on z-board.net");
|
||||
}
|
||||
else {
|
||||
zb.testnetWarning->setText("");
|
||||
}
|
||||
|
||||
zb.feeAmount->setText(Settings::getInstance()->getZECUSDDisplayFormat(Utils::getZboardAmount() + Utils::getMinerFee()));
|
||||
if (d.exec() == QDialog::Accepted) {
|
||||
// Create a transaction.
|
||||
Tx tx;
|
||||
|
||||
// Send from your first sapling address that has a balance.
|
||||
tx.fromAddr = zb.fromAddr->currentText();
|
||||
if (tx.fromAddr.isEmpty()) {
|
||||
QMessageBox::critical(this, "Error Posting Message", "You need a sapling address with available balance to post", QMessageBox::Ok);
|
||||
}
|
||||
|
||||
auto memo = zb.memoTxt->toPlainText().trimmed();
|
||||
if (!zb.postAs->text().trimmed().isEmpty())
|
||||
memo = "Name::" + zb.postAs->text().trimmed() + " " + memo;
|
||||
|
||||
tx.toAddrs.push_back(ToFields{ Utils::getZboardAddr(), Utils::getZboardAmount(), memo, memo.toUtf8().toHex() });
|
||||
tx.fee = Utils::getMinerFee();
|
||||
|
||||
json params = json::array();
|
||||
rpc->fillTxJsonParams(params, tx);
|
||||
std::cout << std::setw(2) << params << std::endl;
|
||||
|
||||
// And send the Tx
|
||||
rpc->sendZTransaction(params, [=](const json& reply) {
|
||||
QString opid = QString::fromStdString(reply.get<json::string_t>());
|
||||
ui->statusBar->showMessage("Computing Tx: " % opid);
|
||||
|
||||
// And then start monitoring the transaction
|
||||
rpc->addNewTxToWatch(tx, opid);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::doImport(QList<QString>* keys) {
|
||||
qDebug() << keys->size();
|
||||
if (keys->isEmpty()) {
|
||||
|
||||
@@ -81,6 +81,7 @@ private:
|
||||
QString doSendTxValidations(Tx tx);
|
||||
|
||||
void donate();
|
||||
void postToZBoard();
|
||||
void importPrivKey();
|
||||
void exportAllKeys();
|
||||
void doImport(QList<QString>* keys);
|
||||
|
||||
@@ -316,8 +316,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>841</width>
|
||||
<height>321</height>
|
||||
<width>843</width>
|
||||
<height>363</height>
|
||||
</rect>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="sendToLayout">
|
||||
@@ -718,7 +718,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>889</width>
|
||||
<height>22</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuFile">
|
||||
@@ -727,7 +727,6 @@
|
||||
</property>
|
||||
<addaction name="actionImport_Private_Key"/>
|
||||
<addaction name="actionExport_All_Private_Keys"/>
|
||||
<addaction name="actionTurnstile_Migration"/>
|
||||
<addaction name="actionSettings"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="actionExit"/>
|
||||
@@ -740,7 +739,15 @@
|
||||
<addaction name="actionCheck_for_Updates"/>
|
||||
<addaction name="actionAbout"/>
|
||||
</widget>
|
||||
<widget class="QMenu" name="menuApps">
|
||||
<property name="title">
|
||||
<string>Apps</string>
|
||||
</property>
|
||||
<addaction name="actionTurnstile_Migration"/>
|
||||
<addaction name="actionz_board_net"/>
|
||||
</widget>
|
||||
<addaction name="menuFile"/>
|
||||
<addaction name="menuApps"/>
|
||||
<addaction name="menuHelp"/>
|
||||
</widget>
|
||||
<widget class="QStatusBar" name="statusBar"/>
|
||||
@@ -787,6 +794,11 @@
|
||||
<string>Export All Private Keys</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionz_board_net">
|
||||
<property name="text">
|
||||
<string>z-board.net</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<layoutdefault spacing="6" margin="11"/>
|
||||
<customwidgets>
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Dialog</string>
|
||||
<string>Memo</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
|
||||
@@ -245,7 +245,17 @@ void MainWindow::memoButtonClicked(int number) {
|
||||
QString txt = memoDialog.memoTxt->toPlainText();
|
||||
memoDialog.memoSize->setText(QString::number(txt.toUtf8().size()) + "/512");
|
||||
|
||||
memoDialog.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(txt.toUtf8().size() <= 512);
|
||||
if (txt.toUtf8().size() <= 512) {
|
||||
// Everything is fine
|
||||
memoDialog.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(true);
|
||||
memoDialog.memoSize->setStyleSheet("");
|
||||
}
|
||||
else {
|
||||
// Overweight
|
||||
memoDialog.buttonBox->button(QDialogButtonBox::Ok)->setEnabled(false);
|
||||
memoDialog.memoSize->setStyleSheet("color: red;");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
memoDialog.memoTxt->setPlainText(currentMemo);
|
||||
|
||||
@@ -67,6 +67,19 @@ const QString Utils::getDevAddr(Tx tx) {
|
||||
double Utils::getMinerFee() {
|
||||
return 0.0001;
|
||||
}
|
||||
|
||||
double Utils::getZboardAmount() {
|
||||
return 0.0001;
|
||||
}
|
||||
|
||||
QString Utils::getZboardAddr() {
|
||||
if (Settings::getInstance()->isTestnet()) {
|
||||
return getDonationAddr(true);
|
||||
}
|
||||
else {
|
||||
return "zs10m00rvkhfm4f7n23e4sxsx275r7ptnggx39ygl0vy46j9mdll5c97gl6dxgpk0njuptg2mn9w5s";
|
||||
}
|
||||
}
|
||||
double Utils::getDevFee() {
|
||||
if (Settings::getInstance()->isTestnet()) {
|
||||
return 0.0001;
|
||||
|
||||
@@ -17,6 +17,8 @@ public:
|
||||
static const QString getDonationAddr(bool sapling);
|
||||
|
||||
static double getMinerFee();
|
||||
static double getZboardAmount();
|
||||
static QString getZboardAddr();
|
||||
static double getDevFee();
|
||||
static double getTotalFee();
|
||||
|
||||
|
||||
155
src/zboard.ui
Normal file
155
src/zboard.ui
Normal file
@@ -0,0 +1,155 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>zboard</class>
|
||||
<widget class="QDialog" name="zboard">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>520</width>
|
||||
<height>376</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Post to z-board.net</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="4" column="0" colspan="2">
|
||||
<widget class="QComboBox" name="fromAddr"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Send From</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="2">
|
||||
<widget class="Line" name="line">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="2">
|
||||
<widget class="QLineEdit" name="postAs">
|
||||
<property name="placeholderText">
|
||||
<string>(optional)</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Memo</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<widget class="QLabel" name="memoSize">
|
||||
<property name="text">
|
||||
<string>0 / 512</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="10" column="0" colspan="2">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Post As:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Total Fee</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="0" colspan="2">
|
||||
<widget class="QPlainTextEdit" name="memoTxt"/>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<widget class="QLabel" name="feeAmount">
|
||||
<property name="text">
|
||||
<string>feeamount</string>
|
||||
</property>
|
||||
<property name="alignment">
|
||||
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="2">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string><html><head/><body><p>ZBoard is Fully anonymous and untraceable chat messages based on the ZCash blockchain. <a href="http://www.z-board.net/"><span style=" text-decoration: underline; color:#0000ff;">http://www.z-board.net/</span></a></p><p>Posting to ZBoard: #Main_Area</p></body></html></string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openExternalLinks">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="2">
|
||||
<widget class="QLabel" name="testnetWarning">
|
||||
<property name="styleSheet">
|
||||
<string notr="true">color:red;</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>TextLabel</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<resources/>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>zboard</receiver>
|
||||
<slot>accept()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>248</x>
|
||||
<y>254</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>157</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>rejected()</signal>
|
||||
<receiver>zboard</receiver>
|
||||
<slot>reject()</slot>
|
||||
<hints>
|
||||
<hint type="sourcelabel">
|
||||
<x>316</x>
|
||||
<y>260</y>
|
||||
</hint>
|
||||
<hint type="destinationlabel">
|
||||
<x>286</x>
|
||||
<y>274</y>
|
||||
</hint>
|
||||
</hints>
|
||||
</connection>
|
||||
</connections>
|
||||
</ui>
|
||||
@@ -82,7 +82,8 @@ FORMS += \
|
||||
src/turnstileprogress.ui \
|
||||
src/privkey.ui \
|
||||
src/memodialog.ui \
|
||||
src/connection.ui
|
||||
src/connection.ui \
|
||||
src/zboard.ui
|
||||
|
||||
win32: RC_ICONS = res/icon.ico
|
||||
|
||||
|
||||
Reference in New Issue
Block a user