diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 758f203..7a7961f 100644 --- a/src/mainwindow.cpp +++ b/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()) { diff --git a/src/rpc.cpp b/src/rpc.cpp index b638540..1dfea1c 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -1009,3 +1009,15 @@ void RPC::getZboardTopics(std::function)> 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(); +} \ No newline at end of file diff --git a/src/rpc.h b/src/rpc.h index 607ff15..c198532 100644 --- a/src/rpc.h +++ b/src/rpc.h @@ -62,6 +62,8 @@ public: void shutdownZcashd(); void noConnection(); + QString getDefaultSaplingAddress(); + void getAllPrivKeys(const std::function>)>); Turnstile* getTurnstile() { return turnstile; }