Compare commits

...

7 Commits
master ... dev

  1. 1
      application.qrc
  2. 7
      lib/Cargo.lock
  3. 2
      lib/Cargo.toml
  4. BIN
      res/silentdragonlite_ud.qm
  5. 3056
      res/silentdragonlite_ud.ts
  6. 1
      silentdragon-lite.pro
  7. 102
      src/connection.cpp
  8. 7
      src/connection.h
  9. 69
      src/controller.cpp
  10. 16
      src/controller.h
  11. 4
      src/datamodel.h
  12. 21
      src/liteinterface.cpp
  13. 5
      src/liteinterface.h
  14. 178
      src/mainwindow.cpp
  15. 45
      src/mainwindow.ui
  16. 17
      src/privkey.ui

1
application.qrc

@ -93,6 +93,7 @@
<file>res/silentdragonlite_id.qm</file>
<file>res/silentdragonlite_ar.qm</file>
<file>res/silentdragonlite_ro.qm</file>
<file>res/silentdragonlite_ud.qm</file>
</qresource>
<qresource prefix="/css">
<file>res/css/Blue.css</file>

7
lib/Cargo.lock

@ -1192,7 +1192,7 @@ dependencies = [
"blake3 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.66 (registry+https://github.com/rust-lang/crates.io-index)",
"silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=1d678e4280975a532cdff58f55b2b129c033c9f8)",
"silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=8535a11e3774d79de2ebeaa5540567ccb4988f81)",
]
[[package]]
@ -1655,10 +1655,11 @@ dependencies = [
[[package]]
name = "silentdragonlitelib"
version = "0.1.0"
source = "git+https://github.com/MyHush/silentdragonlite-cli?rev=1d678e4280975a532cdff58f55b2b129c033c9f8#1d678e4280975a532cdff58f55b2b129c033c9f8"
source = "git+https://github.com/MyHush/silentdragonlite-cli?rev=8535a11e3774d79de2ebeaa5540567ccb4988f81#8535a11e3774d79de2ebeaa5540567ccb4988f81"
dependencies = [
"base58 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
"bellman 0.1.0 (git+https://github.com/MyHush/librustzcash.git?rev=1a0204113d487cdaaf183c2967010e5214ff9e37)",
"bs58 0.2.5 (registry+https://github.com/rust-lang/crates.io-index)",
"byteorder 1.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"bytes 0.4.12 (registry+https://github.com/rust-lang/crates.io-index)",
"dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
@ -2671,7 +2672,7 @@ dependencies = [
"checksum serde_yaml 0.8.11 (registry+https://github.com/rust-lang/crates.io-index)" = "691b17f19fc1ec9d94ec0b5864859290dff279dbd7b03f017afda54eb36c3c35"
"checksum sha2 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "27044adfd2e1f077f649f59deb9490d3941d674002f7d062870a60ebe9bd47a0"
"checksum signal-hook-registry 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "94f478ede9f64724c5d173d7bb56099ec3e2d9fc2774aac65d34b8b890405f41"
"checksum silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=1d678e4280975a532cdff58f55b2b129c033c9f8)" = "<none>"
"checksum silentdragonlitelib 0.1.0 (git+https://github.com/MyHush/silentdragonlite-cli?rev=8535a11e3774d79de2ebeaa5540567ccb4988f81)" = "<none>"
"checksum slab 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "c111b5bd5695e56cffe5129854aa230b39c93a305372fdbb2668ca2394eea9f8"
"checksum smallvec 0.6.13 (registry+https://github.com/rust-lang/crates.io-index)" = "f7b0758c52e15a8b5e3691eae6cc559f08eee9406e548a4477ba4e67770a82b6"
"checksum socket2 0.3.11 (registry+https://github.com/rust-lang/crates.io-index)" = "e8b74de517221a2cb01a53349cf54182acdc31a074727d3079068448c0676d85"

2
lib/Cargo.toml

@ -12,4 +12,4 @@ crate-type = ["staticlib"]
libc = "0.2.58"
lazy_static = "1.4.0"
blake3 = "0.3.4"
silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "1d678e4280975a532cdff58f55b2b129c033c9f8" }
silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "8535a11e3774d79de2ebeaa5540567ccb4988f81" }

BIN
res/silentdragonlite_ud.qm

Binary file not shown.

3056
res/silentdragonlite_ud.ts

File diff suppressed because it is too large

1
silentdragon-lite.pro

@ -168,6 +168,7 @@ TRANSLATIONS = res/silentdragonlite_es.ts \
res/silentdragonlite_id.ts \
res/silentdragonlite_ar.ts \
res/silentdragonlite_ro.ts \
res/silentdragonlite_ud.ts \
res/silentdragonlite_tr.ts
include(singleapplication/singleapplication.pri)

102
src/connection.cpp

@ -65,6 +65,72 @@ void ConnectionLoader::loadConnection()
d->exec();
}
void ConnectionLoader::loadProgress()
{
QTimer::singleShot(1, [=]() { this->ShowProgress(); });
if (!Settings::getInstance()->isHeadless())
d->exec();
}
void ConnectionLoader::ShowProgress()
{
auto config = std::shared_ptr<ConnectionConfig>(new ConnectionConfig());
config->dangerous = false;
config->server = Settings::getInstance()->getSettings().server;
auto connection = makeConnection(config);
auto me = this;
isSyncing = new QAtomicInteger<bool>();
isSyncing->store(true);
main->logger->write("isSyncing");
// Do a sync after import
syncTimer = new QTimer(main);
main->logger->write("Beginning sync after import wif");
connection->doRPCWithDefaultErrorHandling("sync", "", [=](auto) {
isSyncing->store(false);
// Cancel the timer
syncTimer->deleteLater();
// When sync is done, set the connection
this->doRPCSetConnectionShield(connection);
});
// While it is syncing, we'll show the status updates while it is alive.
QObject::connect(syncTimer, &QTimer::timeout, [=]() {
// Check the sync status
if (isSyncing != nullptr && isSyncing->load()) {
// Get the sync status
try {
connection->doRPC("syncstatus", "", [=](json reply) {
if (isSyncing != nullptr && reply.find("synced_blocks") != reply.end())
{
qint64 synced = reply["synced_blocks"].get<json::number_unsigned_t>();
qint64 total = reply["total_blocks"].get<json::number_unsigned_t>();
me->showInformation(
"Synced " + QString::number(synced) + " / " + QString::number(total)
);
}
},
[=](QString err) {
qDebug() << "Sync error" << err;
});
}catch (...)
{
main->logger->write("catch sync progress reply");
}
}
});
syncTimer->setInterval(1* 1000);
syncTimer->start();
main->logger->write("Start sync timer");
}
void ConnectionLoader::doAutoConnect()
{
qDebug() << "Doing autoconnect";
@ -109,14 +175,14 @@ void ConnectionLoader::doAutoConnect()
connection->setInfo(reply);
main->logger->write("getting Connection reply");
isSyncing = new QAtomicInteger<bool>();
isSyncing->storeRelaxed(true);
isSyncing->store(true);
main->logger->write("isSyncing");
// Do a sync at startup
syncTimer = new QTimer(main);
main->logger->write("Beginning sync");
connection->doRPCWithDefaultErrorHandling("sync", "", [=](auto) {
isSyncing->storeRelaxed(false);
isSyncing->store(false);
// Cancel the timer
syncTimer->deleteLater();
// When sync is done, set the connection
@ -126,7 +192,7 @@ void ConnectionLoader::doAutoConnect()
// While it is syncing, we'll show the status updates while it is alive.
QObject::connect(syncTimer, &QTimer::timeout, [=]() {
// Check the sync status
if (isSyncing != nullptr && isSyncing->loadRelaxed()) {
if (isSyncing != nullptr && isSyncing->load()) {
// Get the sync status
try {
@ -196,6 +262,30 @@ try
}
void ConnectionLoader::doRPCSetConnectionShield(Connection* conn)
{
qDebug() << "Importing finished, setting connection";
rpc->setConnection(conn);
d->accept();
main->getRPC()->shield([=] (auto) {});
QTimer::singleShot(1, [=]() { delete this; });
try
{
QFile plaintextWallet(dirwalletconnection);
main->logger->write("Path to Wallet.dat : " );
plaintextWallet.remove();
}catch (...)
{
main->logger->write("no Plaintext wallet.dat");
}
}
Connection* ConnectionLoader::makeConnection(std::shared_ptr<ConnectionConfig> config)
{
return new Connection(main, config);
@ -255,7 +345,6 @@ void Executor::run()
emit responseReady(parsed);
}
void Callback::processRPCCallback(json resp)
{
this->cb(resp);
@ -284,7 +373,10 @@ void Connection::doRPC(const QString cmd, const QString args, const std::functio
// Ignoring RPC because shutdown in progress
return;
//qDebug() << "Doing RPC: " << cmd;
// qDebug() << "Doing RPC: " << cmd;
// Create a runner.
auto runner = new Executor(cmd, args);

7
src/connection.h

@ -24,6 +24,7 @@ public:
~ConnectionLoader();
void loadConnection();
void loadProgress();
private:
std::shared_ptr<ConnectionConfig> autoDetecthushConf();
@ -32,6 +33,7 @@ private:
Connection* makeConnection(std::shared_ptr<ConnectionConfig> config);
void doAutoConnect();
void ShowProgress();
void createOrRestore(bool dangerous, QString server);
@ -39,6 +41,7 @@ private:
void showInformation(QString info, QString detail = "");
void doRPCSetConnection(Connection* conn);
void doRPCSetConnectionShield(Connection* conn);
QTimer* syncTimer = nullptr;
QAtomicInteger<bool>* isSyncing = nullptr;
@ -82,7 +85,7 @@ class Executor : public QObject, public QRunnable {
public:
Executor(QString cmd, QString args) {
this->cmd = cmd;
this->args = args;
this->args = args;
};
~Executor() = default;
@ -118,9 +121,9 @@ public:
void doRPC(const QString cmd, const QString args, const std::function<void(json)>& cb,
const std::function<void(QString)>& errCb);
void doRPCWithDefaultErrorHandling(const QString cmd, const QString args, const std::function<void(json)>& cb);
void doRPCIgnoreError(const QString cmd, const QString args, const std::function<void(json)>& cb) ;
void showTxError(const QString& error);
json getInfo() { return serverInfo; }

69
src/controller.cpp

@ -32,6 +32,9 @@ Controller::Controller(MainWindow* main)
balancesTableModel = new BalancesTableModel(main->ui->balancesTable);
main->ui->balancesTable->setModel(balancesTableModel);
// Call the supply once
// supplyUpdate();
// Setup transactions table model
transactionsTableModel = new TxTableModel(ui->transactionsTable);
main->ui->transactionsTable->setModel(transactionsTableModel);
@ -52,6 +55,13 @@ Controller::Controller(MainWindow* main)
});
timer->start(Settings::updateSpeed);
// Set up to fetch supply
timer = new QTimer(main);
QObject::connect(timer, &QTimer::timeout, [=]() {
supplyUpdate();
});
timer->start(Settings::priceRefreshSpeed);
// Create the data model
model = new DataModel();
@ -81,6 +91,7 @@ void Controller::setConnection(Connection* c)
// If we're allowed to get the Hush Price, get the prices
if (Settings::getInstance()->getAllowFetchPrices())
refreshZECPrice();
supplyUpdate();
// If we're allowed to check for updates, check for a new release
if (Settings::getInstance()->getCheckForUpdates())
@ -577,29 +588,7 @@ void Controller::getInfoThenRefresh(bool force)
bool isLocked = reply["locked"].get<json::boolean_t>();
model->setEncryptionStatus(isEncrypted, isLocked);
});
// Get the total supply and render it with thousand decimal
zrpc->fetchSupply([=] (const json& reply) {
int supply = reply["supply"].get<json::number_integer_t>();
int zfunds = reply["zfunds"].get<json::number_integer_t>();
int total = reply["total"].get<json::number_integer_t>();;
if (
Settings::getInstance()->get_currency_name() == "EUR" ||
Settings::getInstance()->get_currency_name() == "CHF" ||
Settings::getInstance()->get_currency_name() == "RUB"
)
{
ui->supply_taddr->setText((QLocale(QLocale::German).toString(supply)+ " Hush"));
ui->supply_zaddr->setText((QLocale(QLocale::German).toString(zfunds)+ " Hush"));
ui->supply_total->setText((QLocale(QLocale::German).toString(total)+ " Hush"));
}
else
{
ui->supply_taddr->setText("Hush " + (QLocale(QLocale::English).toString(supply)));
ui->supply_zaddr->setText("Hush " +(QLocale(QLocale::English).toString(zfunds)));
ui->supply_total->setText("Hush " +(QLocale(QLocale::English).toString(total)));
}
});
if ( doUpdate )
{
@ -692,6 +681,36 @@ void Controller::updateUI(bool anyUnconfirmed)
);
};
void Controller::supplyUpdate() {
qDebug()<<"Supply";
// Get the total supply and render it with thousand decimal
zrpc->fetchSupply([=] (const json& reply) {
int supply = reply["supply"].get<json::number_integer_t>();
int zfunds = reply["zfunds"].get<json::number_integer_t>();
int total = reply["total"].get<json::number_integer_t>();;
if (
Settings::getInstance()->get_currency_name() == "EUR" ||
Settings::getInstance()->get_currency_name() == "CHF" ||
Settings::getInstance()->get_currency_name() == "RUB"
)
{
ui->supply_taddr->setText((QLocale(QLocale::German).toString(supply)+ " Hush"));
ui->supply_zaddr->setText((QLocale(QLocale::German).toString(zfunds)+ " Hush"));
ui->supply_total->setText((QLocale(QLocale::German).toString(total)+ " Hush"));
}
else
{
ui->supply_taddr->setText("Hush " + (QLocale(QLocale::English).toString(supply)));
ui->supply_zaddr->setText("Hush " +(QLocale(QLocale::English).toString(zfunds)));
ui->supply_total->setText("Hush " +(QLocale(QLocale::English).toString(total)));
}
});
}
// Function to process reply of the listunspent and z_listunspent API calls, used below.
void Controller::processUnspent(const json& reply, QMap<QString, CAmount>* balancesMap, QList<UnspentOutput>* unspentOutputs) {
auto processFn = [=](const json& array) {
@ -727,6 +746,7 @@ void Controller::updateUIBalances()
CAmount balT = getModel()->getBalT();
CAmount balZ = getModel()->getBalZ();
CAmount balVerified = getModel()->getBalVerified();
CAmount balSpendable = getModel()->getBalSpendable();
// Reduce the BalanceZ by the pending outgoing amount. We're adding
// here because totalPending is already negative for outgoing txns.
@ -743,6 +763,7 @@ void Controller::updateUIBalances()
ui->balSheilded->setText(balZ.toDecimalhushString());
ui->balVerified->setText(balVerified.toDecimalhushString());
ui->balTransparent->setText(balT.toDecimalhushString());
ui->balSpendable->setText(balSpendable.toDecimalhushString());
ui->balTotal->setText(balTotal.toDecimalhushString());
if (Settings::getInstance()->get_currency_name() == "USD")
@ -879,10 +900,12 @@ void Controller::refreshBalances()
CAmount balT = CAmount::fromqint64(reply["tbalance"].get<json::number_unsigned_t>());
CAmount balZ = CAmount::fromqint64(reply["zbalance"].get<json::number_unsigned_t>());
CAmount balVerified = CAmount::fromqint64(reply["verified_zbalance"].get<json::number_unsigned_t>());
CAmount balSpendable = CAmount::fromqint64(reply["spendable_zbalance"].get<json::number_unsigned_t>());
model->setBalT(balT);
model->setBalZ(balZ);
model->setBalVerified(balVerified);
model->setBalSpendable(balSpendable);
// This is for the websockets
AppDataModel::getInstance()->setBalances(balT, balZ);

16
src/controller.h

@ -108,7 +108,11 @@ public:
void saveWallet(const std::function<void(json)>& cb) { zrpc->saveWallet(cb); }
void supplyUpdate();
void clearWallet(const std::function<void(json)>& cb) { zrpc->clearWallet(cb); }
void shield(const std::function<void(json)>& cb) { zrpc->shield(cb); }
void createNewZaddr(bool sapling, const std::function<void(json)>& cb) {
unlockIfEncrypted([=] () {
@ -154,9 +158,17 @@ public:
});
}
void importZPrivKey(QString addr,const std::function<void(json)>& cb) {
unlockIfEncrypted([=] () {
zrpc->importZPrivKey(addr,cb);
}, [=](){});
}
// void importZPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb) { zrpc->importZPrivKey(addr, rescan, cb); }
// void importTPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb) { zrpc->importTPrivKey(addr, rescan, cb); }
void importTPrivKey(QString addr,const std::function<void(json)>& cb) {
unlockIfEncrypted([=] () {
zrpc->importTPrivKey(addr,cb);
}, [=](){});
}
QString getDefaultSaplingAddress();
QString getDefaultTAddress();

4
src/datamodel.h

@ -49,6 +49,9 @@ public:
CAmount getBalVerified() { QReadLocker locker(lock); return balVerified; }
void setBalVerified(CAmount a) { QReadLocker locker(lock); this->balVerified = a; }
CAmount getBalSpendable() { QReadLocker locker(lock); return balSpendable; }
void setBalSpendable(CAmount a) { QReadLocker locker(lock); this->balSpendable = a; }
CAmount getTotalPending() { QReadLocker locker(lock); return totalPending; }
void setTotalPending(CAmount a) { QReadLocker locker(lock); this->totalPending = a; }
@ -72,6 +75,7 @@ private:
CAmount balT;
CAmount balZ;
CAmount balVerified;
CAmount balSpendable;
QReadWriteLock* lock;
};

21
src/liteinterface.cpp

@ -27,6 +27,20 @@ void LiteInterface::fetchAddresses(const std::function<void(json)>& cb) {
conn->doRPCWithDefaultErrorHandling("addresses", "", cb);
}
void LiteInterface::importZPrivKey(QString addr, const std::function<void(json)>& cb) {
if (conn == nullptr)
return;
conn->doRPCWithDefaultErrorHandling("import", addr, cb);
}
void LiteInterface::importTPrivKey(QString addr,const std::function<void(json)>& cb) {
if (conn == nullptr)
return;
conn->doRPCWithDefaultErrorHandling("timport", addr, cb);
}
void LiteInterface::fetchUnspent(const std::function<void(json)>& cb) {
if (conn == nullptr)
@ -99,6 +113,13 @@ void LiteInterface::clearWallet(const std::function<void(json)>& cb) {
conn->doRPCWithDefaultErrorHandling("clear", "", cb);
}
void LiteInterface::shield(const std::function<void(json)>& cb) {
if (conn == nullptr)
return;
conn->doRPCWithDefaultErrorHandling("shield", "", cb);
}
void LiteInterface::unlockWallet(QString password, const std::function<void(json)>& cb) {
if (conn == nullptr)
return;

5
src/liteinterface.h

@ -63,6 +63,7 @@ public:
void saveWallet(const std::function<void(json)>& cb);
void clearWallet(const std::function<void(json)>& cb);
void shield(const std::function<void(json)>& cb);
void fetchWalletEncryptionStatus(const std::function<void(json)>& cb);
void fetchSupply(const std::function<void(json)>& cb);
@ -70,8 +71,8 @@ public:
void unlockWallet(QString password, const std::function<void(json)>& cb);
void removeWalletEncryption(QString password, const std::function<void(json)>& cb);
//void importZPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb);
//void importTPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb);
void importZPrivKey(QString addr, const std::function<void(json)>& cb);
void importTPrivKey(QString addr, const std::function<void(json)>& cb);
void sendTransaction(QString params, const std::function<void(json)>& cb, const std::function<void(QString)>& err);

178
src/mainwindow.cpp

@ -280,6 +280,8 @@ MainWindow::MainWindow(QWidget *parent) :
dialog.exec();
});
// Import Privkey
QObject::connect(ui->actionImport_Privatkey, &QAction::triggered, this, &MainWindow::importPrivKey);
// Address Book
QObject::connect(ui->action_Address_Book, &QAction::triggered, this, &MainWindow::addressBook);
@ -930,31 +932,41 @@ void MainWindow::donate() {
ui->tabWidget->setCurrentIndex(1);
}
// void MainWindow::doImport(QList<QString>* keys) {
// if (rpc->getConnection() == nullptr) {
// // No connection, just return
// return;
// }
void MainWindow::doImport(QList<QString>* keys) {
if (rpc->getConnection() == nullptr) {
// No connection, just return
return;
}
// if (keys->isEmpty()) {
// delete keys;
// ui->statusBar->showMessage(tr("Private key import rescan finished"));
// return;
// }
if (keys->isEmpty()) {
delete keys;
ui->statusBar->showMessage(tr("Private key import rescan in progress. Your funds will be automaticly shield to a wallet seed zaddr. This will take some time"));
return;
}
// Pop the first key
QString key = keys->first();
QString key1 = key + QString(" ") + QString("0");
keys->pop_front();
bool rescan = keys->isEmpty();
// // Pop the first key
// QString key = keys->first();
// keys->pop_front();
// bool rescan = keys->isEmpty();
if (key.startsWith("SK") ||
key.startsWith("secret")) {
rpc->importZPrivKey(key, [=] (auto) { this->doImport(keys); });
} else if (key.startsWith("U")) {
// if (key.startsWith("SK") ||
// key.startsWith("secret")) { // Z key
// rpc->importZPrivKey(key, rescan, [=] (auto) { this->doImport(keys); });
// } else {
// rpc->importTPrivKey(key, rescan, [=] (auto) { this->doImport(keys); });
// }
// }
rpc->importTPrivKey(key, [=] (auto) { this->doImport(keys); });
}else{
QMessageBox::critical(this, tr("Wrong Privatkey format"),
tr("Privatkey should start with U (for taddr) or secret- (for zaddr)") + "\n");
return;
}
}
// Callback invoked when the RPC has finished loading all the balances, and the UI
// is now ready to send transactions.
@ -1041,51 +1053,87 @@ void MainWindow::payhushURI(QString uri, QString myAddr) {
}
}
void MainWindow::importPrivKey() {
QDialog d(this);
Ui_PrivKey pui;
pui.setupUi(&d);
Settings::saveRestore(&d);
pui.buttonBox->button(QDialogButtonBox::Save)->setVisible(true);
pui.helpLbl->setText(QString() %
tr("Please paste your private key(zs-Addr or R-addr) here, one per import") % ".\n" %
tr("Caution: If this key is for Zs-addr it will be NOT inlcude in your Seed. Please send them direct to a Seed zs-addr") % ".\n" %
tr("R-addr keys will be autoshield to a seed zs-addr")
);
if (d.exec() == QDialog::Accepted && !pui.privKeyTxt->toPlainText().trimmed().isEmpty()) {
auto rawkeys = pui.privKeyTxt->toPlainText().trimmed().split("\n");
QList<QString> keysTmp;
// Filter out all the empty keys.
std::copy_if(rawkeys.begin(), rawkeys.end(), std::back_inserter(keysTmp), [=] (auto key) {
return !key.startsWith("#") && !key.trimmed().isEmpty();
});
auto keys = new QList<QString>();
std::transform(keysTmp.begin(), keysTmp.end(), std::back_inserter(*keys), [=](auto key) {
return key.trimmed().split(" ")[0];
});
// Special case.
// Sometimes, when importing from a paperwallet or such, the key is split by newlines, and might have
// been pasted like that. So check to see if the whole thing is one big private key
if (Settings::getInstance()->isValidSaplingPrivateKey(keys->join(""))) {
auto multiline = keys;
keys = new QList<QString>();
keys->append(multiline->join(""));
delete multiline;
}
// Start the import. The function takes ownership of keys
QTimer::singleShot(1, [=]() {doImport(keys);});
/////Rescan the Wallet (optional) and do automaticly shielding to a seed zaddr
if((pui.rescan->isChecked() == true) && (pui.privKeyTxt->toPlainText().startsWith("U"))) {
// Show the dialog that keys will be imported and rescan is in progress.
QMessageBox::information(this,
"Imported", tr("The keys were imported. It may take several minutes to rescan the blockchain. Until then, functionality may be limited"),
QMessageBox::Ok);
this->getRPC()->clearWallet([=] (auto) {
// Save the wallet
this->getRPC()->saveWallet([=] (auto) {
// Then reload the connection. The ConnectionLoader deletes itself.
auto cl = new ConnectionLoader(this, rpc);
cl->loadProgress();
});
});
}else if ((pui.rescan->isChecked() == true) && (pui.privKeyTxt->toPlainText().startsWith("secret"))){
// Show the dialog that keys will be imported.
QMessageBox::information(this,
"Imported", tr("The keys were imported. It may take several minutes to rescan the blockchain. Until then, functionality may be limited"),
QMessageBox::Ok);
this->getRPC()->clearWallet([=] (auto) {
// Save the wallet
this->getRPC()->saveWallet([=] (auto) {
// Then reload the connection. The ConnectionLoader deletes itself.
auto cl = new ConnectionLoader(this, rpc);
cl->loadConnection();
});
});
// void MainWindow::importPrivKey() {
// QDialog d(this);
// Ui_PrivKey pui;
// pui.setupUi(&d);
// Settings::saveRestore(&d);
// pui.buttonBox->button(QDialogButtonBox::Save)->setVisible(false);
// pui.helpLbl->setText(QString() %
// tr("Please paste your private keys (z-Addr or t-Addr) here, one per line") % ".\n" %
// tr("The keys will be imported into your connected hushd node"));
// if (d.exec() == QDialog::Accepted && !pui.privKeyTxt->toPlainText().trimmed().isEmpty()) {
// auto rawkeys = pui.privKeyTxt->toPlainText().trimmed().split("\n");
// QList<QString> keysTmp;
// // Filter out all the empty keys.
// std::copy_if(rawkeys.begin(), rawkeys.end(), std::back_inserter(keysTmp), [=] (auto key) {
// return !key.startsWith("#") && !key.trimmed().isEmpty();
// });
// auto keys = new QList<QString>();
// std::transform(keysTmp.begin(), keysTmp.end(), std::back_inserter(*keys), [=](auto key) {
// return key.trimmed().split(" ")[0];
// });
// // Special case.
// // Sometimes, when importing from a paperwallet or such, the key is split by newlines, and might have
// // been pasted like that. So check to see if the whole thing is one big private key
// if (Settings::getInstance()->isValidSaplingPrivateKey(keys->join(""))) {
// auto multiline = keys;
// keys = new QList<QString>();
// keys->append(multiline->join(""));
// delete multiline;
// }
// // Start the import. The function takes ownership of keys
// QTimer::singleShot(1, [=]() {doImport(keys);});
// // Show the dialog that keys will be imported.
// QMessageBox::information(this,
// "Imported", tr("The keys were imported. It may take several minutes to rescan the blockchain. Until then, functionality may be limited"),
// QMessageBox::Ok);
// }
// }
}else{
QMessageBox::information(this,
"Imported", tr("The keys were imported without rescan option. The Address you imported will be visible without balance"),
QMessageBox::Ok);
}
}
}
/**
* Export transaction history into a CSV file

45
src/mainwindow.ui

@ -59,7 +59,7 @@
<item row="0" column="0" colspan="2">
<widget class="QTabWidget" name="tabWidget">
<property name="currentIndex">
<number>0</number>
<number>1</number>
</property>
<widget class="QWidget" name="tab_6">
<attribute name="title">
@ -666,13 +666,40 @@
</layout>
</item>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_20">
<item>
<widget class="QLabel" name="label_40">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>Spendable</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="balSpendable">
<property name="text">
<string/>
</property>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
</layout>
</item>
<item row="4" column="0">
<widget class="Line" name="line">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QLabel" name="label_3">
@ -711,7 +738,7 @@
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0">
<widget class="QLabel" name="lblSyncWarning">
<property name="styleSheet">
<string notr="true">color:red;</string>
@ -724,7 +751,7 @@
</property>
</widget>
</item>
<item row="6" column="0">
<item row="7" column="0">
<widget class="QLabel" name="unconfirmedWarning">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
@ -743,14 +770,14 @@
</property>
</widget>
</item>
<item row="7" column="0">
<item row="8" column="0">
<widget class="QPushButton" name="depositHushButton">
<property name="text">
<string>Deposit Hush</string>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -1894,6 +1921,7 @@
<addaction name="actionRemove_Wallet_Encryption"/>
<addaction name="separator"/>
<addaction name="actionRescan"/>
<addaction name="actionImport_Privatkey"/>
</widget>
<addaction name="menuFile"/>
<addaction name="menu_Edit"/>
@ -2005,6 +2033,11 @@
<string>Rescan</string>
</property>
</action>
<action name="actionImport_Privatkey">
<property name="text">
<string>Import Privatkey</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<customwidgets>

17
src/privkey.ui

@ -14,14 +14,21 @@
<string>Private Keys</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="1" column="0">
<item row="1" column="0" colspan="3">
<widget class="QPlainTextEdit" name="privKeyTxt">
<property name="plainText">
<string/>
</property>
</widget>
</item>
<item row="2" column="0">
<item row="0" column="0">
<widget class="QLabel" name="helpLbl">
<property name="text">
<string notr="true">TextLabel</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
@ -31,10 +38,10 @@
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="helpLbl">
<item row="2" column="1">
<widget class="QRadioButton" name="rescan">
<property name="text">
<string notr="true">TextLabel</string>
<string>Rescan Wallet</string>
</property>
</widget>
</item>

Loading…
Cancel
Save