export priv key in the addresses dialog
This commit is contained in:
@@ -677,6 +677,12 @@ void MainWindow::backupWalletDat() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::exportAllKeys() {
|
void MainWindow::exportAllKeys() {
|
||||||
|
exportKeys("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void MainWindow::exportKeys(QString addr) {
|
||||||
|
bool allKeys = addr.isEmpty() ? true : false;
|
||||||
|
|
||||||
QDialog d(this);
|
QDialog d(this);
|
||||||
Ui_PrivKey pui;
|
Ui_PrivKey pui;
|
||||||
pui.setupUi(&d);
|
pui.setupUi(&d);
|
||||||
@@ -691,7 +697,11 @@ void MainWindow::exportAllKeys() {
|
|||||||
pui.privKeyTxt->setPlainText("Loading...");
|
pui.privKeyTxt->setPlainText("Loading...");
|
||||||
pui.privKeyTxt->setReadOnly(true);
|
pui.privKeyTxt->setReadOnly(true);
|
||||||
pui.privKeyTxt->setLineWrapMode(QPlainTextEdit::LineWrapMode::NoWrap);
|
pui.privKeyTxt->setLineWrapMode(QPlainTextEdit::LineWrapMode::NoWrap);
|
||||||
pui.helpLbl->setText("These are all the private keys for all the addresses in your wallet");
|
|
||||||
|
if (allKeys)
|
||||||
|
pui.helpLbl->setText("These are all the private keys for all the addresses in your wallet");
|
||||||
|
else
|
||||||
|
pui.helpLbl->setText("Private key for " + addr);
|
||||||
|
|
||||||
// Disable the save button until it finishes loading
|
// Disable the save button until it finishes loading
|
||||||
pui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(false);
|
pui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(false);
|
||||||
@@ -700,7 +710,7 @@ void MainWindow::exportAllKeys() {
|
|||||||
// Wire up save button
|
// Wire up save button
|
||||||
QObject::connect(pui.buttonBox->button(QDialogButtonBox::Save), &QPushButton::clicked, [=] () {
|
QObject::connect(pui.buttonBox->button(QDialogButtonBox::Save), &QPushButton::clicked, [=] () {
|
||||||
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
|
QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),
|
||||||
"zcash-all-privatekeys.txt");
|
allKeys ? "zcash-all-privatekeys.txt" : "zcash-privatekey.txt");
|
||||||
QFile file(fileName);
|
QFile file(fileName);
|
||||||
if (!file.open(QIODevice::WriteOnly)) {
|
if (!file.open(QIODevice::WriteOnly)) {
|
||||||
QMessageBox::information(this, tr("Unable to open file"), file.errorString());
|
QMessageBox::information(this, tr("Unable to open file"), file.errorString());
|
||||||
@@ -712,9 +722,10 @@ void MainWindow::exportAllKeys() {
|
|||||||
|
|
||||||
// Call the API
|
// Call the API
|
||||||
auto isDialogAlive = std::make_shared<bool>(true);
|
auto isDialogAlive = std::make_shared<bool>(true);
|
||||||
rpc->getAllPrivKeys([=] (auto privKeys) {
|
|
||||||
|
auto fnUpdateUIWithKeys = [=](QList<QPair<QString, QString>> privKeys) {
|
||||||
// Check to see if we are still showing.
|
// Check to see if we are still showing.
|
||||||
if (! *isDialogAlive.get()) return;
|
if (!isDialogAlive) return;
|
||||||
|
|
||||||
QString allKeysTxt;
|
QString allKeysTxt;
|
||||||
for (auto keypair : privKeys) {
|
for (auto keypair : privKeys) {
|
||||||
@@ -723,10 +734,28 @@ void MainWindow::exportAllKeys() {
|
|||||||
|
|
||||||
pui.privKeyTxt->setPlainText(allKeysTxt);
|
pui.privKeyTxt->setPlainText(allKeysTxt);
|
||||||
pui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(true);
|
pui.buttonBox->button(QDialogButtonBox::Save)->setEnabled(true);
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (allKeys) {
|
||||||
|
rpc->getAllPrivKeys(fnUpdateUIWithKeys);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
auto fnAddKey = [=](json key) {
|
||||||
|
QList<QPair<QString, QString>> singleAddrKey;
|
||||||
|
singleAddrKey.push_back(QPair<QString, QString>(addr, QString::fromStdString(key.get<json::string_t>())));
|
||||||
|
fnUpdateUIWithKeys(singleAddrKey);
|
||||||
|
};
|
||||||
|
|
||||||
|
if (Settings::getInstance()->isZAddress(addr)) {
|
||||||
|
rpc->getZPrivKey(addr, fnAddKey);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rpc->getTPrivKey(addr, fnAddKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
d.exec();
|
d.exec();
|
||||||
*isDialogAlive.get() = false;
|
*isDialogAlive = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::setupBalancesTab() {
|
void MainWindow::setupBalancesTab() {
|
||||||
@@ -786,26 +815,7 @@ void MainWindow::setupBalancesTab() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
menu.addAction("Get private key", [=] () {
|
menu.addAction("Get private key", [=] () {
|
||||||
auto fnCB = [=] (const json& reply) {
|
this->exportKeys(addr);
|
||||||
auto privKey = QString::fromStdString(reply.get<json::string_t>());
|
|
||||||
QDialog d(this);
|
|
||||||
Ui_PrivKey pui;
|
|
||||||
pui.setupUi(&d);
|
|
||||||
|
|
||||||
pui.helpLbl->setText("Private Key:");
|
|
||||||
pui.privKeyTxt->setPlainText(privKey);
|
|
||||||
pui.privKeyTxt->setReadOnly(true);
|
|
||||||
pui.privKeyTxt->selectAll();
|
|
||||||
pui.buttonBox->button(QDialogButtonBox::Save)->setVisible(false);
|
|
||||||
pui.buttonBox->button(QDialogButtonBox::Ok)->setVisible(false);
|
|
||||||
|
|
||||||
d.exec();
|
|
||||||
};
|
|
||||||
|
|
||||||
if (Settings::getInstance()->isZAddress(addr))
|
|
||||||
rpc->getZPrivKey(addr, fnCB);
|
|
||||||
else
|
|
||||||
rpc->getTPrivKey(addr, fnCB);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
menu.addAction("Send from " % addr.left(40) % (addr.size() > 40 ? "..." : ""), [=]() {
|
menu.addAction("Send from " % addr.left(40) % (addr.size() > 40 ? "..." : ""), [=]() {
|
||||||
@@ -1072,6 +1082,9 @@ void MainWindow::setupRecieveTab() {
|
|||||||
auto curLabel = AddressBook::getInstance()->getLabelForAddress(addr);
|
auto curLabel = AddressBook::getInstance()->getLabelForAddress(addr);
|
||||||
auto label = ui->rcvLabel->text().trimmed();
|
auto label = ui->rcvLabel->text().trimmed();
|
||||||
|
|
||||||
|
if (curLabel == label) // Nothing to update
|
||||||
|
return;
|
||||||
|
|
||||||
QString info;
|
QString info;
|
||||||
|
|
||||||
if (!curLabel.isEmpty() && label.isEmpty()) {
|
if (!curLabel.isEmpty() && label.isEmpty()) {
|
||||||
@@ -1101,6 +1114,14 @@ void MainWindow::setupRecieveTab() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Recieve Export Key
|
||||||
|
QObject::connect(ui->exportKey, &QPushButton::clicked, [=]() {
|
||||||
|
QString addr = ui->listRecieveAddresses->currentText();
|
||||||
|
if (addr.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
this->exportKeys(addr);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
MainWindow::~MainWindow()
|
MainWindow::~MainWindow()
|
||||||
|
|||||||
@@ -92,6 +92,7 @@ private:
|
|||||||
void postToZBoard();
|
void postToZBoard();
|
||||||
void importPrivKey();
|
void importPrivKey();
|
||||||
void exportAllKeys();
|
void exportAllKeys();
|
||||||
|
void exportKeys(QString addr = "");
|
||||||
void backupWalletDat();
|
void backupWalletDat();
|
||||||
|
|
||||||
void doImport(QList<QString>* keys);
|
void doImport(QList<QString>* keys);
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QTabWidget" name="tabWidget">
|
<widget class="QTabWidget" name="tabWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="tab">
|
<widget class="QWidget" name="tab">
|
||||||
<attribute name="title">
|
<attribute name="title">
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>300</width>
|
<width>250</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
@@ -52,6 +52,12 @@
|
|||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QLabel" name="label">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Shielded</string>
|
<string>Shielded</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -73,6 +79,12 @@
|
|||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_2">
|
<widget class="QLabel" name="label_2">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Transparent</string>
|
<string>Transparent</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -101,6 +113,12 @@
|
|||||||
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
<weight>75</weight>
|
<weight>75</weight>
|
||||||
@@ -145,6 +163,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="unconfirmedWarning">
|
<widget class="QLabel" name="unconfirmedWarning">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Minimum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="styleSheet">
|
<property name="styleSheet">
|
||||||
<string notr="true">color: red;</string>
|
<string notr="true">color: red;</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -160,6 +184,12 @@
|
|||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QGroupBox" name="groupBox_2">
|
<widget class="QGroupBox" name="groupBox_2">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>Address Balances</string>
|
<string>Address Balances</string>
|
||||||
</property>
|
</property>
|
||||||
@@ -672,6 +702,13 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="2" column="1" colspan="2">
|
||||||
|
<widget class="QLabel" name="rcvBal">
|
||||||
|
<property name="text">
|
||||||
|
<string> </string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="2" column="0">
|
<item row="2" column="0">
|
||||||
<widget class="QLabel" name="label_21">
|
<widget class="QLabel" name="label_21">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -684,12 +721,8 @@
|
|||||||
<property name="maxLength">
|
<property name="maxLength">
|
||||||
<number>40</number>
|
<number>40</number>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="placeholderText">
|
||||||
</item>
|
<string>Optional</string>
|
||||||
<item row="2" column="1" colspan="2">
|
|
||||||
<widget class="QLabel" name="rcvBal">
|
|
||||||
<property name="text">
|
|
||||||
<string>TextLabel</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -716,6 +749,30 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="3" column="1" colspan="2">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_16">
|
||||||
|
<item>
|
||||||
|
<widget class="QPushButton" name="exportKey">
|
||||||
|
<property name="text">
|
||||||
|
<string>Export Private Key</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_5">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
QRCodeLabel::QRCodeLabel(QWidget *parent) :
|
QRCodeLabel::QRCodeLabel(QWidget *parent) :
|
||||||
QLabel(parent)
|
QLabel(parent)
|
||||||
{
|
{
|
||||||
this->setMinimumSize(1,1);
|
this->setMinimumSize(100, 100);
|
||||||
setScaledContents(false);
|
setScaledContents(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -285,7 +285,6 @@ void RPC::getAllPrivKeys(const std::function<void(QList<QPair<QString, QString>>
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
// First get all the t and z addresses.
|
// First get all the t and z addresses.
|
||||||
json payloadT = {
|
json payloadT = {
|
||||||
{"jsonrpc", "1.0"},
|
{"jsonrpc", "1.0"},
|
||||||
|
|||||||
Reference in New Issue
Block a user