|
|
@ -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<json::number_unsigned_t>()); |
|
|
|
CAmount balZ = CAmount::fromqint64(reply["zbalance"].get<json::number_unsigned_t>()); |
|
|
|
CAmount balU = CAmount::fromqint64(reply["unconfirmed"].get<json::number_unsigned_t>()); |
|
|
|
CAmount balVerified = CAmount::fromqint64(reply["verified_zbalance"].get<json::number_unsigned_t>()); |
|
|
|
CAmount balSpendable = CAmount::fromqint64(reply["spendable_zbalance"].get<json::number_unsigned_t>()); |
|
|
|
|
|
|
|
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<json::number_integer_t>()), |
|
|
|
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( |
|
|
|