Browse Source

Add "Shield to sapling" menu item on balances table.

import_zecw
Aditya Kulkarni 6 years ago
parent
commit
9ee81ebbba
  1. 21
      src/mainwindow.cpp
  2. 12
      src/rpc.cpp
  3. 2
      src/rpc.h

21
src/mainwindow.cpp

@ -691,7 +691,7 @@ void MainWindow::setupBalancesTab() {
ui->unconfirmedWarning->setVisible(false);
// Double click on balances table
auto fnDoSendFrom = [=](const QString& addr) {
auto fnDoSendFrom = [=](const QString& addr, const QString& to = QString(), bool sendMax = false) {
// Find the inputs combo
for (int i = 0; i < ui->inputsCombo->count(); i++) {
if (ui->inputsCombo->itemText(i).startsWith(addr)) {
@ -700,6 +700,18 @@ void MainWindow::setupBalancesTab() {
}
}
// If there's a to address, add that as well
if (!to.isEmpty()) {
// Remember to clear any existing address fields, because we are creating a new transaction.
this->removeExtraAddresses();
ui->Address1->setText(to);
}
// See if max button has to be checked
if (sendMax) {
ui->Max1->setChecked(true);
}
// And switch to the send tab.
ui->tabWidget->setCurrentIndex(1);
};
@ -757,6 +769,13 @@ void MainWindow::setupBalancesTab() {
});
if (addr.startsWith("t")) {
auto defaultSapling = rpc->getDefaultSaplingAddress();
if (!defaultSapling.isEmpty()) {
menu.addAction("Shield balance to Sapling", [=] () {
fnDoSendFrom(addr, defaultSapling, true);
});
}
menu.addAction("View on block explorer", [=] () {
QString url;
if (Settings::getInstance()->isTestnet()) {

12
src/rpc.cpp

@ -1009,3 +1009,15 @@ void RPC::getZboardTopics(std::function<void(QMap<QString, QString>)> cb) {
}
});
}
/**
* Get a Sapling address from the user's wallet
*/
QString RPC::getDefaultSaplingAddress() {
for (QString addr: *zaddresses) {
if (Settings::getInstance()->isSaplingAddress(addr))
return addr;
}
return QString();
}

2
src/rpc.h

@ -62,6 +62,8 @@ public:
void shutdownZcashd();
void noConnection();
QString getDefaultSaplingAddress();
void getAllPrivKeys(const std::function<void(QList<QPair<QString, QString>>)>);
Turnstile* getTurnstile() { return turnstile; }

Loading…
Cancel
Save