add tkey import and autoshield it
This commit is contained in:
7
lib/Cargo.lock
generated
7
lib/Cargo.lock
generated
@@ -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=7637fba279fa9fc47da47ff7d8e5b993f823ec6e)",
|
||||
"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=7637fba279fa9fc47da47ff7d8e5b993f823ec6e#7637fba279fa9fc47da47ff7d8e5b993f823ec6e"
|
||||
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=7637fba279fa9fc47da47ff7d8e5b993f823ec6e)" = "<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"
|
||||
|
||||
@@ -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 = "7637fba279fa9fc47da47ff7d8e5b993f823ec6e" }
|
||||
silentdragonlitelib = { git = "https://github.com/MyHush/silentdragonlite-cli", rev = "8535a11e3774d79de2ebeaa5540567ccb4988f81" }
|
||||
|
||||
@@ -81,25 +81,19 @@ void ConnectionLoader::ShowProgress()
|
||||
auto connection = makeConnection(config);
|
||||
auto me = this;
|
||||
|
||||
// After the lib is initialized, try to do get info
|
||||
connection->doRPC("info", "", [=](auto reply) {
|
||||
// If success, set the connection
|
||||
main->logger->write("Connection is online.");
|
||||
connection->setInfo(reply);
|
||||
main->logger->write("getting Connection reply");
|
||||
isSyncing = new QAtomicInteger<bool>();
|
||||
isSyncing->store(true);
|
||||
main->logger->write("isSyncing");
|
||||
|
||||
// Do a sync at startup
|
||||
// Do a sync after import
|
||||
syncTimer = new QTimer(main);
|
||||
main->logger->write("Beginning sync");
|
||||
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->doRPCSetConnection(connection);
|
||||
this->doRPCSetConnectionShield(connection);
|
||||
});
|
||||
|
||||
// While it is syncing, we'll show the status updates while it is alive.
|
||||
@@ -126,7 +120,6 @@ void ConnectionLoader::ShowProgress()
|
||||
}catch (...)
|
||||
{
|
||||
main->logger->write("catch sync progress reply");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -136,9 +129,6 @@ void ConnectionLoader::ShowProgress()
|
||||
syncTimer->start();
|
||||
main->logger->write("Start sync timer");
|
||||
|
||||
}, [=](QString err) {
|
||||
showError(err);
|
||||
});
|
||||
}
|
||||
|
||||
void ConnectionLoader::doAutoConnect()
|
||||
@@ -272,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);
|
||||
|
||||
@@ -41,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;
|
||||
|
||||
@@ -109,6 +109,8 @@ public:
|
||||
void saveWallet(const std::function<void(json)>& cb) { zrpc->saveWallet(cb); }
|
||||
|
||||
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([=] () {
|
||||
@@ -159,8 +161,12 @@ public:
|
||||
zrpc->importZPrivKey(addr,cb);
|
||||
}, [=](){});
|
||||
}
|
||||
// void importZPrivKey(QString addr, const std::function<void(json)>& cb,const std::function<void(QString)>& err) { zrpc->importZPrivKey(addr, 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();
|
||||
|
||||
@@ -30,29 +30,16 @@ void LiteInterface::fetchAddresses(const std::function<void(json)>& cb) {
|
||||
void LiteInterface::importZPrivKey(QString addr, const std::function<void(json)>& cb) {
|
||||
if (conn == nullptr)
|
||||
return;
|
||||
|
||||
// QString params = addr % QString(" ");
|
||||
// params.append(birthday);
|
||||
qDebug()<<addr;
|
||||
|
||||
|
||||
|
||||
|
||||
conn->doRPCWithDefaultErrorHandling("import", addr, cb);
|
||||
// conn->doRPC("import", params, cb, err);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*void LiteInterface::importTPrivKey(QString addr, bool rescan, const std::function<void(json)>& cb) {
|
||||
void LiteInterface::importTPrivKey(QString addr,const std::function<void(json)>& cb) {
|
||||
if (conn == nullptr)
|
||||
return;
|
||||
|
||||
|
||||
|
||||
// conn->doRPCWithDefaultErrorHandling("import", addr, cb);
|
||||
|
||||
// conn->doRPC("import", addr, 0, cb);
|
||||
}*/
|
||||
conn->doRPCWithDefaultErrorHandling("timport", addr, cb);
|
||||
}
|
||||
|
||||
|
||||
void LiteInterface::fetchUnspent(const std::function<void(json)>& cb) {
|
||||
@@ -126,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;
|
||||
|
||||
@@ -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);
|
||||
@@ -71,7 +72,7 @@ public:
|
||||
void removeWalletEncryption(QString password, const std::function<void(json)>& cb);
|
||||
|
||||
void importZPrivKey(QString addr, const std::function<void(json)>& cb);
|
||||
//void importTPrivKey(QString addr, bool rescan, 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);
|
||||
|
||||
@@ -940,7 +940,7 @@ void MainWindow::donate() {
|
||||
|
||||
if (keys->isEmpty()) {
|
||||
delete keys;
|
||||
ui->statusBar->showMessage(tr("Private key import rescan finished"));
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -953,19 +953,20 @@ void MainWindow::donate() {
|
||||
|
||||
|
||||
if (key.startsWith("SK") ||
|
||||
key.startsWith("secret")) { // Z key
|
||||
key.startsWith("secret")) {
|
||||
|
||||
rpc->importZPrivKey(key, [=] (auto) { this->doImport(keys); });
|
||||
|
||||
// Then reload the connection. The ConnectionLoader deletes itself.
|
||||
|
||||
|
||||
|
||||
} else {
|
||||
// rpc->importTPrivKey(key, rescan, [=] (auto) { this->doImport(keys); });
|
||||
}
|
||||
}
|
||||
|
||||
} else if (key.startsWith("U")) {
|
||||
|
||||
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.
|
||||
@@ -1060,9 +1061,9 @@ void MainWindow::payhushURI(QString uri, QString myAddr) {
|
||||
|
||||
pui.buttonBox->button(QDialogButtonBox::Save)->setVisible(true);
|
||||
pui.helpLbl->setText(QString() %
|
||||
tr("Please paste your private key(z-Addr) here, one per import") % ".\n" %
|
||||
tr("Caution: These key will be NOT inlcude in your Seed. Please send them direct to a Seed zaddr") % ".\n" %
|
||||
tr("The import of your Privatkey will take some time.")
|
||||
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()) {
|
||||
@@ -1092,14 +1093,45 @@ void MainWindow::payhushURI(QString uri, QString myAddr) {
|
||||
// Start the import. The function takes ownership of keys
|
||||
QTimer::singleShot(1, [=]() {doImport(keys);});
|
||||
|
||||
auto cl = new ConnectionLoader(this, rpc);
|
||||
QTimer::singleShot(1, [=]() { cl->loadProgress(); });
|
||||
|
||||
/////Rescan the Wallet (optional) and do automaticly shielding to a seed zaddr
|
||||
|
||||
// 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);
|
||||
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();
|
||||
});
|
||||
});
|
||||
|
||||
}else{
|
||||
QMessageBox::information(this,
|
||||
"Imported", tr("The keys were imported without rescan option. The Address you imported will be visible without balance"),
|
||||
QMessageBox::Ok);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user