diff --git a/lib/Cargo.lock b/lib/Cargo.lock index 174a16f..1f3f359 100644 --- a/lib/Cargo.lock +++ b/lib/Cargo.lock @@ -1849,7 +1849,7 @@ dependencies = [ [[package]] name = "silentdragonlitelib" version = "0.1.0" -source = "git+https://git.hush.is/hush/silentdragonlite-cli?rev=0181b16fd037f98c760e668bb6af8a41dd0d6267#0181b16fd037f98c760e668bb6af8a41dd0d6267" +source = "git+https://git.hush.is/lucretius/silentdragonlite-cli?rev=eff5dd7b6dbcfd7e4db6fdba423399337b590722#eff5dd7b6dbcfd7e4db6fdba423399337b590722" dependencies = [ "base58", "bellman", diff --git a/lib/Cargo.toml b/lib/Cargo.toml index 11e08b7..4d3007a 100644 --- a/lib/Cargo.toml +++ b/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://git.hush.is/hush/silentdragonlite-cli", rev = "0181b16fd037f98c760e668bb6af8a41dd0d6267" } +silentdragonlitelib = { git = "https://git.hush.is/lucretius/silentdragonlite-cli", rev = "eff5dd7b6dbcfd7e4db6fdba423399337b590722" } diff --git a/lib/src/lib.rs b/lib/src/lib.rs index 6f73c6d..eaa03ba 100644 --- a/lib/src/lib.rs +++ b/lib/src/lib.rs @@ -92,7 +92,15 @@ pub extern fn litelib_initialize_new(dangerous: bool,server: *const c_char) -> * } }; - LIGHTCLIENT.lock().unwrap().replace(Some(Arc::new(lightclient))); + let lc = Arc::new(lightclient); + match LightClient::start_mempool_monitor(lc.clone()) { + Ok(_) => {println!("Starting Mempool")}, + Err(e) => { + println!("Couldnt start mempool {}", e) + } + } + + LIGHTCLIENT.lock().unwrap().replace(Some(lc)); // Return the wallet's seed let s_str = CString::new(seed).unwrap(); @@ -135,7 +143,15 @@ pub extern fn litelib_initialize_new_from_phrase(dangerous: bool,server: *const // Initialize logging let _ = lightclient.init_logging(); - LIGHTCLIENT.lock().unwrap().replace(Some(Arc::new(lightclient))); + let lc = Arc::new(lightclient); + match LightClient::start_mempool_monitor(lc.clone()) { + Ok(_) => {println!("Starting Mempool")}, + Err(e) => { + println!("Couldnt start mempool {}",e) + } + } + + LIGHTCLIENT.lock().unwrap().replace(Some(lc)); let c_str = CString::new("OK").unwrap(); return c_str.into_raw(); @@ -169,8 +185,17 @@ pub extern fn litelib_initialize_existing(dangerous: bool, server: *const c_char // Initialize logging let _ = lightclient.init_logging(); + + + let lc = Arc::new(lightclient); + match LightClient::start_mempool_monitor(lc.clone()) { + Ok(_) => {println!("Starting Mempool")}, + Err(e) => { + println!("Couldnt start mempool {}",e) + } + } - LIGHTCLIENT.lock().unwrap().replace(Some(Arc::new(lightclient))); + LIGHTCLIENT.lock().unwrap().replace(Some(lc)); let c_str = CString::new("OK").unwrap(); return c_str.into_raw(); diff --git a/src/controller.cpp b/src/controller.cpp index c280b07..ec2e013 100644 --- a/src/controller.cpp +++ b/src/controller.cpp @@ -261,10 +261,12 @@ void Controller::noConnection() // Clear balances ui->balSheilded->setText(""); + ui->balUnconfirmed->setText(""); ui->balTransparent->setText(""); ui->balTotal->setText(""); ui->balSheilded->setToolTip(""); + ui->balUnconfirmed->setToolTip(""); ui->balTransparent->setToolTip(""); ui->balTotal->setToolTip(""); } @@ -738,6 +740,7 @@ void Controller::updateUIBalances() { CAmount balT = getModel()->getBalT(); CAmount balZ = getModel()->getBalZ(); + CAmount balU = getModel()->getBalU(); CAmount balVerified = getModel()->getBalVerified(); CAmount balSpendable = getModel()->getBalSpendable(); @@ -755,6 +758,7 @@ void Controller::updateUIBalances() // Balances table ui->balSheilded->setText(balZ.toDecimalhushString()); ui->balVerified->setText(balVerified.toDecimalhushString()); + ui->balUnconfirmed->setText(balU.toDecimalhushString()); ui->balTransparent->setText(balT.toDecimalhushString()); ui->balSpendable->setText(balSpendable.toDecimalhushString()); ui->balTotal->setText(balTotal.toDecimalhushString()); @@ -894,11 +898,13 @@ void Controller::refreshBalances() zrpc->fetchBalance([=] (json reply) { CAmount balT = CAmount::fromqint64(reply["tbalance"].get()); CAmount balZ = CAmount::fromqint64(reply["zbalance"].get()); + CAmount balU = CAmount::fromqint64(reply["unconfirmed"].get()); CAmount balVerified = CAmount::fromqint64(reply["verified_zbalance"].get()); CAmount balSpendable = CAmount::fromqint64(reply["spendable_zbalance"].get()); model->setBalT(balT); model->setBalZ(balZ); + model->setBalU(balU); model->setBalVerified(balVerified); model->setBalSpendable(balSpendable); @@ -936,6 +942,26 @@ void Controller::refreshBalances() }); } +void printJsonValue(QTextStream& out, const nlohmann::json& j, int depth = 0) { + if (j.is_array()) { + for (auto& elem : j) { + printJsonValue(out, elem, depth + 1); + } + } else if (j.is_object()) { + for (auto it = j.begin(); it != j.end(); ++it) { + std::string key = it.key(); + const nlohmann::json& value = it.value(); + out << QString::fromStdString(std::string(depth * 4, ' ')) + << QString::fromStdString(key) << ": "; + printJsonValue(out, value, depth + 1); + } + } else { + out << QString::fromStdString(j.dump(4)) << "\n"; + } +} + + + void Controller::refreshTransactions() { qDebug()<< __func__; if (!zrpc->haveConnection()) @@ -1047,7 +1073,6 @@ void Controller::refreshTransactions() { #define MESSAGEAS1 ((const unsigned char *) hashEncryptionKeyraw) /////////// #define MESSAGEAS1_LEN length - unsigned char sk[crypto_kx_SECRETKEYBYTES]; unsigned char pk[crypto_kx_PUBLICKEYBYTES]; @@ -1061,9 +1086,7 @@ void Controller::refreshTransactions() { unsigned char server_rx[crypto_kx_SESSIONKEYBYTES], server_tx[crypto_kx_SESSIONKEYBYTES]; ////////////////Get the pubkey from Bob, so we can create the share key - /////Create the shared key for sending the message - if (crypto_kx_server_session_keys(server_rx, server_tx, pk, sk, pubkeyBob) != 0) { main->logger->write("Suspicious client public outgoing key, bail out "); @@ -1085,15 +1108,11 @@ void Controller::refreshTransactions() { { //////unsigned char* as message from QString #define MESSAGE2 (const unsigned char *) encryptedMemo - ///////// length of the encrypted message #define CIPHERTEXT1_LEN encryptedMemoSize1 - ///////Message length is smaller then the encrypted message #define MESSAGE1_LEN encryptedMemoSize1 - crypto_secretstream_xchacha20poly1305_ABYTES - //////Set the length of the decrypted message - unsigned char decrypted[MESSAGE1_LEN]; unsigned char tag[crypto_secretstream_xchacha20poly1305_TAG_FINAL]; crypto_secretstream_xchacha20poly1305_state state; @@ -1121,7 +1140,6 @@ void Controller::refreshTransactions() { /////Now we can convert it to QString //////////////Give us the output of the decrypted message as debug to see if it was successfully - ChatItem item = ChatItem( datetime, address, @@ -1164,13 +1182,13 @@ void Controller::refreshTransactions() { } else { { // Incoming Transaction - address = (it["address"].is_null() ? "" : QString::fromStdString(it["address"])); - model->markAddressUsed(address); + QString memo; + address = (it["address"].is_null() ? "" : QString::fromStdString(it["address"])); - QString memo; if (!it["memo"].is_null()) { memo = QString::fromStdString(it["memo"]); } + items.push_back(TransactionItemDetail{ address, CAmount::fromqint64(it["amount"].get()), memo @@ -1190,7 +1208,7 @@ void Controller::refreshTransactions() { QString contactname = ""; bool isContact = false; - if (!it["memo"].is_null()) { + if (!memo.isNull()) { if (memo.startsWith("{")) { try { @@ -1260,7 +1278,8 @@ void Controller::refreshTransactions() { if (position == 1) { chatModel->addMemo(txid, headerbytes); - } else { + } + else { // } @@ -1276,7 +1295,6 @@ void Controller::refreshTransactions() { #define MESSAGEAS1 ((const unsigned char *) hashEncryptionKeyraw)/////////// #define MESSAGEAS1_LEN length - unsigned char sk[crypto_kx_SECRETKEYBYTES]; unsigned char pk[crypto_kx_PUBLICKEYBYTES]; @@ -1290,7 +1308,6 @@ void Controller::refreshTransactions() { unsigned char client_rx[crypto_kx_SESSIONKEYBYTES], client_tx[crypto_kx_SESSIONKEYBYTES]; ////////////////Get the pubkey from Bob, so we can create the share key - /////Create the shared key for sending the message if (crypto_kx_client_session_keys(client_rx, client_tx, pk, sk, pubkeyBob) != 0) { @@ -1307,18 +1324,13 @@ void Controller::refreshTransactions() { int encryptedMemoSize1 = ba.length(); //int headersize = ba1.length(); - //////unsigned char* as message from QString #define MESSAGE2 (const unsigned char *) encryptedMemo - ///////// length of the encrypted message #define CIPHERTEXT1_LEN encryptedMemoSize1 - ///////Message length is smaller then the encrypted message #define MESSAGE1_LEN encryptedMemoSize1 - crypto_secretstream_xchacha20poly1305_ABYTES - //////Set the length of the decrypted message - unsigned char decrypted[MESSAGE1_LEN+1]; unsigned char tag[crypto_secretstream_xchacha20poly1305_TAG_FINAL]; crypto_secretstream_xchacha20poly1305_state state; @@ -1346,7 +1358,6 @@ void Controller::refreshTransactions() { memodecrypt = QString::fromUtf8( decryptedMemo.data(), decryptedMemo.size()); ////Give us the output of the decrypted message as debug to see if it was successfully - ChatItem item = ChatItem( datetime, address, @@ -1370,8 +1381,6 @@ void Controller::refreshTransactions() { qDebug() << __func__ << ": ignoring txid="<< txid; } - //} else if (memo.startsWith("{")) { - //qDebug() << __func__ << ": ignoring a header memo"; } else { // Add a chatitem for the initial CR ChatItem item = ChatItem( diff --git a/src/datamodel.h b/src/datamodel.h index 4c32bdf..ef39a42 100644 --- a/src/datamodel.h +++ b/src/datamodel.h @@ -48,6 +48,9 @@ public: CAmount getBalZ() { QReadLocker locker(lock); return balZ; } void setBalZ(CAmount a) { QReadLocker locker(lock); this->balZ = a; } + CAmount getBalU() { QReadLocker locker(lock); return balU; } + void setBalU(CAmount a) { QReadLocker locker(lock); this->balU = a; } + CAmount getBalVerified() { QReadLocker locker(lock); return balVerified; } void setBalVerified(CAmount a) { QReadLocker locker(lock); this->balVerified = a; } @@ -76,6 +79,7 @@ private: CAmount balT; CAmount balZ; + CAmount balU; CAmount balVerified; CAmount balSpendable; diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 0a4b91d..db12534 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -641,6 +641,33 @@ + + + 0 + 0 + + + + Unconfirmed + + + + + + + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + + + + + + + 0 @@ -664,7 +691,7 @@ - + @@ -691,14 +718,14 @@ - + Qt::Horizontal - + @@ -735,7 +762,7 @@ - + color:red; @@ -748,7 +775,7 @@ - + @@ -767,14 +794,14 @@ - + Deposit Hush - + Qt::Vertical diff --git a/src/version.h b/src/version.h index 514ba63..c1543d3 100644 --- a/src/version.h +++ b/src/version.h @@ -1,3 +1,3 @@ // Copyright 2019-2023 The Hush developers // Released under the GPLv3 -#define APP_VERSION "1.5.3" +#define APP_VERSION "1.5.4"